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

Last change on this file since 463 was 463, checked in by mafoipsl, 13 years ago

Delete useless sleep.

  • Property svn:keywords set to Revision Author Date
File size: 39.6 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)
152if [ ! X${LSB_QUEUE} = Xmono ] ; then
153    typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}}
154else
155    typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/TMPDIR_IGCM/tmp$$}
156fi
157
158#====================================================
159#- BIG_DIR : BIG_DIR to store files waiting for rebuild
160typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD}
161
162#====================================================
163#- HOST_MPIRUN_COMMAND
164typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"}
165
166#====================================================
167#- Max number of arguments passed to nco operator or demigration command
168UNIX_MAX_LIMIT=360
169
170#D-#==================================================
171#D-function IGCM_sys_RshMaster
172#D-* Purpose: Just a fake command to wrapp
173#D-           IGCM_card call in post-treatment
174#D-           Ulam do not see brodie filesystem
175#D-           Cesium do not see all mercure filesystem
176#D-           That's why we need this hack.
177#D-* Examples:
178#D-
179function IGCM_sys_RshMaster {
180    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
181    /bin/ksh <<-EOF
182    export libIGCM=${libIGCM}
183    export DEBUG_debug=${DEBUG_debug}
184    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
185    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
186    ${@}
187EOF
188    if [ $? -gt 0 ] ; then
189        echo "IGCM_sys_RshMaster : erreur."
190        IGCM_debug_Exit "IGCM_sys_RshMaster"
191    fi
192    IGCM_debug_PopStack "IGCM_sys_RshMaster"
193}
194
195#D-#==================================================
196#D-function IGCM_sys_RshArchive
197#D-* Purpose: Archive rsh command
198#D-* Examples:
199#D-
200function IGCM_sys_RshArchive {
201    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
202    /bin/ksh <<-EOF
203    ${@}
204EOF
205    if [ $? -gt 0 ] ; then
206        echo "IGCM_sys_RshArchive : erreur."
207        IGCM_debug_Exit "IGCM_sys_RshArchive"
208    fi
209    IGCM_debug_PopStack "IGCM_sys_RshArchive"
210}
211
212#D-#==================================================
213#D-function IGCM_sys_RshPost
214#D-* Purpose: Post-process rsh command
215#D-* Examples:
216#D-
217function IGCM_sys_RshPost {
218    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
219    if ( $DEBUG_sys ) ; then
220        echo "IGCM_sys_RshPost :" $@
221    fi
222
223    typeset NB_ESSAI DELAI status i
224    # keep standard input for the loop onto temporary file
225    cat >tmp_IGCM_sys_RshPost_$$
226
227    #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL
228    #cat tmp_IGCM_sys_RshPost_$$
229
230    if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then
231        # little hack so that rebuild submission is done on titane not an cesium
232        #
233        libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' )
234        POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' )
235        sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt
236        sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$
237        sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt
238        sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$
239        #\mv tmp.txt tmp_IGCM_sys_RshPost_$$
240        #
241        #echo cat tmp_IGCM_sys_RshPost_$$ AFTER
242        #cat tmp_IGCM_sys_RshPost_$$
243        /bin/ksh <tmp_IGCM_sys_RshPost_$$
244        if [ $? -gt 0 ] ; then
245            echo "IGCM_sys_RshPost : erreur."
246            IGCM_debug_Exit "IGCM_sys_RshPost"
247        fi
248    else
249        # number of tentative
250        NB_ESSAI=10
251        # time delay between tentative
252        DELAI=10
253        i=0
254        while [ $i -ne $NB_ESSAI ] ; do
255            ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$
256            status=$?
257            if [ ${status} -ne 0 ];
258            then
259                sleep $DELAI
260            else
261                break
262            fi
263            let i=$i+1
264        done
265        # delete temporary file
266        /bin/rm tmp_IGCM_sys_RshPost_$$
267
268        if [ ${status} -gt 0 ] ; then
269            echo "IGCM_sys_RshPost : erreur."
270            IGCM_debug_Exit "IGCM_sys_RshPost"
271        fi
272    fi
273    IGCM_debug_PopStack "IGCM_sys_RshPost"
274}
275
276#D-#==================================================
277#D-function IGCM_sys_SendMail
278#D-* Purpose: Send mail when simulation is over
279#D-* Examples:
280#D-
281function IGCM_sys_SendMail {
282    IGCM_debug_PushStack "IGCM_sys_SendMail" $@
283    if ( $DEBUG_sys ) ; then
284       echo "IGCM_sys_SendMail :" $@
285    fi
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} ${status}" ${config_UserChoices_MailName} < job_end.mail
315    elif [ -f ~/.forward ] ; then
316        mailx -s "${config_UserChoices_JobName} ${status}" $( 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
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.