source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh @ 451

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