source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_platine.ksh @ 187

Last change on this file since 187 was 187, checked in by aclsce, 15 years ago

Use of TMPDIR_IGCM as TMPDIR.
Remove RUN_DIR at the end on RUN mode.
Removed Master variable declared as read-only variable.
Removed echo in count_archive function.
Coherence in filename used by mail function.

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Date Author Revision
File size: 38.8 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip
5# Contact: Martial.Mancip_ipsl.jussieu.fr
6# $Date$
7# $Author$
8# $Revision$
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11# History:
12# Modification:
13#
14#**************************************************************
15
16#=========================================================
17# The documentation of this file can be automatically generated
18# if you use the prefix #D- for comments to be extracted.
19# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
20#=========================================================
21
22#D-#==================================================
23#D-LibIGCM_sys for Platine
24#D-#==================================================
25#D-
26#D- This ksh library if a layer under some usefull
27#D-environment variables and shell commands.
28#D-All those definitions depend on host particularities.
29#D-It manages a stack mechanism and test validity of operations.
30#D-All function described bellow must be prefixed by IGCM_sys.
31
32#====================================================
33# libIGCM_sys PARAMETERS
34#====================================================
35
36#====================================================
37# set DEBUG_sys to true to output calls of function
38typeset -r DEBUG_sys=${DEBUG_sys:=true}
39
40#====================================================
41# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
42typeset -r DRYRUN=${DRYRUN:=0}
43
44# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
45# -------------------------------------------------------------------------------------
46# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
47# |          |  Cp/Exe param files |            |  Chmod  |                           |
48# |          |      Qsub           |            |         |                           |
49# -------------------------------------------------------------------------------------
50# |    0     |       yes           |    yes     |  yes    |      yes                  |
51# -------------------------------------------------------------------------------------
52# |    1     |       yes           |    yes     |  yes    |      no                   |
53# -------------------------------------------------------------------------------------
54# |    2     |       yes           |    yes     |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56# |    3     |       yes           |    no      |  no     |      no                   |
57# -------------------------------------------------------------------------------------
58
59#=====================================================
60# Global Variables :
61#=====================================================
62# Language : "fr" or "en"
63typeset -r MYLANG="fr"
64
65#=====================================================
66# Host and user names
67# $hostname ou hostname
68typeset -r HOST=$( hostname )
69# $username ou whoami
70typeset -r LOGIN=$( whoami )
71# $hostname of the MASTER job
72typeset MASTER=platine
73
74#D-
75#D-#==================================================
76#D-Program used in libIGCM
77#D-#==================================================
78
79# rsync with path
80typeset -r RSYNC=/home/cont003/p86denv/SX_RSYNC/bin/rsync
81#typeset -r RSYNC_FRONT="rsh platine-eth0 /usr/bin/rsync "
82# RSYNC_opt args to rsync
83typeset -r RSYNC_opt="-Lt -v"
84# RSYNC_opt args to "remote rsync"
85# ie storage filesystem
86typeset -r RHOST=fer.ccc.cea.fr
87typeset -r REMOTE_RSYNC=/dmnfs/cont003/p86denv/RSYNC/bin/rsync
88
89#====================================================
90# Source Ferret
91. /home/cont003/p86ipsl/.atlas_env_platine_ksh
92
93#====================================================
94# Specific for ocean additionnal diagnostic
95export FER_GO="$FER_GO /home/cont003/p86denv/IGCM_POST_UTIL/JNL /home/cont003/p86denv/GRAF /home/cont003/p86denv/GRAF/GO"
96export FER_PALETTE="$FER_PALETTE /home/cont003/p86denv/GRAF/PALET"
97
98#====================================================
99# Host specific DIRECTORIES
100#====================================================
101
102#====================================================
103#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
104typeset -r R_EXE="${MODIPSL}/bin"
105
106#====================================================
107#- SUBMIT_DIR : submission dir
108typeset SUBMIT_DIR=${SUBMIT_DIR:=${PWD}}
109
110#====================================================
111#- ARCHIVE
112typeset -r ARCHIVE=${DMFDIR}
113
114#====================================================
115#- libIGCM_POST
116typeset -r libIGCM_POST=${libIGCM}
117
118#====================================================
119#- IN
120typeset -r R_IN=${R_IN:=/dmnfs/cont003/p86ipsl/IGCM}
121
122#====================================================
123#- OUT
124typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
125
126#====================================================
127#- OUT_SCR (ONLY FOR double copy an scratch)
128typeset -r R_OUT_SCR=${SCRATCHDIR}/IGCM_OUT
129
130#====================================================
131#- OUT_POST
132typeset -r R_OUT_POST=${SCRATCHDIR}/IGCM_OUT
133
134#====================================================
135#- RUN_DIR_PATH : Temporary working directory (=> TMP)
136typeset RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}}
137if [ $LSB_QUEUE == post ] ; then
138    typeset -r RUN_DIR_PATH=${SCRATCHDIR}/TMPDIR_IGCM/tmp$$
139    if [ ! -d ${RUN_DIR_PATH} ]; then 
140        \mkdir -p ${RUN_DIR_PATH}
141        if [ $? -gt 0 ] ; then
142            echo "Error in creation of "${RUN_DIR_PATH}
143        fi
144    fi
145fi
146
147#====================================================
148#- BIG_DIR : BIG_DIR to store files waiting for rebuild
149typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD}
150
151#====================================================
152#- HOST_MPIRUN_COMMAND
153typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time srun"}
154
155#====================================================
156#- Max number of arguments passed to nco operator or demigration command
157UNIX_MAX_LIMIT=360
158
159##D-#==================================================
160#D-function IGCM_sys_RshMaster
161#D-* Purpose: Just a fake command to wrapp
162#D-           IGCM_card call in post-treatment
163#D-           Ulam do not see brodie filesystem
164#D-           Cesium do not see all mercure filesystem
165#D-           That's why we need this hake.
166#D-* Examples:
167#D-
168function IGCM_sys_RshMaster {
169    #set -vx
170    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
171    /bin/ksh <<-EOF
172    export libIGCM=${libIGCM}
173    export DEBUG_debug=${DEBUG_debug}
174    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
175    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
176    ${@}
177EOF
178    if [ $? -gt 0 ] ; then
179        echo "IGCM_sys_RshMaster : erreur."
180        IGCM_debug_Exit "IGCM_sys_RshMaster"
181    fi
182    IGCM_debug_PopStack "IGCM_sys_RshMaster"
183}
184
185#D-#==================================================
186#D-function IGCM_sys_RshArchive
187#D-* Purpose: Archive rsh command
188#D-* Examples:
189#D-
190function IGCM_sys_RshArchive {
191    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
192    /bin/ksh <<-EOF
193    ${@}
194EOF
195    if [ $? -gt 0 ] ; then
196        echo "IGCM_sys_RshArchive : erreur."
197        IGCM_debug_Exit "IGCM_sys_RshArchive"
198    fi
199    IGCM_debug_PopStack "IGCM_sys_RshArchive"
200}
201
202#D-#==================================================
203#D-function IGCM_sys_RshPost
204#D-* Purpose: Post-process rsh command
205#D-* Examples:
206#D-
207function IGCM_sys_RshPost {
208    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
209    if ( $DEBUG_sys ) ; then
210        echo "IGCM_sys_RshPost :" $@
211    fi
212    /bin/ksh ${@}
213    if [ $? -gt 0 ] ; then
214        echo "IGCM_sys_RshPost : erreur."
215        IGCM_debug_Exit "IGCM_sys_RshPost"
216    fi
217    IGCM_debug_PopStack "IGCM_sys_RshPost"
218}
219
220#D-#==================================================
221#D-function IGCM_sys_SendMail
222#D-* Purpose: Send mail when simulation is over
223#D-* Examples:
224#D-
225function IGCM_sys_SendMail {
226    IGCM_debug_PushStack "IGCM_sys_SendMailPost" $@
227    if ( $DEBUG_sys ) ; then
228       echo "IGCM_sys_SendMail :" $@
229    fi
230    cat  << END_MAIL > job_end.mail
231Dear ${LOGIN},
232
233  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
234  Job started : ${DateBegin}
235  Job ended   : ${DateEnd}
236  Ouput files are available in ${R_SAVE}
237END_MAIL
238
239    if [ ! -z ${config_UserChoices_MailName} ] ; then
240        mailx -s "${config_UserChoices_JobName} completed" ${config_UserChoices_MailName} < job_end.mail
241    elif [ -f ~/.forward ] ; then
242        mailx -s "${config_UserChoices_JobName} completed" $( cat ~/.forward ) < job_end.mail
243    fi
244
245    if [ $? -gt 0 ] ; then
246        echo "IGCM_sys_SendMail : erreur."
247        IGCM_debug_Exit "IGCM_sys_SendMail"
248    fi
249    IGCM_debug_PopStack "IGCM_sys_SendMail"
250}
251
252#D-#==================================================
253#D-function IGCM_sys_Mkdir
254#D-* Purpose: Master locale mkdir command
255#D-* Examples:
256#D-
257function IGCM_sys_Mkdir {
258    IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
259    if ( $DEBUG_sys ) ; then
260        echo "IGCM_sys_Mkdir :" $@
261    fi
262    if [ ! -d ${1} ]; then
263        \mkdir -p $1
264        if [ $? -gt 0 ] ; then
265            echo "IGCM_sys_Mkdir : erreur."
266            IGCM_debug_Exit "IGCM_sys_Mkdir"
267        fi
268    fi
269    # vérification :
270    if [ ! -d ${1} ] ; then
271        echo "IGCM_sys_Mkdir : erreur."
272        IGCM_debug_Exit "IGCM_sys_Mkdir"
273    fi
274    IGCM_debug_PopStack "IGCM_sys_Mkdir"
275}
276
277#D-#==================================================
278#D-function IGCM_sys_MkdirArchive
279#D-* Purpose: Mkdir on Archive
280#D-* Examples:
281#D-
282function IGCM_sys_MkdirArchive {
283    IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
284    if ( $DEBUG_sys ) ; then
285        echo "IGCM_sys_MkdirArchive :" $@
286    fi
287    #- creation de repertoire sur le serveur fichier
288    if [ ! -d ${1} ]; then 
289        \mkdir -p $1
290        if [ $? -gt 0 ] ; then
291            echo "IGCM_sys_MkdirArchive : erreur."
292            IGCM_debug_Exit "IGCM_sys_MkdirArchive"
293        fi
294    fi
295#    vérification ?? :
296#    if [ ! -d ${1} ] ; then
297#       echo "IGCM_sys_MkdirArchive : erreur."
298#       IGCM_debug_Exit "IGCM_sys_MkdirArchive"
299#    fi
300    IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
301}
302
303#D-#==================================================
304#D-function IGCM_sys_MkdirWork
305#D-* Purpose: Mkdir on Work
306#D-* Examples:
307#D-
308function IGCM_sys_MkdirWork {
309    IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
310    if ( $DEBUG_sys ) ; then
311        echo "IGCM_sys_MkdirWork :" $@
312    fi
313    #- creation de repertoire sur le serveur fichier
314    if [ ! -d ${1} ]; then 
315        \mkdir -p $1
316        if [ $? -gt 0 ] ; then
317            echo "IGCM_sys_MkdirWork : erreur."
318            IGCM_debug_Exit "IGCM_sys_MkdirWork"
319        fi
320    fi
321    # vérification ?? :
322    if [ ! -d ${1} ] ; then
323        echo "IGCM_sys_MkdirWork : erreur."
324        IGCM_debug_Exit "IGCM_sys_MkdirWork"
325    fi
326    IGCM_debug_PopStack "IGCM_sys_MkdirWork"
327}
328#IGCM_sys_MkdirWork ${RUN_DIR_PATH}
329#echo "RUN_DIR_PATH ${RUN_DIR_PATH} ok."
330
331#D-#==================================================
332#D-function IGCM_sys_Cd
333#D-* Purpose: master cd command
334#D-* Examples:
335#D-
336function IGCM_sys_Cd {
337    IGCM_debug_PushStack "IGCM_sys_Cd" $@
338    if ( $DEBUG_sys ) ; then
339        echo "IGCM_sys_Cd :" $@
340    fi
341    \cd $1
342    if [ $? -gt 0 ] ; then
343        echo "IGCM_sys_Cd : erreur."
344        IGCM_debug_Exit "IGCM_sys_Cd"
345    fi
346    IGCM_debug_PopStack "IGCM_sys_Cd"
347}
348
349#D-#==================================================
350#D-function IGCM_sys_Chmod
351#D-* Purpose: Chmod
352#D-* Examples:
353#D-
354function IGCM_sys_Chmod {
355    IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
356    if ( $DEBUG_sys ) ; then
357        echo "IGCM_sys_Chmod :" $@
358    fi
359    if [ $DRYRUN -le 1 ]; then
360        \chmod $@
361        if [ $? -gt 0 ] ; then
362            echo "IGCM_sys_Chmod : erreur."
363            IGCM_debug_Exit "IGCM_sys_Chmod"
364        fi
365    else
366        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
367    fi
368    IGCM_debug_PopStack "IGCM_sys_Chmod"
369}
370
371#D-#==================================================
372#D-function IGCM_sys_FileSize
373#D-* Purpose: Filesize
374#D-* Examples:
375#D-
376function IGCM_sys_FileSize {
377    IGCM_debug_PushStack "IGCM_sys_FileSize" $@
378
379    typeset sizeF
380    set +A sizeF -- $( ls -la ${1} )
381    if [ $? -gt 0 ] ; then
382        IGCM_debug_Exit "IGCM_sys_FileSize"
383    fi
384    eval ${2}=${sizeF[4]}
385
386    IGCM_debug_PopStack "IGCM_sys_FileSize"
387}
388
389#D-#==================================================
390#D-function IGCM_sys_TestDir
391#D-* Purpose: Test Directory that must exists
392#D-* Examples:
393#D-
394function IGCM_sys_TestDir {
395    IGCM_debug_PushStack "IGCM_sys_TestDir" $@
396    if ( $DEBUG_sys ) ; then
397        echo "IGCM_sys_TestDir :" $@
398    fi
399    typeset ExistFlag
400    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
401    IGCM_debug_PopStack "IGCM_sys_TestDir"
402
403    return ${ExistFlag}
404}
405
406#D-#==================================================
407#D-function IGCM_sys_TestDirArchive
408#D-* Purpose: Test Directory that must exists on Archive
409#D-* Examples:
410#D-
411function IGCM_sys_TestDirArchive {
412    IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
413    if ( $DEBUG_sys ) ; then
414        echo "IGCM_sys_TestDirArchive :" $@
415    fi
416    typeset ExistFlag
417    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
418    IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
419
420    return ${ExistFlag}
421}
422
423#D-#==================================================
424#D-function IGCM_sys_TestFileArchive
425#D-* Purpose: Test file that must NOT EXISTS on Archive
426#D-* Examples:
427#D-
428function IGCM_sys_TestFileArchive {
429    IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
430    typeset ExistFlag
431    ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
432    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
433
434    return ${ExistFlag}
435}
436
437#D-#==================================================
438#D-function IGCM_sys_CountFileArchive
439#D-* Purpose: Count files on Archive filesystem
440#D-* Examples:
441#D-
442function IGCM_sys_CountFileArchive {
443    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
444    ls ${@} 2>/dev/null | wc -l
445    if [ $? -gt 0 ] ; then
446        echo "IGCM_sys_CountFileArchive : erreur."
447    fi
448    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
449}
450
451#D-#==================================================
452#D-function IGCM_sys_Tree
453#D-* Purpose: Tree directories with files on ${ARCHIVE}
454#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
455#D-
456function IGCM_sys_Tree {
457    IGCM_debug_PushStack "IGCM_sys_Tree" $@
458    if ( $DEBUG_sys ) ; then
459        echo "IGCM_sys_Tree :" $@
460    fi
461
462    \tree -f $@
463
464    IGCM_debug_PopStack "IGCM_sys_Tree"
465}
466
467#D-#==================================================
468#D-function IGCM_sys_Tar
469#D-* Purpose: master un-tar command
470#D-* Examples:
471#D-
472function IGCM_sys_Tar {
473    IGCM_debug_PushStack "IGCM_sys_Tar" $@
474    if ( $DEBUG_sys ) ; then
475        echo "IGCM_sys_Tar :" $@
476    fi
477    \tar cvf $@
478    if [ $? -gt 0 ] ; then
479        echo "IGCM_sys_Tar : erreur."
480        IGCM_debug_Exit "IGCM_sys_Tar"
481    fi
482    \tar tvf $1
483
484    IGCM_debug_PopStack "IGCM_sys_Tar"
485}
486
487#D-#==================================================
488#D-function IGCM_sys_UnTar
489#D-* Purpose: master un-tar command
490#D-* Examples:
491#D-
492function IGCM_sys_UnTar {
493    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
494    if ( $DEBUG_sys ) ; then
495        echo "IGCM_sys_UnTar :" $@
496    fi
497    \tar xvf $1
498    if [ $? -gt 0 ] ; then
499        echo "IGCM_sys_UnTar : erreur."
500        IGCM_debug_Exit "IGCM_sys_UnTar"
501    fi
502    IGCM_debug_PopStack "IGCM_sys_UnTar"
503}
504
505#D-#==================================================
506#D-function IGCM_sys_Qsub
507#D-* Purpose: Qsub new job
508#D-* Examples:
509#D-
510function IGCM_sys_Qsub {
511    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
512    if ( $DEBUG_sys ) ; then
513        echo "IGCM_sys_Qsub :" $@
514    fi
515    bsub -o ${Script_Output} -J ${config_UserChoices_JobName}.${CumulPeriod} < $1
516    if [ $? -gt 0 ] ; then
517        echo "IGCM_sys_Qsub : erreur " $@
518        IGCM_debug_Exit "IGCM_sys_Qsub"
519    fi
520    IGCM_debug_PopStack "IGCM_sys_Qsub"
521}
522
523#D-#==================================================
524#D-function IGCM_sys_QsubPost
525#D-* Purpose: Qsub new job on scalaire
526#D-* Examples:
527#D-
528function IGCM_sys_QsubPost {
529    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
530    if ( $DEBUG_sys ) ; then
531        echo "IGCM_sys_QsubPost :" $@
532    fi
533    bsub -o ${POST_DIR}/$1.${PeriodDateEnd}.out < ${libIGCM_POST}/$1.job
534    if [ $? -gt 0 ] ; then
535        echo "IGCM_sys_QsubPost : erreur " $@
536        IGCM_debug_Exit "IGCM_sys_QsubPost"
537    fi
538    IGCM_debug_PopStack "IGCM_sys_QsubPost"
539}
540
541#D-*************************
542#D- File transfer functions
543#D-*************************
544#D-
545
546#D-#==================================================
547#D-function IGCM_sys_Rsync_out
548#D-* Purpose: treat return val of rsync
549#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
550#D-  Error values and explanations can depend on your system version.
551function IGCM_sys_Rsync_out {
552    RET=$1
553    if [ ! $RET ] ; then
554        echo "rsync error !"
555    fi
556
557    if [ $MYLANG = "fr" ]; then
558        case $RET in
559            0)  return ;;
560            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
561                echo "Erreur de syntaxe ou d'utilisation."
562                return;;
563            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
564                echo "Incompatibilité de protocole."
565                return;;
566            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
567                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
568                echo "répertoires"
569                return;;
570            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
571                echo "Action demandée non supportée : une tentative de manipulation de"
572                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
573                echo "été faite ; ou une option qui est supportée par le  client  mais"
574                echo "pas par le serveur a été spécifiée."
575                return;;
576            10) echo "Erreur de rsync ; RERR_SOCKETIO"
577                echo "Erreur dans le socket d'entrée sortie"
578                return;;
579            11) echo "Erreur de rsync ; RERR_FILEIO"
580                echo "Erreur d'entrée sortie fichier"
581                return;;
582            12) echo "Erreur de rsync ; RERR_STREAMIO"
583                echo "Erreur dans flux de donnée du protocole rsync"
584                return;;
585            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
586                echo "Erreur avec les diagnostics du programme"
587                return;;
588            14) echo "Erreur de rsync ; RERR_IPC"
589                echo "Erreur dans le code IPC"
590                return;;
591            20) echo "Erreur de rsync ; RERR_SIGNAL"
592                echo "SIGUSR1 ou SIGINT reçu"
593                return;;
594            21) echo "Erreur de rsync ; RERR_WAITCHILD"
595                echo "Une erreur retournée par waitpid()"
596                return;;
597            22) echo "Erreur de rsync ; RERR_MALLOC"
598                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
599                return;;
600            23) echo ""
601                echo "Erreur fichier inexistant"
602                return;;
603            30) echo "Erreur de rsync ; RERR_TIMEOUT"
604                echo "Temps d'attente écoulé dans l'envoi/réception de données"
605                return;;
606            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
607                return;;
608        esac
609    elif [ $MYLANG = "en" ] ; then
610        case $RET in
611            0)  return;;               
612            1)  echo "rsync error : Syntax or usage error "
613                return;;
614            2)  echo "rsync error : Protocol incompatibility "
615                return;;
616            3)  echo "rsync error : Errors selecting input/output files, dirs"
617                return;;
618            4)  echo "rsync error : Requested action not supported: an attempt"
619                echo "was made to manipulate 64-bit files on a platform that cannot support"
620                echo "them; or an option was specified that is supported by the client and"
621                echo "not by the server."
622                return;;
623            5)  echo "rsync error : Error starting client-server protocol"
624                return;;
625            10) echo "rsync error : Error in socket I/O "
626                return;;
627            11) echo "rsync error : Error in file I/O "
628                return;;
629            12) echo "rsync error : Error in rsync protocol data stream "
630                return;;
631            13) echo "rsync error : Errors with program diagnostics "
632                return;;
633            14) echo "rsync error : Error in IPC code "
634                return;;
635            20) echo "rsync error : Received SIGUSR1 or SIGINT "
636                return;;
637            21) echo "rsync error : Some error returned by waitpid() "
638                return;;
639            22) echo "rsync error : Error allocating core memory buffers "
640                return;;
641            23) echo "rsync error : Partial transfer due to error"
642                return;;
643            24) echo "rsync error : Partial transfer due to vanished source files"
644                return;;
645            30) echo "rsync error : Timeout in data send/receive "
646                return;;
647            *)  echo "rsync error : return code of rsync unknown :" $RET
648                return;;
649        esac
650    else
651        echo "unknown language $MYLANG."
652        return
653    fi
654}
655   
656#D-#==================================================
657#D-function IGCM_sys_Cp
658#D-* Purpose: generic cp
659#D-* Examples:
660#D-
661function IGCM_sys_Cp {
662    IGCM_debug_PushStack "IGCM_sys_Cp" $@
663    if ( $DEBUG_sys ) ; then
664        echo "IGCM_sys_Cp :" $@
665    fi
666
667    typeset RET
668
669    echo cp $@ > out_rsync 2>&1
670    \cp $@ >> out_rsync 2>&1
671    RET=$?
672
673    if [ ${RET} -gt 0 ] ; then
674        echo "IGCM_sys_Cp : error."
675        cat out_rsync
676        IGCM_debug_Exit "IGCM_sys_Cp"
677    fi
678    IGCM_debug_PopStack "IGCM_sys_Cp"
679}
680
681#D-#==================================================
682#D-function IGCM_sys_Rm
683#D-* Purpose: generic rm
684#D-* Examples:
685#D-
686function IGCM_sys_Rm {
687    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
688    if ( $DEBUG_sys ) ; then
689        echo "IGCM_sys_Rm :" $@
690    fi
691
692    typeset RET
693
694    echo rm $@ > out_rsync 2>&1
695    \rm $@ >> out_rsync 2>&1
696    RET=$?
697
698    if [ ${RET} -gt 0 ] ; then
699        echo "IGCM_sys_Rm : error."
700        cat out_rsync
701        IGCM_debug_Exit "IGCM_sys_Rm"
702    fi
703    IGCM_debug_PopStack "IGCM_sys_Rm"
704}
705
706#D-#==================================================
707#D-function IGCM_sys_Rm
708#D-* Purpose: generic rm
709#D-* Examples:
710#D-
711function IGCM_sys_Rm {
712    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
713    if ( $DEBUG_sys ) ; then
714        echo "IGCM_sys_Rm :" $@
715    fi
716
717    typeset RET
718
719    echo rm $@ > out_rsync 2>&1
720    \rm $@ >> out_rsync 2>&1
721    RET=$?
722   
723    if [ ${RET} -gt 0 ] ; then
724        echo "IGCM_sys_Rm : error."
725        cat out_rsync
726        IGCM_debug_Exit "IGCM_sys_Rm"
727    fi
728    IGCM_debug_PopStack "IGCM_sys_Rm"
729}
730
731#D-#==================================================
732#D-function IGCM_sys_Mv
733#D-* Purpose: generic move
734#D-* Examples:
735#D-
736function IGCM_sys_Mv {
737    IGCM_debug_PushStack "IGCM_sys_Mv" $@
738    if ( $DEBUG_sys ) ; then
739        echo "IGCM_sys_Mv :" $@
740    fi
741
742    if [ $DRYRUN = 0 ]; then
743
744        typeset RET
745           
746        echo mv $@ > out_rsync 2>&1
747        \mv $@ >> out_rsync 2>&1
748        RET=$?
749   
750        if [ ${RET} -gt 0 ] ; then
751            echo "IGCM_sys_Mv : error in mv."
752            cat out_rsync
753            IGCM_debug_Exit "IGCM_sys_Mv"
754        fi
755    else
756        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
757    fi
758
759    IGCM_debug_PopStack "IGCM_sys_Mv"
760}
761
762#D-#==================================================
763#D-function IGCM_sys_Put_Rest
764#D-* Purpose: Put computied restarts on $(ARCHIVE).
765#D-           File and target directory must exist.
766#D-* Examples:
767#D-
768function IGCM_sys_Put_Rest {
769    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
770    if ( $DEBUG_sys ) ; then
771        echo "IGCM_sys_Put_Rest :" $@
772    fi
773    if [ $DRYRUN = 0 ]; then
774        if [ ! -f ${1} ] ; then
775            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
776            IGCM_debug_Exit "IGCM_sys_Put_Rest"
777        fi
778
779        typeset RET
780        #
781        if [ X${JobType} = XRUN ] ; then
782            IGCM_sys_Chmod 444 ${1}
783        fi
784        #
785        IGCM_sys_TestDirArchive $( dirname $2 )
786        #
787        # USUAL WAY
788        putfer $1 $2 > out_rsync 2>&1
789        RET=$?
790
791#       #RSYNC WITH NETWORK RSH CALL
792#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
793#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
794
795#       #RSYNC WITH NFS USE
796#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
797#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
798
799#       RET=$?
800#       IGCM_sys_Rsync_out $RET
801
802#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
803#       (( RET=RET+$? ))
804
805        if [ ${RET} -gt 0 ] ; then
806            echo "IGCM_sys_Put_Rest : error."
807            cat out_rsync
808            IGCM_debug_Exit "IGCM_sys_Put_Rest"
809        fi
810    else
811        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
812    fi
813    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
814}
815#D-#==================================================
816#D-function IGCM_sys_Put_Dir
817#D-* Purpose: Copy a complete directory on $(ARCHIVE)
818#D-* Examples:
819#D-
820function IGCM_sys_Put_Dir {
821    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
822    if ( $DEBUG_sys ) ; then
823        echo "IGCM_sys_Put_Dir :" $@
824    fi
825    if [ $DRYRUN = 0 ]; then
826        if [ ! -d ${1} ] ; then
827            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
828            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
829            return
830        fi
831
832        typeset RET
833
834        # Only if we use rsync
835        #IGCM_sys_TestDirArchive $( dirname $2 )
836        #
837        #USUAL WAY
838        \cp -r $1 $2 > out_rsync 2>&1
839        RET=$?
840
841        if [ ${RET} -gt 0 ] ; then
842            echo "IGCM_sys_Put_Dir : error."
843            cat out_rsync
844            IGCM_debug_Exit "IGCM_sys_Put_Dir"
845        fi
846    else
847        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
848    fi
849    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
850}
851
852#D-#==================================================
853#D-function IGCM_sys_Get_Dir
854#D-* Purpose: Copy a complete directory from $(ARCHIVE)
855#D-* Examples:
856#D-
857function IGCM_sys_Get_Dir {
858    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
859    if ( $DEBUG_sys ) ; then
860        echo "IGCM_sys_Get_Dir :" $@
861    fi
862    if [ $DRYRUN = 0 ]; then
863        if [ ! -d ${1} ] ; then
864            echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
865            IGCM_debug_PopStack "IGCM_sys_Get_Dir"
866            return
867        fi
868
869        typeset RET
870
871        # Only if we use rsync
872        #IGCM_sys_TestDirArchive $( dirname $2 )
873        #
874        #USUAL WAY
875        \cp -r $1 $2 > out_rsync 2>&1
876        RET=$?
877
878        if [ ${RET} -gt 0 ] ; then
879            echo "IGCM_sys_Get_Dir : error."
880            cat out_rsync
881            IGCM_debug_Exit "IGCM_sys_Get_Dir"
882        fi
883    else
884        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
885    fi
886    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
887}
888
889#D-#==================================================
890#D-function IGCM_sys_Get_Master
891#D-* Purpose: Copy a complete directory from MASTER filesystem
892#D-* Examples:
893#D-
894function IGCM_sys_Get_Master {
895    IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
896    if ( $DEBUG_sys ) ; then
897        echo "IGCM_sys_Get_Master :" $@
898    fi
899    if [ $DRYRUN = 0 ]; then
900        if [ ! -d ${1} ] ; then
901            echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
902            IGCM_debug_PopStack "IGCM_sys_Get_Master"
903            return
904        fi
905
906        typeset RET
907        sleep 60
908
909        #USUAL WAY
910        \cp -r $1 $2 > out_rsync 2>&1
911        RET=$?
912
913        if [ ${RET} -gt 0 ] ; then
914            echo "IGCM_sys_Get_Master : error."
915            cat out_rsync
916            IGCM_debug_Exit "IGCM_sys_Get_Master"
917        fi
918    else
919        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
920    fi
921    IGCM_debug_PopStack "IGCM_sys_Get_Master"
922}
923
924#D-#==================================================
925#D-function IGCM_sys_Put_Out
926#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
927#D-* Examples:
928#D-
929function IGCM_sys_Put_Out {
930    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
931    if ( $DEBUG_sys ) ; then
932        echo "IGCM_sys_Put_Out :" $@
933    fi
934    if [ $DRYRUN = 0 ]; then
935        if [ ! -f ${1} ] ; then
936            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
937            IGCM_debug_PopStack "IGCM_sys_Put_Out"
938            return 1
939        fi
940        #
941        IGCM_sys_MkdirArchive $( dirname $2 )
942        #
943        typeset RET
944        #
945        if [ X${JobType} = XRUN ] ; then
946            IGCM_sys_Chmod 444 ${1}
947        fi
948        #
949        # USUAL WAY
950        putfer $1 $2 > out_rsync 2>&1
951        RET=$?
952
953#       #RSYNC WITH NETWORK RSH CALL
954#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
955#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
956
957#       #RSYNC WITH NFS USE
958#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
959#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
960
961#       RET=$?
962#       IGCM_sys_Rsync_out $RET
963
964#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
965#       (( RET=RET+$? ))
966
967        if [ ${RET} -gt 0 ] ; then
968            echo "IGCM_sys_Put_Out : error."
969            cat out_rsync
970            IGCM_debug_Exit "IGCM_sys_Put_Out"
971        fi
972    else
973        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
974    fi
975    IGCM_debug_PopStack "IGCM_sys_Put_Out"
976    return 0
977}
978
979#D-#==================================================
980#D-function IGCM_sys_Get
981#D-* Purpose: Get a file from ${ARCHIVE}
982#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
983#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
984function IGCM_sys_Get {
985    IGCM_debug_PushStack "IGCM_sys_Get" $@
986
987    typeset DEST RET dm_liste ifile target file_work
988
989    if ( $DEBUG_sys ) ; then
990        echo "IGCM_sys_Get :" $@
991    fi
992    if [ $DRYRUN -le 2 ]; then
993        if [ X${1} = X'/l' ] ; then
994            # test if the first file is present in the old computation :
995            eval set +A dm_liste \${${2}}
996        else
997            eval set +A dm_liste ${1}
998        fi
999        eval DEST=\${${#}}
1000
1001        #=====================================================
1002        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1003        #=====================================================
1004
1005        # Is it an R_OUT file (not R_IN) ?
1006        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1007        #if [ $? -eq 0 ] ; then
1008        #    # Yes  ? then we try to get it in SCRATCHDIR
1009        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
1010        #    if [ -f ${file_work[0]} ] ; then
1011        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
1012        #       IGCM_debug_PopStack "IGCM_sys_Get"
1013        #       return
1014        #    fi
1015        #fi
1016
1017        # test if the (first) file is present in the old computation :
1018        IGCM_sys_TestFileArchive ${dm_liste[0]}
1019        RET=$?
1020        if [ ${RET} -gt 0 ] ; then
1021            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1022            IGCM_debug_Exit "IGCM_sys_Get"
1023            #IGCM_debug_PopStack "IGCM_sys_Get"
1024            #return
1025        fi
1026
1027        dmget ${dm_liste[*]} > out_rsync 2>&1
1028        RET=$?
1029        if [ ${RET} -gt 0 ] ; then
1030            echo "IGCM_sys_Get : demigration error."
1031            cat out_rsync
1032            IGCM_debug_Exit "IGCM_sys_Get"
1033            IGCM_debug_PopStack "IGCM_sys_Get"
1034            return
1035        fi
1036
1037        #USUAL WAY
1038        (( RET=0 ))
1039        if [ X${1} = X'/l' ] ; then
1040            (( RET=0 ))
1041            for target in ${dm_liste[*]} ; do
1042                local_file=$( basename ${target} )
1043                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1044                (( RET = RET + $? ))
1045            done
1046        else
1047            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1048            RET=$?
1049        fi
1050
1051#       #RSYNC WITH NETWORK RSH CALL
1052#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1053#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1054
1055#       #RSYNC WITH NFS USE
1056#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1057#       ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1058
1059#       RET=$?
1060#       IGCM_sys_Rsync_out $RET
1061
1062#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1063#       (( RET=RET+$? ))
1064
1065        if [ ${RET} -gt 0 ] ; then
1066            echo "IGCM_sys_Get : copy error."
1067            cat out_rsync
1068            IGCM_debug_Exit "IGCM_sys_Get"
1069        fi
1070    else
1071        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1072    fi
1073    IGCM_debug_PopStack "IGCM_sys_Get"
1074}
1075
1076#D-#==================================================
1077#D-function IGCM_sys_Put_Dods
1078#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1079#D-* Examples:
1080#D-
1081function IGCM_sys_Put_Dods {
1082    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1083    if ( $DEBUG_sys ) ; then
1084        echo "IGCM_sys_Put_Dods :" $@
1085    fi
1086    if [ $DRYRUN = 0 ]; then
1087        if [ ! -d ${R_SAVE}/${1} ] ; then
1088            echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
1089            IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1090            return
1091        fi
1092
1093        typeset RET
1094        #
1095        cd ${R_SAVE}
1096        dods_rm public/${LOGIN}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/${1} > /dev/null 2>&1
1097        #/bin/chmod -R u+w  ${R_SAVE}/${1}
1098        dods_cp ${1} public/${LOGIN}/${config_UserChoices_TagName}/${config_UserChoices_JobName} > /dev/null 2>&1
1099        #/bin/chmod -R +rX ${R_SAVE}/${1}
1100        #/bin/chmod -R a+rX /dmnfs/cont003/dods/public/${LOGIN}/${config_UserChoices_TagName}
1101        #RET=$?
1102        RET=0
1103
1104        if [ ${RET} -gt 0 ] ; then
1105            echo "IGCM_sys_Put_Dods : error."
1106            IGCM_debug_Exit "IGCM_sys_Put_Dods"
1107        fi
1108    else
1109        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1110    fi
1111    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1112}
1113
1114#D-#==================================================
1115#D-function IGCM_sys_Rapatrie
1116#D-* Purpose: Rapatrie
1117#D-* Examples:
1118#D-
1119function IGCM_sys_Rapatrie {
1120    IGCM_debug_PushStack "IGCM_sys_Rapatrie" $@
1121    if ( $DEBUG_sys ) ; then
1122        echo "IGCM_sys_Rapatrie :" $@
1123    fi
1124
1125    typeset RET=0
1126
1127    IGCM_sys_Get ${R_STOCKAGE}/$2 $1 ;
1128    let $(( RET=RET+$? ))
1129    IGCM_sys_Cd $1 ;
1130    let $(( RET=RET+$? ))
1131    IGCM_sys_UnTar $2 ;
1132    let $(( RET=RET+$? ))
1133
1134    if [ ${RET} -gt 0 ] ; then
1135        echo "IGCM_sys_Rapatrie : erreur."
1136        IGCM_debug_Exit "IGCM_sys_Rapatrie"
1137    fi
1138    IGCM_debug_PopStack "IGCM_sys_Rapatrie"
1139}
1140
1141############################################################## A FINIR !!
1142
1143#D-#==================================================
1144#D-function IGCM_sys_GetDate_FichWork
1145#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1146#D-* Examples:
1147#D-
1148function IGCM_sys_GetDate_FichWork {
1149    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1150    if ( $DEBUG_sys ) ; then
1151        echo "IGCM_sys_GetDate_FichWork :" $@
1152    fi
1153    # donne la date filesys d'un fichier sur la machine work
1154    IGCM_debug_PopStack "IGCM_sys_FichWork"
1155}
1156
1157#D-#==================================================
1158#D-function IGCM_sys_GetDate_FichArchive
1159#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1160#D-* Examples:
1161#D-
1162function IGCM_sys_GetDate_FichArchive {
1163    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1164    if ( $DEBUG_sys ) ; then
1165        echo "IGCM_sys_GetDate_FichArchive :" $@
1166    fi
1167    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1168}
1169
1170##############################################################
1171# NCO OPERATOR
1172
1173function IGCM_sys_ncap {
1174    IGCM_debug_PushStack "IGCM_sys_ncap" -- $@
1175    if ( $DEBUG_sys ) ; then
1176        echo "IGCM_sys_ncap :" $@
1177    fi
1178    /applications/nco/bin/ncap $@
1179    if [ $? -gt 0 ] ; then
1180       echo "IGCM_sys_ncap : erreur ${@}."
1181#       IGCM_debug_Exit "ncap"
1182    fi
1183
1184    IGCM_debug_PopStack "IGCM_sys_ncap"
1185}
1186
1187ncatted=/applications/nco/bin/ncatted
1188# Problem with ksh and string passed in this function to ncatted !
1189# function IGCM_sys_ncatted {
1190#     IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1191#     if ( $DEBUG_sys ) ; then
1192#       echo "IGCM_sys_ncatted :" $@
1193#     fi
1194#     /usr/local/bin/ncatted $@
1195#     if [ $? -gt 0 ] ; then
1196#        echo "IGCM_sys_ncatted : erreur ${@}."
1197#        IGCM_debug_Exit "ncatted"
1198#     fi
1199
1200#     IGCM_debug_PopStack "IGCM_sys_ncatted"
1201# }
1202
1203function IGCM_sys_ncbo {
1204    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1205    if ( $DEBUG_sys ) ; then
1206        echo "IGCM_sys_ncbo :" $@
1207    fi
1208    /applications/nco/bin/ncbo $@
1209    if [ $? -gt 0 ] ; then
1210       echo "IGCM_sys_ncbo : erreur ${@}."
1211#       IGCM_debug_Exit "ncbo"
1212    fi
1213
1214    IGCM_debug_PopStack "IGCM_sys_ncbo"
1215}
1216
1217function IGCM_sys_ncdiff {
1218    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1219    if ( $DEBUG_sys ) ; then
1220        echo "IGCM_sys_ncdiff :" $@
1221    fi
1222    /applications/nco/bin/ncdiff $@
1223    if [ $? -gt 0 ] ; then
1224       echo "IGCM_sys_ncdiff : erreur ${@}."
1225#       IGCM_debug_Exit "ncdiff"
1226    fi
1227
1228    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1229}
1230
1231function IGCM_sys_ncea {
1232    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1233    if ( $DEBUG_sys ) ; then
1234        echo "IGCM_sys_ncea :" $@
1235    fi
1236    /applications/nco/bin/ncea $@
1237    if [ $? -gt 0 ] ; then
1238       echo "IGCM_sys_ncea : erreur ${@}."
1239#       IGCM_debug_Exit "ncea"
1240    fi
1241
1242    IGCM_debug_PopStack "IGCM_sys_ncea"
1243}
1244
1245function IGCM_sys_ncecat {
1246    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1247    if ( $DEBUG_sys ) ; then
1248        echo "IGCM_sys_ncecat :" $@
1249    fi
1250    /applications/nco/bin/ncecat $@
1251    if [ $? -gt 0 ] ; then
1252       echo "IGCM_sys_ncecat : erreur ${@}."
1253#       IGCM_debug_Exit "ncecat"
1254    fi
1255
1256    IGCM_debug_PopStack "IGCM_sys_ncecat"
1257}
1258
1259function IGCM_sys_ncflint {
1260    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1261    if ( $DEBUG_sys ) ; then
1262        echo "IGCM_sys_ncflint :" $@
1263    fi
1264    /usr/local/bin/ncflint $@
1265    if [ $? -gt 0 ] ; then
1266       echo "IGCM_sys_ncflint : erreur ${@}."
1267#       IGCM_debug_Exit "ncflint"
1268    fi
1269
1270    IGCM_debug_PopStack "IGCM_sys_ncflint"
1271}
1272
1273function IGCM_sys_ncks {
1274    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1275    if ( $DEBUG_sys ) ; then
1276        echo "IGCM_sys_ncks :" $@
1277    fi
1278    /applications/nco/bin/ncks $@
1279    if [ $? -gt 0 ] ; then
1280       echo "IGCM_sys_ncks : erreur ${@}."
1281#       IGCM_debug_Exit "ncks"
1282    fi
1283
1284    IGCM_debug_PopStack "IGCM_sys_ncks"
1285}
1286
1287function IGCM_sys_ncpdq {
1288    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1289    if ( $DEBUG_sys ) ; then
1290        echo "IGCM_sys_ncpdq :" $@
1291    fi
1292    /applications/nco/bin/ncpdq $@
1293    if [ $? -gt 0 ] ; then
1294       echo "IGCM_sys_ncpdq : erreur ${@}."
1295#       IGCM_debug_Exit "ncpdq"
1296    fi
1297
1298    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1299}
1300
1301function IGCM_sys_ncra {
1302    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1303    if ( $DEBUG_sys ) ; then
1304        echo "IGCM_sys_ncra :" $@
1305    fi
1306    /applications/nco/bin/ncra $@
1307    if [ $? -gt 0 ] ; then
1308       echo "IGCM_sys_ncra : erreur ${@}."
1309#       IGCM_debug_Exit "ncra"
1310    fi
1311
1312    IGCM_debug_PopStack "IGCM_sys_ncra"
1313}
1314
1315function IGCM_sys_ncrcat {
1316    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1317    if ( $DEBUG_sys ) ; then
1318        echo "IGCM_sys_ncrcat :" $@
1319    fi
1320    /applications/nco/bin/ncrcat $@
1321    if [ $? -gt 0 ] ; then
1322       echo "IGCM_sys_ncrcat : erreur ${@}."
1323#       IGCM_debug_Exit "ncrcat"
1324    fi
1325
1326    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1327}
1328
1329function IGCM_sys_ncrename {
1330    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1331    if ( $DEBUG_sys ) ; then
1332        echo "IGCM_sys_ncrename :" $@
1333    fi
1334    /applications/nco/bin/ncrename $@
1335    if [ $? -gt 0 ] ; then
1336       echo "IGCM_sys_ncrename : erreur ${@}."
1337#       IGCM_debug_Exit "ncrename"
1338    fi
1339
1340    IGCM_debug_PopStack "IGCM_sys_ncrename"
1341}
1342
1343function IGCM_sys_ncwa {
1344    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1345    if ( $DEBUG_sys ) ; then
1346        echo "IGCM_sys_ncwa :" $@
1347    fi
1348    /applications/nco/bin/ncwa $@
1349    if [ $? -gt 0 ] ; then
1350       echo "IGCM_sys_ncwa : erreur ${@}."
1351#       IGCM_debug_Exit "ncwa"
1352    fi
1353
1354    IGCM_debug_PopStack "IGCM_sys_ncwa"
1355}
1356
1357##############################################################
1358# REBUILD OPERATOR
1359
1360function IGCM_sys_rebuild {
1361    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1362    if ( $DEBUG_sys ) ; then
1363        echo "IGCM_sys_rebuild :" $@
1364    fi
1365    /home/cont003/p86ipsl/IA64/bin/rebuild -f -o $@
1366    if [ $? -gt 0 ] ; then
1367       echo "IGCM_sys_rebuild : erreur ${@}."
1368       IGCM_debug_Exit "rebuild"
1369    fi
1370
1371    IGCM_debug_PopStack "IGCM_sys_rebuild"
1372}
1373
1374############################################################
1375# Activate Running Environnment Variables
1376
1377function IGCM_sys_activ_variables {
1378    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1379    if ( $DEBUG_sys ) ; then
1380        echo "IGCM_sys_activ_variables"
1381    fi
1382    ulimit -s 2097152
1383    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1384}
1385
1386############################################################
1387# Desactivate Running Environnment Variables
1388
1389function IGCM_sys_desactiv_variables {
1390    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1391    if ( $DEBUG_sys ) ; then
1392        echo "IGCM_sys_desactiv_variables"
1393    fi
1394    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1395}
1396
1397############################################################
1398# Build run file
1399
1400function IGCM_sys_build_run_file {
1401    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1402    if ( $DEBUG_sys ) ; then
1403        echo "IGCM_sys_build_run_file " $@
1404    fi
1405    if [ $1 = MPI1 ]; then
1406        (( nb_tot_m1 = $BATCH_NUM_PROC_TOT  - 1 ))
1407        cat <<EOF > run_file
1408#!/bin/bash
1409if [ \$SLURM_PROCID -eq 0 ]
1410  then ./oasis ;
1411elif ( [ \$SLURM_PROCID -ge 1 ] && [ \$SLURM_PROCID -lt ${nb_tot_m1} ] )
1412  then ./lmdz.x ;
1413else ./opa.xx ;
1414fi
1415EOF
1416        config_UserChoices_JobRunOptions='"-n ${BATCH_NUM_PROC_TOT}"'
1417        IGCM_sys_Chmod u+x run_file
1418    fi
1419    (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - 2 ))
1420    (( NUM_PROC_OCE = 1 ))
1421
1422    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1423 
1424}
Note: See TracBrowser for help on using the repository browser.