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

Last change on this file since 455 was 455, checked in by sdipsl, 13 years ago
  • Continuation of [451]. Submit post-treatment from titane's mono class to cesium. Nasty hack waiting for a better solution
  • Cosmetic and verbosity
  • Property svn:keywords set to Revision Author Date
File size: 39.5 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    else
290        status=completed
291    fi
292
293    ssh -t titane996 ssh platine /bin/ksh <<-EOF
294    export LOGIN=${LOGIN}
295    export config_UserChoices_JobName=${config_UserChoices_JobName}
296    export config_UserChoices_MailName=${config_UserChoices_MailName}
297    export DateBegin=${DateBegin}
298    export DateEnd=${DateEnd}
299    export R_SAVE=${R_SAVE}
300    export SUBMIT_DIR=${SUBMIT_DIR}
301    export status=${status}
302
303    cat  << END_MAIL > job_end.mail
304Dear ${LOGIN},
305
306  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
307  Job started : ${DateBegin}
308  Job ended   : ${DateEnd}
309  Output files are available in ${R_SAVE}
310  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
311END_MAIL
312
313    if [ ! -z ${config_UserChoices_MailName} ] ; then
314        mailx -s "${config_UserChoices_JobName} completed" ${config_UserChoices_MailName} < job_end.mail
315    elif [ -f ~/.forward ] ; then
316        mailx -s "${config_UserChoices_JobName} completed" $( cat ~/.forward ) < job_end.mail
317    fi
318
319    sleep 10
320    rm -f job_end.mail
321EOF
322
323    if [ $? -gt 0 ] ; then
324        echo "IGCM_sys_SendMail : erreur."
325        IGCM_debug_Exit "IGCM_sys_SendMail"
326    fi
327    IGCM_debug_PopStack "IGCM_sys_SendMail"
328}
329
330#D-#==================================================
331#D-function IGCM_sys_Mkdir
332#D-* Purpose: Master locale mkdir command
333#D-* Examples:
334#D-
335function IGCM_sys_Mkdir {
336    IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
337    if ( $DEBUG_sys ) ; then
338        echo "IGCM_sys_Mkdir :" $@
339    fi
340    if [ ! -d ${1} ]; then
341        \mkdir -p $1
342        if [ $? -gt 0 ] ; then
343            echo "IGCM_sys_Mkdir : erreur."
344            IGCM_debug_Exit "IGCM_sys_Mkdir"
345        fi
346    fi
347    # vérification :
348    if [ ! -d ${1} ] ; then
349        echo "IGCM_sys_Mkdir : erreur."
350        IGCM_debug_Exit "IGCM_sys_Mkdir"
351    fi
352    IGCM_debug_PopStack "IGCM_sys_Mkdir"
353}
354
355#D-#==================================================
356#D-function IGCM_sys_MkdirArchive
357#D-* Purpose: Mkdir on Archive
358#D-* Examples:
359#D-
360function IGCM_sys_MkdirArchive {
361    IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
362    if ( $DEBUG_sys ) ; then
363        echo "IGCM_sys_MkdirArchive :" $@
364    fi
365    #- creation de repertoire sur le serveur fichier
366    if [ ! -d ${1} ]; then 
367        \mkdir -p $1
368        if [ $? -gt 0 ] ; then
369            echo "IGCM_sys_MkdirArchive : erreur."
370            IGCM_debug_Exit "IGCM_sys_MkdirArchive"
371        fi
372    fi
373    IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
374}
375
376#D-#==================================================
377#D-function IGCM_sys_MkdirWork
378#D-* Purpose: Mkdir on Work
379#D-* Examples:
380#D-
381function IGCM_sys_MkdirWork {
382    IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
383    if ( $DEBUG_sys ) ; then
384        echo "IGCM_sys_MkdirWork :" $@
385    fi
386    #- creation de repertoire sur le serveur fichier
387    if [ ! -d ${1} ]; then 
388        \mkdir -p $1
389        if [ $? -gt 0 ] ; then
390            echo "IGCM_sys_MkdirWork : erreur."
391            IGCM_debug_Exit "IGCM_sys_MkdirWork"
392        fi
393    fi
394    IGCM_debug_PopStack "IGCM_sys_MkdirWork"
395}
396
397#D-#==================================================
398#D-function IGCM_sys_Cd
399#D-* Purpose: master cd command
400#D-* Examples:
401#D-
402function IGCM_sys_Cd {
403    IGCM_debug_PushStack "IGCM_sys_Cd" $@
404    if ( $DEBUG_sys ) ; then
405        echo "IGCM_sys_Cd :" $@
406    fi
407    \cd $1
408    if [ $? -gt 0 ] ; then
409        echo "IGCM_sys_Cd : erreur."
410        IGCM_debug_Exit "IGCM_sys_Cd"
411    fi
412    IGCM_debug_PopStack "IGCM_sys_Cd"
413}
414
415#D-#==================================================
416#D-function IGCM_sys_Chmod
417#D-* Purpose: Chmod
418#D-* Examples:
419#D-
420function IGCM_sys_Chmod {
421    IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
422    if ( $DEBUG_sys ) ; then
423        echo "IGCM_sys_Chmod :" $@
424    fi
425    if [ $DRYRUN -le 1 ]; then
426        \chmod $@
427        if [ $? -gt 0 ] ; then
428            echo "IGCM_sys_Chmod : erreur."
429            IGCM_debug_Exit "IGCM_sys_Chmod"
430        fi
431    else
432        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
433    fi
434    IGCM_debug_PopStack "IGCM_sys_Chmod"
435}
436
437#D-#==================================================
438#D-function IGCM_sys_FileSize
439#D-* Purpose: Filesize
440#D-* Examples:
441#D-
442function IGCM_sys_FileSize {
443    IGCM_debug_PushStack "IGCM_sys_FileSize" $@
444
445    typeset sizeF
446    set +A sizeF -- $( ls -la ${1} )
447    if [ $? -gt 0 ] ; then
448        IGCM_debug_Exit "IGCM_sys_FileSize"
449    fi
450    eval ${2}=${sizeF[4]}
451
452    IGCM_debug_PopStack "IGCM_sys_FileSize"
453}
454
455#D-#==================================================
456#D-function IGCM_sys_TestDir
457#D-* Purpose: Test Directory that must exists
458#D-* Examples:
459#D-
460function IGCM_sys_TestDir {
461    IGCM_debug_PushStack "IGCM_sys_TestDir" $@
462    if ( $DEBUG_sys ) ; then
463        echo "IGCM_sys_TestDir :" $@
464    fi
465    typeset ExistFlag
466    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
467    IGCM_debug_PopStack "IGCM_sys_TestDir"
468
469    return ${ExistFlag}
470}
471
472#D-#==================================================
473#D-function IGCM_sys_TestDirArchive
474#D-* Purpose: Test Directory that must exists on Archive
475#D-* Examples:
476#D-
477function IGCM_sys_TestDirArchive {
478    IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
479    if ( $DEBUG_sys ) ; then
480        echo "IGCM_sys_TestDirArchive :" $@
481    fi
482    typeset ExistFlag
483    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
484    IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
485
486    return ${ExistFlag}
487}
488
489#D-#==================================================
490#D-function IGCM_sys_TestFileArchive
491#D-* Purpose: Test file that must NOT EXISTS on Archive
492#D-* Examples:
493#D-
494function IGCM_sys_TestFileArchive {
495    IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
496    typeset ExistFlag
497    ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
498    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
499
500    return ${ExistFlag}
501}
502
503#D-#==================================================
504#D-function IGCM_sys_CountFileArchive
505#D-* Purpose: Count files on Archive filesystem
506#D-* Examples:
507#D-
508function IGCM_sys_CountFileArchive {
509    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
510    ls ${@} 2>/dev/null | wc -l
511    if [ $? -gt 0 ] ; then
512        echo "IGCM_sys_CountFileArchive : erreur."
513    fi
514    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
515}
516
517#D-#==================================================
518#D-function IGCM_sys_Tree
519#D-* Purpose: Tree directories with files on ${ARCHIVE}
520#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
521#D-
522function IGCM_sys_Tree {
523    IGCM_debug_PushStack "IGCM_sys_Tree" $@
524    if ( $DEBUG_sys ) ; then
525        echo "IGCM_sys_Tree :" $@
526    fi
527
528    \ls -lR ${@}
529
530    IGCM_debug_PopStack "IGCM_sys_Tree"
531}
532
533#D-#==================================================
534#D-function IGCM_sys_Tar
535#D-* Purpose: master un-tar command
536#D-* Examples:
537#D-
538function IGCM_sys_Tar {
539    IGCM_debug_PushStack "IGCM_sys_Tar" $@
540    if ( $DEBUG_sys ) ; then
541        echo "IGCM_sys_Tar :" $@
542    fi
543    \tar xvf $1
544    if [ $? -gt 0 ] ; then
545        echo "IGCM_sys_Tar : erreur."
546        IGCM_debug_Exit "IGCM_sys_Tar"
547    fi
548    IGCM_debug_PopStack "IGCM_sys_Tar"
549}
550
551#D-#==================================================
552#D-function IGCM_sys_UnTar
553#D-* Purpose: master un-tar command
554#D-* Examples:
555#D-
556function IGCM_sys_UnTar {
557    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
558    if ( $DEBUG_sys ) ; then
559        echo "IGCM_sys_UnTar :" $@
560    fi
561    \tar xvf $1
562    if [ $? -gt 0 ] ; then
563        echo "IGCM_sys_UnTar : erreur."
564        IGCM_debug_Exit "IGCM_sys_UnTar"
565    fi
566    IGCM_debug_PopStack "IGCM_sys_UnTar"
567}
568
569#D-#==================================================
570#D-function IGCM_sys_Qsub
571#D-* Purpose: Qsub new job
572#D-* Examples:
573#D-
574function IGCM_sys_Qsub {
575    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
576    if ( $DEBUG_sys ) ; then
577        echo "IGCM_sys_Qsub :" $@
578    fi
579    /usr/local/bin/ccc_msub -o ${Script_Output} -e ${Script_Output} -r ${config_UserChoices_JobName}.${CumulPeriod} < $1
580    if [ $? -gt 0 ] ; then
581        echo "IGCM_sys_Qsub : erreur " $@
582        IGCM_debug_Exit "IGCM_sys_Qsub"
583    fi
584    IGCM_debug_PopStack "IGCM_sys_Qsub"
585}
586
587#D-#==================================================
588#D-function IGCM_sys_QsubPost
589#D-* Purpose: Qsub new job on scalaire
590#D-* Examples:
591#D-
592function IGCM_sys_QsubPost {
593    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
594    if ( $DEBUG_sys ) ; then
595        echo "IGCM_sys_QsubPost :" $@
596    fi
597    /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
598    if [ $? -gt 0 ] ; then
599        echo "IGCM_sys_QsubPost : erreur " $@
600        IGCM_debug_Exit "IGCM_sys_QsubPost"
601    fi
602    IGCM_debug_PopStack "IGCM_sys_QsubPost"
603}
604
605#D-*************************
606#D- File transfer functions
607#D-*************************
608#D-
609
610#D-#==================================================
611#D-function IGCM_sys_Rsync_out
612#D-* Purpose: treat return val of rsync
613#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
614#D-  Error values and explanations can depend on your system version.
615function IGCM_sys_Rsync_out {
616    RET=$1
617    if [ ! $RET ] ; then
618        echo "rsync error !"
619    fi
620
621    if [ $MYLANG = "fr" ]; then
622        case $RET in
623            0)  return ;;
624            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
625                echo "Erreur de syntaxe ou d'utilisation."
626                return;;
627            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
628                echo "Incompatibilité de protocole."
629                return;;
630            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
631                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
632                echo "répertoires"
633                return;;
634            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
635                echo "Action demandée non supportée : une tentative de manipulation de"
636                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
637                echo "été faite ; ou une option qui est supportée par le  client  mais"
638                echo "pas par le serveur a été spécifiée."
639                return;;
640            10) echo "Erreur de rsync ; RERR_SOCKETIO"
641                echo "Erreur dans le socket d'entrée sortie"
642                return;;
643            11) echo "Erreur de rsync ; RERR_FILEIO"
644                echo "Erreur d'entrée sortie fichier"
645                return;;
646            12) echo "Erreur de rsync ; RERR_STREAMIO"
647                echo "Erreur dans flux de donnée du protocole rsync"
648                return;;
649            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
650                echo "Erreur avec les diagnostics du programme"
651                return;;
652            14) echo "Erreur de rsync ; RERR_IPC"
653                echo "Erreur dans le code IPC"
654                return;;
655            20) echo "Erreur de rsync ; RERR_SIGNAL"
656                echo "SIGUSR1 ou SIGINT reçu"
657                return;;
658            21) echo "Erreur de rsync ; RERR_WAITCHILD"
659                echo "Une erreur retournée par waitpid()"
660                return;;
661            22) echo "Erreur de rsync ; RERR_MALLOC"
662                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
663                return;;
664            23) echo ""
665                echo "Erreur fichier inexistant"
666                return;;
667            30) echo "Erreur de rsync ; RERR_TIMEOUT"
668                echo "Temps d'attente écoulé dans l'envoi/réception de données"
669                return;;
670            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
671                return;;
672        esac
673    elif [ $MYLANG = "en" ] ; then
674        case $RET in
675            0)  return;;               
676            1)  echo "rsync error : Syntax or usage error "
677                return;;
678            2)  echo "rsync error : Protocol incompatibility "
679                return;;
680            3)  echo "rsync error : Errors selecting input/output files, dirs"
681                return;;
682            4)  echo "rsync error : Requested action not supported: an attempt"
683                echo "was made to manipulate 64-bit files on a platform that cannot support"
684                echo "them; or an option was specified that is supported by the client and"
685                echo "not by the server."
686                return;;
687            5)  echo "rsync error : Error starting client-server protocol"
688                return;;
689            10) echo "rsync error : Error in socket I/O "
690                return;;
691            11) echo "rsync error : Error in file I/O "
692                return;;
693            12) echo "rsync error : Error in rsync protocol data stream "
694                return;;
695            13) echo "rsync error : Errors with program diagnostics "
696                return;;
697            14) echo "rsync error : Error in IPC code "
698                return;;
699            20) echo "rsync error : Received SIGUSR1 or SIGINT "
700                return;;
701            21) echo "rsync error : Some error returned by waitpid() "
702                return;;
703            22) echo "rsync error : Error allocating core memory buffers "
704                return;;
705            23) echo "rsync error : Partial transfer due to error"
706                return;;
707            24) echo "rsync error : Partial transfer due to vanished source files"
708                return;;
709            30) echo "rsync error : Timeout in data send/receive "
710                return;;
711            *)  echo "rsync error : return code of rsync unknown :" $RET
712                return;;
713        esac
714    else
715        echo "unknown language $MYLANG."
716        return
717    fi
718}
719   
720
721#D-#==================================================
722#D-function IGCM_sys_Miror_libIGCM
723#D-* Purpose: Mirror libIGCM PATH and lib to cesium
724#D-* Examples:
725#D-
726function IGCM_sys_Mirror_libIGCM {
727    IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
728    if ( $DEBUG_sys ) ; then
729        echo "IGCM_sys_Mirror_libIGCM"
730    fi
731
732    typeset RET DEST
733
734    mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
735
736    echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
737    ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
738    RET=$?
739
740    if [ ${RET} -gt 0 ] ; then
741        echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium."
742        cat out_rsync
743    fi
744    IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
745}
746
747#====================================================
748#- Call IGCM_sys_Mirror_libIGCM now !
749if ( $MirrorlibIGCM ) ; then
750    IGCM_sys_Mirror_libIGCM
751fi
752
753#D-#==================================================
754#D-function IGCM_sys_Cp
755#D-* Purpose: generic cp
756#D-* Examples:
757#D-
758function IGCM_sys_Cp {
759    IGCM_debug_PushStack "IGCM_sys_Cp" $@
760    if ( $DEBUG_sys ) ; then
761        echo "IGCM_sys_Cp :" $@
762    fi
763
764    typeset RET
765
766    echo cp $@ > out_rsync 2>&1
767    \cp $@ >> out_rsync 2>&1
768    RET=$?
769
770    if [ ${RET} -gt 0 ] ; then
771        echo "IGCM_sys_Cp : error."
772        cat out_rsync
773        IGCM_debug_Exit "IGCM_sys_Cp"
774     else
775         \rm out_rsync
776    fi
777    IGCM_debug_PopStack "IGCM_sys_Cp"
778}
779
780#D-#==================================================
781#D-function IGCM_sys_Rm
782#D-* Purpose: generic rm
783#D-* Examples:
784#D-
785function IGCM_sys_Rm {
786    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
787    if ( $DEBUG_sys ) ; then
788        echo "IGCM_sys_Rm :" $@
789    fi
790
791    typeset RET
792
793    echo rm $@ > out_rsync 2>&1
794    \rm $@ >> out_rsync 2>&1
795    RET=$?
796
797    if [ ${RET} -gt 0 ] ; then
798        echo "IGCM_sys_Rm : error."
799        cat out_rsync
800        IGCM_debug_Exit "IGCM_sys_Rm"
801    else
802        \rm out_rsync
803    fi
804    IGCM_debug_PopStack "IGCM_sys_Rm"
805}
806
807#D-#==================================================
808#D-function IGCM_sys_Mv
809#D-* Purpose: generic move
810#D-* Examples:
811#D-
812function IGCM_sys_Mv {
813    IGCM_debug_PushStack "IGCM_sys_Mv" $@
814    if ( $DEBUG_sys ) ; then
815        echo "IGCM_sys_Mv :" $@
816    fi
817
818    if [ $DRYRUN = 0 ]; then
819
820        typeset RET
821           
822        echo mv $@ > out_rsync 2>&1
823        \mv $@ >> out_rsync 2>&1
824        RET=$?
825   
826        if [ ${RET} -gt 0 ] ; then
827            echo "IGCM_sys_Mv : error in mv."
828            cat out_rsync
829            IGCM_debug_Exit "IGCM_sys_Mv"
830        else
831            \rm out_rsync
832        fi
833    else
834        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
835    fi
836
837    IGCM_debug_PopStack "IGCM_sys_Mv"
838}
839
840#D-#==================================================
841#D-function IGCM_sys_Put_Dir
842#D-* Purpose: Copy a complete directory on $(ARCHIVE)
843#D-* Examples:
844#D-
845function IGCM_sys_Put_Dir {
846    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
847    if ( $DEBUG_sys ) ; then
848        echo "IGCM_sys_Put_Dir :" $@
849    fi
850    if [ $DRYRUN = 0 ]; then
851        if [ ! -d ${1} ] ; then
852            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
853            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
854            return
855        fi
856
857        typeset RET
858
859        # Only if we use rsync
860        #IGCM_sys_TestDirArchive $( dirname $2 )
861        #
862        #USUAL WAY
863        \cp -r $1 $2 > out_rsync 2>&1
864        RET=$?
865
866        if [ ${RET} -gt 0 ] ; then
867            echo "IGCM_sys_Put_Dir : error."
868            cat out_rsync
869            IGCM_debug_Exit "IGCM_sys_Put_Dir"
870        else
871            \rm out_rsync
872        fi
873    else
874        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
875    fi
876    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
877}
878
879#D-#==================================================
880#D-function IGCM_sys_Get_Dir
881#D-* Purpose: Copy a complete directory from $(ARCHIVE)
882#D-* Examples:
883#D-
884function IGCM_sys_Get_Dir {
885    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
886    if ( $DEBUG_sys ) ; then
887        echo "IGCM_sys_Get_Dir :" $@
888    fi
889    if [ $DRYRUN = 0 ]; then
890        if [ ! -d ${1} ] ; then
891            echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
892            IGCM_debug_PopStack "IGCM_sys_Get_Dir"
893            return
894        fi
895
896        typeset RET
897
898        # Only if we use rsync
899        #IGCM_sys_TestDirArchive $( dirname $2 )
900        #
901        #USUAL WAY
902        \cp -r $1 $2 > out_rsync 2>&1
903        RET=$?
904
905        if [ ${RET} -gt 0 ] ; then
906            echo "IGCM_sys_Get_Dir : error."
907            cat out_rsync
908            IGCM_debug_Exit "IGCM_sys_Get_Dir"
909        else
910            \rm out_rsync
911        fi
912    else
913        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
914    fi
915    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
916}
917
918#D-#==================================================
919#D-function IGCM_sys_Get_Master
920#D-* Purpose: Copy a complete directory from MASTER filesystem
921#D-* Examples:
922#D-
923function IGCM_sys_Get_Master {
924    IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
925    if ( $DEBUG_sys ) ; then
926        echo "IGCM_sys_Get_Master :" $@
927    fi
928    if [ $DRYRUN = 0 ]; then
929        if [ ! -d ${1} ] ; then
930            echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
931            IGCM_debug_PopStack "IGCM_sys_Get_Master"
932            return
933        fi
934
935        typeset RET
936        sleep 10
937
938        #USUAL WAY
939        \cp -r $1 $2 > out_rsync 2>&1
940        RET=$?
941
942        if [ ${RET} -gt 0 ] ; then
943            echo "IGCM_sys_Get_Master : error."
944            cat out_rsync
945            IGCM_debug_Exit "IGCM_sys_Get_Master"
946        fi
947    else
948        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
949    fi
950    IGCM_debug_PopStack "IGCM_sys_Get_Master"
951}
952
953#D-#==================================================
954#D-function IGCM_sys_Put_Rest
955#D-* Purpose: Put computied restarts on $(ARCHIVE).
956#D-           File and target directory must exist.
957#D-* Examples:
958#D-
959function IGCM_sys_Put_Rest {
960    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
961    if ( $DEBUG_sys ) ; then
962        echo "IGCM_sys_Put_Rest :" $@
963    fi
964    if [ $DRYRUN = 0 ]; then
965        if [ ! -f ${1} ] ; then
966            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
967            IGCM_debug_Exit "IGCM_sys_Put_Rest"
968        fi
969
970        typeset RET
971        #
972        if [ X${JobType} = XRUN ] ; then
973            IGCM_sys_Chmod 444 ${1}
974        fi
975        #
976        IGCM_sys_TestDirArchive $( dirname $2 )
977        #
978        # USUAL WAY
979        \cp $1 $2 > out_rsync 2>&1
980        RET=$?
981
982#       #RSYNC WITH NETWORK SSH CALL
983#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
984#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
985
986#       #RSYNC WITH NFS USE
987#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
988#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
989
990#       RET=$?
991#       IGCM_sys_Rsync_out $RET
992
993#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
994#       (( RET=RET+$? ))
995
996        if [ ${RET} -gt 0 ] ; then
997            echo "IGCM_sys_Put_Rest : error."
998            cat out_rsync
999            IGCM_debug_Exit "IGCM_sys_Put_Rest"
1000        else
1001            \rm out_rsync
1002        fi
1003    else
1004        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1005    fi
1006    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
1007}
1008
1009#D-#==================================================
1010#D-function IGCM_sys_Put_Out
1011#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
1012#D-* Examples:
1013#D-
1014function IGCM_sys_Put_Out {
1015    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
1016    if ( $DEBUG_sys ) ; then
1017        echo "IGCM_sys_Put_Out :" $@
1018    fi
1019    if [ $DRYRUN = 0 ]; then
1020        if [ ! -f ${1} ] ; then
1021            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
1022            IGCM_debug_PopStack "IGCM_sys_Put_Out"
1023            return 1
1024        fi
1025        #
1026        IGCM_sys_MkdirArchive $( dirname $2 )
1027        #
1028        typeset RET
1029
1030        #=====================================================
1031        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1032        #=====================================================
1033
1034        #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
1035        #if [ $? -eq 0 ] ; then
1036        #    typeset WORKPATH FILEPATH
1037        #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
1038        #    IGCM_sys_MkdirWork ${WORKPATH}
1039        #    FILEPATH=${WORKPATH}/$( basename $2 )
1040        #    #
1041        #    IGCM_sys_Cp ${1} ${FILEPATH}
1042        #fi
1043
1044        if [ X${JobType} = XRUN ] ; then
1045            if [ X${3} = X ] ; then
1046                IGCM_sys_Chmod 444 ${1}
1047            fi
1048        fi
1049        #
1050        # USUAL WAY
1051        \cp $1 $2 > out_rsync 2>&1
1052        RET=$?
1053
1054#       #RSYNC WITH NETWORK SSH CALL
1055#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
1056#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
1057
1058#       #RSYNC WITH NFS USE
1059#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1060#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1061
1062#       RET=$?
1063#       IGCM_sys_Rsync_out $RET
1064
1065#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1066#       (( RET=RET+$? ))
1067
1068        if [ ${RET} -gt 0 ] ; then
1069            echo "IGCM_sys_Put_Out : error."
1070            cat out_rsync
1071            IGCM_debug_Exit "IGCM_sys_Put_Out"
1072        else
1073            \rm out_rsync
1074        fi
1075    else
1076        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1077    fi
1078    IGCM_debug_PopStack "IGCM_sys_Put_Out"
1079    return 0
1080}
1081
1082#D-#==================================================
1083#D-function IGCM_sys_Get
1084#D-* Purpose: Get a file from ${ARCHIVE}
1085#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1086#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1087function IGCM_sys_Get {
1088    IGCM_debug_PushStack "IGCM_sys_Get" $@
1089
1090    typeset DEST RET dm_liste ifile target file_work
1091
1092    if ( $DEBUG_sys ) ; then
1093        echo "IGCM_sys_Get :" $@
1094    fi
1095    if [ $DRYRUN -le 2 ]; then
1096        if [ X${1} = X'/l' ] ; then
1097            # test if the first file is present in the old computation :
1098            eval set +A dm_liste \${${2}}
1099        else
1100            eval set +A dm_liste ${1}
1101        fi
1102        eval DEST=\${${#}}
1103
1104        #=====================================================
1105        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1106        #=====================================================
1107
1108        # Is it an R_OUT file (not R_IN) ?
1109        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1110        #if [ $? -eq 0 ] ; then
1111        #    # Yes  ? then we try to get it in SCRATCHDIR
1112        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
1113        #    if [ -f ${file_work[0]} ] ; then
1114        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
1115        #       IGCM_debug_PopStack "IGCM_sys_Get"
1116        #       return
1117        #    fi
1118        #fi
1119
1120        # test if the (first) file is present in the old computation :
1121        IGCM_sys_TestFileArchive ${dm_liste[0]}
1122        RET=$?
1123        if [ ${RET} -gt 0 ] ; then
1124            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1125            IGCM_debug_Exit "IGCM_sys_Get"
1126            IGCM_debug_PopStack "IGCM_sys_Get"
1127            return
1128        fi
1129
1130#       dmget ${dm_liste[*]} > out_rsync 2>&1
1131#       RET=$?
1132#       if [ ${RET} -gt 0 ] ; then
1133#           echo "IGCM_sys_Get : demigration error."
1134#           cat out_rsync
1135#           IGCM_debug_Exit "IGCM_sys_Get"
1136#       fi
1137
1138        #USUAL WAY
1139        if [ X${1} = X'/l' ] ; then
1140            (( RET=0 ))
1141            for target in ${dm_liste[*]} ; do
1142                local_file=$( basename ${target} )
1143                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1144                (( RET = RET + $? ))
1145            done
1146        else
1147            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1148            RET=$?
1149        fi
1150
1151#       #RSYNC WITH NETWORK SSH CALL
1152#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1153#       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1154
1155#       #RSYNC WITH NFS USE
1156#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1157#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1158
1159#       RET=$?
1160#       IGCM_sys_Rsync_out $RET
1161
1162#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1163#       (( RET=RET+$? ))
1164
1165        if [ ${RET} -gt 0 ] ; then
1166            echo "IGCM_sys_Get : copy error."
1167            cat out_rsync
1168            IGCM_debug_Exit "IGCM_sys_Get"
1169        else
1170            \rm out_rsync
1171        fi
1172    else
1173        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1174    fi
1175    IGCM_debug_PopStack "IGCM_sys_Get"
1176}
1177
1178############################################################## A FINIR !!
1179
1180#D-#==================================================
1181#D-function IGCM_sys_GetDate_FichWork
1182#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1183#D-* Examples:
1184#D-
1185function IGCM_sys_GetDate_FichWork {
1186    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1187    if ( $DEBUG_sys ) ; then
1188        echo "IGCM_sys_GetDate_FichWork :" $@
1189    fi
1190    # donne la date filesys d'un fichier sur la machine work
1191    IGCM_debug_PopStack "IGCM_sys_FichWork"
1192}
1193
1194#D-#==================================================
1195#D-function IGCM_sys_GetDate_FichArchive
1196#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1197#D-* Examples:
1198#D-
1199function IGCM_sys_GetDate_FichArchive {
1200    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1201    if ( $DEBUG_sys ) ; then
1202        echo "IGCM_sys_GetDate_FichArchive :" $@
1203    fi
1204    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1205}
1206
1207##############################################################
1208# REBUILD OPERATOR
1209
1210function IGCM_sys_rebuild {
1211    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1212    if ( $DEBUG_sys ) ; then
1213        echo "IGCM_sys_rebuild :" $@
1214    fi
1215    /home/cont003/p86ipsl/X64/bin/rebuild -f -o $@
1216    if [ $? -gt 0 ] ; then
1217       echo "IGCM_sys_rebuild : erreur ${@}."
1218       IGCM_debug_Exit "rebuild"
1219    fi
1220
1221    IGCM_debug_PopStack "IGCM_sys_rebuild"
1222}
1223
1224############################################################
1225# Activate Running Environnment Variables
1226
1227function IGCM_sys_activ_variables {
1228    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1229    if ( $DEBUG_sys ) ; then
1230        echo "IGCM_sys_activ_variables"
1231    fi
1232    ulimit -s 2097152
1233    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1234}
1235
1236############################################################
1237# Desactivate Running Environnment Variables
1238
1239function IGCM_sys_desactiv_variables {
1240    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1241    if ( $DEBUG_sys ) ; then
1242        echo "IGCM_sys_desactiv_variables"
1243    fi
1244    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1245}
1246
1247############################################################
1248# Build run file
1249
1250function IGCM_sys_build_run_file {
1251    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1252    if ( $DEBUG_sys ) ; then
1253        echo "IGCM_sys_build_run_file " $@
1254    fi
1255
1256    # set Number of processors for OCE here
1257    NUM_PROC_OCE=5
1258
1259    (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE - 1))
1260    (( nb_tot_m1    = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE ))
1261    if [ $1 = MPI1 ]; then
1262        cat <<EOF > run_file
1263-np 1 ./oasis
1264-np ${NUM_PROC_ATM} ./lmdz.x
1265-np ${NUM_PROC_OCE} ./opa.xx
1266EOF
1267        config_UserChoices_JobRunOptions='"--app"'
1268        IGCM_sys_Chmod u+x run_file
1269    fi
1270    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1271 
1272}
1273
1274##############################################################
1275# NCO OPERATOR
1276
1277function IGCM_sys_ncatted {
1278    IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1279    if ( $DEBUG_sys ) ; then
1280        echo "IGCM_sys_ncatted :" $@
1281    fi
1282    ncatted "$@"
1283    if [ $? -gt 0 ] ; then
1284       echo "IGCM_sys_ncatted : erreur ${@}."
1285       IGCM_debug_Exit "ncatted"
1286    fi
1287
1288    IGCM_debug_PopStack "IGCM_sys_ncatted"
1289}
1290
1291function IGCM_sys_ncbo {
1292    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1293    if ( $DEBUG_sys ) ; then
1294        echo "IGCM_sys_ncbo :" $@
1295    fi
1296    ncbo $@
1297    if [ $? -gt 0 ] ; then
1298       echo "IGCM_sys_ncbo : erreur ${@}."
1299       IGCM_debug_Exit "ncbo"
1300    fi
1301
1302    IGCM_debug_PopStack "IGCM_sys_ncbo"
1303}
1304
1305function IGCM_sys_ncdiff {
1306    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1307    if ( $DEBUG_sys ) ; then
1308        echo "IGCM_sys_ncdiff :" $@
1309    fi
1310    ncdiff $@
1311    if [ $? -gt 0 ] ; then
1312       echo "IGCM_sys_ncdiff : erreur ${@}."
1313       IGCM_debug_Exit "ncdiff"
1314    fi
1315
1316    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1317}
1318
1319function IGCM_sys_ncea {
1320    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1321    if ( $DEBUG_sys ) ; then
1322        echo "IGCM_sys_ncea :" $@
1323    fi
1324    ncea $@
1325    if [ $? -gt 0 ] ; then
1326       echo "IGCM_sys_ncea : erreur ${@}."
1327       IGCM_debug_Exit "ncea"
1328    fi
1329
1330    IGCM_debug_PopStack "IGCM_sys_ncea"
1331}
1332
1333function IGCM_sys_ncecat {
1334    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1335    if ( $DEBUG_sys ) ; then
1336        echo "IGCM_sys_ncecat :" $@
1337    fi
1338    ncecat $@
1339    if [ $? -gt 0 ] ; then
1340       echo "IGCM_sys_ncecat : erreur ${@}."
1341       IGCM_debug_Exit "ncecat"
1342    fi
1343
1344    IGCM_debug_PopStack "IGCM_sys_ncecat"
1345}
1346
1347function IGCM_sys_ncflint {
1348    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1349    if ( $DEBUG_sys ) ; then
1350        echo "IGCM_sys_ncflint :" $@
1351    fi
1352    ncflint $@
1353    if [ $? -gt 0 ] ; then
1354       echo "IGCM_sys_ncflint : erreur ${@}."
1355       IGCM_debug_Exit "ncflint"
1356    fi
1357
1358    IGCM_debug_PopStack "IGCM_sys_ncflint"
1359}
1360
1361function IGCM_sys_ncks {
1362    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1363    if ( $DEBUG_sys ) ; then
1364        echo "IGCM_sys_ncks :" $@
1365    fi
1366    ncks $@
1367    if [ $? -gt 0 ] ; then
1368       echo "IGCM_sys_ncks : erreur ${@}."
1369       IGCM_debug_Exit "ncks"
1370    fi
1371
1372    IGCM_debug_PopStack "IGCM_sys_ncks"
1373}
1374
1375function IGCM_sys_ncpdq {
1376    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1377    if ( $DEBUG_sys ) ; then
1378        echo "IGCM_sys_ncpdq :" $@
1379    fi
1380    ncpdq $@
1381    if [ $? -gt 0 ] ; then
1382       echo "IGCM_sys_ncpdq : erreur ${@}."
1383       IGCM_debug_Exit "ncpdq"
1384    fi
1385
1386    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1387}
1388
1389function IGCM_sys_ncra {
1390    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1391    if ( $DEBUG_sys ) ; then
1392        echo "IGCM_sys_ncra :" $@
1393    fi
1394    ncra $@
1395    if [ $? -gt 0 ] ; then
1396       echo "IGCM_sys_ncra : erreur ${@}."
1397       IGCM_debug_Exit "ncra"
1398    fi
1399
1400    IGCM_debug_PopStack "IGCM_sys_ncra"
1401}
1402
1403function IGCM_sys_ncrcat {
1404    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1405    if ( $DEBUG_sys ) ; then
1406        echo "IGCM_sys_ncrcat :" $@
1407    fi
1408    ncrcat $@
1409    if [ $? -gt 0 ] ; then
1410       echo "IGCM_sys_ncrcat : erreur ${@}."
1411#       IGCM_debug_Exit "ncrcat"
1412    fi
1413
1414    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1415}
1416
1417function IGCM_sys_ncrename {
1418    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1419    if ( $DEBUG_sys ) ; then
1420        echo "IGCM_sys_ncrename :" $@
1421    fi
1422    ncrename $@
1423    if [ $? -gt 0 ] ; then
1424       echo "IGCM_sys_ncrename : erreur ${@}."
1425       IGCM_debug_Exit "ncrename"
1426    fi
1427
1428    IGCM_debug_PopStack "IGCM_sys_ncrename"
1429}
1430
1431function IGCM_sys_ncwa {
1432    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1433    if ( $DEBUG_sys ) ; then
1434        echo "IGCM_sys_ncwa :" $@
1435    fi
1436    ncwa $@
1437    if [ $? -gt 0 ] ; then
1438       echo "IGCM_sys_ncwa : erreur ${@}."
1439       IGCM_debug_Exit "ncwa"
1440    fi
1441
1442    IGCM_debug_PopStack "IGCM_sys_ncwa"
1443}
Note: See TracBrowser for help on using the repository browser.