source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_vargas.ksh @ 581

Last change on this file since 581 was 567, checked in by mafoipsl, 12 years ago

On vargas : add temporary file suppression and add $LOGIN to have different names for different login. NB : No problem on other systems.

  • Property svn:keywords set to Revision Author Date
File size: 35.5 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sébastien Denvil
5# Contact: Sebastien.Denvil__at__ipsl.jussieu.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 Vargas
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 -r MASTER=vargas
71
72#D-
73#D-#==================================================
74#D-Program used in libIGCM
75#D-#==================================================
76
77# rsync with path
78typeset -r RSYNC=/usr/local/bin/rsync
79# RSYNC_opt args to rsync
80typeset -r RSYNC_opt="-va"
81# ie storage filesystem
82typeset -r STOREHOST=gaya.idris.fr
83typeset -r REMOTE_RSYNC=/u/rech/ces/rces452/RSYNC/bin/rsync
84
85#====================================================
86# Host specific DIRECTORIES
87#====================================================
88
89#====================================================
90#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
91typeset -r R_EXE="${MODIPSL}/bin"
92
93#====================================================
94#- SUBMIT_DIR : submission dir
95typeset SUBMIT_DIR=${SUBMIT_DIR:=${LOADL_STEP_INITDIR}}
96
97#====================================================
98#- ARCHIVE
99typeset -r ARCHIVE=$( echo ${HOME} | sed -e "s/homegpfs/u/" )
100
101#====================================================
102#- Mirror libIGCM from vargas to ulam
103typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true}
104
105#====================================================
106#- libIGCM_POST
107PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" )
108typeset -r HOME_POST=$( echo ${HOME} | sed -e "s/homegpfs/home/" )
109typeset -r libIGCM_POST=${HOME_POST}/MIRROR/${PATHlibIGCM}/libIGCM
110
111#====================================================
112#- IN
113typeset -r R_IN=${R_IN:=/u/rech/psl/rpsl035/IGCM}
114typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/u/rech/psl/rpsl376}
115
116#====================================================
117#- OUT
118typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
119
120#====================================================
121#- OUT_POST
122typeset -r R_OUT_POST=$( echo ${HOME} | sed -e "s/homegpfs/workdir/" )/IGCM_OUT
123
124#====================================================
125#- RUN_DIR_PATH : Temporary working directory (=> TMP)
126typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${TMPDIR}}
127
128#====================================================
129#- BIG_DIR : BIG_DIR to store files waiting for rebuild
130typeset -r BIG_DIR=${BIG_DIR:=${WORKDIR}/REBUILD}
131
132#====================================================
133#- HOST_MPIRUN_COMMAND
134typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time poe"}
135
136#====================================================
137#- Max number of arguments passed to nco operator or demigration command
138UNIX_MAX_LIMIT=360
139
140#D-#==================================================
141#D-function IGCM_sys_RshMaster
142#D-* Purpose: Connection to frontend machine.
143#D-* Examples:
144#D-
145(( RshMNum = 0 ))
146function IGCM_sys_RshMaster {
147    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
148
149    typeset THEFILE OUTFILE ERR
150
151    RshDIR=${WORKDIR}/RUN_DIR/${config_UserChoices_TagName}/${config_UserChoices_JobName}.${$}
152    if [ ! -d ${RshDIR} ] ; then
153        IGCM_sys_Mkdir ${RshDIR}
154    fi
155    THEFILE=${RshDIR}/file_sys_RshMaster_$$_${RshMNum}
156    echo '#!/bin/ksh' > ${THEFILE}
157    echo "export libIGCM=${libIGCM} > /dev/null 2>&1" >> ${THEFILE}
158    echo "export DEBUG_debug=${DEBUG_debug} > /dev/null 2>&1" >> ${THEFILE}
159    echo ". ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh > /dev/null 2>&1" >> ${THEFILE}
160    echo ". ${libIGCM}/libIGCM_card/libIGCM_card.ksh > /dev/null 2>&1" >> ${THEFILE}
161    echo "${@} " >> ${THEFILE}
162
163    # No frontend queue on brodie : just rsh the job on the frontend with submission.
164    sed -e "s@IGCM_sys_Qsub\(.*\)@\1@" ${THEFILE} > ${THEFILE}_
165
166    chmod u+x  ${THEFILE}_
167
168    OUTFILE=${RshDIR}/out_RshMaster.$$.${RshMNum}
169    (( RshMNum = RshMNum + 1 ))
170
171    rsh ${MASTER} 'bash -c "nohup '${THEFILE}'_ > '${OUTFILE}' 2>&1 &"'
172    if [ $? -gt 0 ] ; then
173        echo "IGCM_sys_RshMaster : erreur."
174        IGCM_debug_Exit "IGCM_sys_RshMaster"
175    fi
176    IGCM_debug_PopStack "IGCM_sys_RshMaster"
177}
178
179#D-#==================================================
180#D-function IGCM_sys_RshArchive
181#D-* Purpose: Archive rsh command
182#D-* Examples:
183#D-
184function IGCM_sys_RshArchive {
185    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
186    rsh ${STOREHOST} exec /bin/ksh <<-EOF
187    ${@}
188EOF
189    if [ $? -gt 0 ] ; then
190        echo "IGCM_sys_RshArchive : erreur."
191        IGCM_debug_Exit "IGCM_sys_RshArchive"
192    fi
193    IGCM_debug_PopStack "IGCM_sys_RshArchive"
194}
195
196#D-#==================================================
197#D-function IGCM_sys_RshPost
198#D-* Purpose: Post-process rsh command
199#D-* Examples:
200#D-
201function IGCM_sys_RshPost {
202    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
203    if ( $DEBUG_sys ) ; then
204        echo "IGCM_sys_RshPost :" $@
205    fi
206
207    # keep standard input to keep it for postpone if ulam don't answer
208    cat >/tmp/tmp_IGCM_sys_RshPost_$$_${LOGIN}
209
210    ## Add submission for old postponed files only if command is a Qsub
211    ##
212    ISITQSUB=0
213    grep Qsub /tmp/tmp_IGCM_sys_RshPost_$$_${LOGIN} >/dev/null 2>&1 && ISITQSUB=1
214    if  ( [ ${ISITQSUB} -gt 0 ] ) ; then
215      if [ -d ${SUBMIT_DIR}/POSTPONE ] ; then
216            for postponed_file in ${SUBMIT_DIR}/POSTPONE/* ; do
217              if [ -f ${postponed_file} ] ; then
218                IGCM_debug_Print 2 " submit postponed file : " ${postponed_file}
219                rsh ulam exec /bin/ksh <${postponed_file}
220                if [ $? -eq 0 ] ; then
221                     IGCM_sys_Rm ${postponed_file}
222                else
223                     IGCM_debug_Print 2 "keep postponed file for an other submission :" ${postponed_file}
224                fi
225              fi
226          done
227      fi
228    fi
229
230    RETURN=0
231    # rsh ulam command
232    rsh ulam exec /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$_${LOGIN}
233    RETURN=$?
234
235    # keep standard input for postpone if ulam don't answer
236    if ( [ ${RETURN} -gt 0 ] ) ; then
237        IGCM_debug_Print 2 "Postpone tmp_IGCM_sys_RshPost_$$_${LOGIN}"
238        [ -d ${SUBMIT_DIR}/POSTPONE ] || mkdir ${SUBMIT_DIR}/POSTPONE
239        mv /tmp/tmp_IGCM_sys_RshPost_$$_${LOGIN} ${SUBMIT_DIR}/POSTPONE
240    else
241        \rm /tmp/tmp_IGCM_sys_RshPost_$$_${LOGIN}
242    fi
243    IGCM_debug_PopStack "IGCM_sys_RshPost"
244}
245
246#D-#==================================================
247#D-function IGCM_sys_SendMail
248#D-* Purpose: Send mail when simulation is over
249#D-* Examples:
250#D-
251function IGCM_sys_SendMail {
252    IGCM_debug_PushStack "IGCM_sys_SendMail" $@
253    if ( $DEBUG_sys ) ; then
254        echo "IGCM_sys_SendMail :" $@
255    fi
256
257    if ( ${ExitFlag} ) ; then
258        status=failed
259    else
260        status=completed
261    fi
262    cat  << END_MAIL > job_end.mail
263Dear ${LOGIN},
264
265  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
266  Job started : ${DateBegin}
267  Job ended   : ${DateEnd}
268  Output files are available in ${R_SAVE}
269  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
270END_MAIL
271
272    if [ ! -z ${config_UserChoices_MailName} ] ; then
273        mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  job_end.mail
274    elif [ -f ~/.forward ] ; then
275        mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
276    else
277        mailx -s "${config_UserChoices_JobName} ${status}" ${USER} < job_end.mail
278    fi
279
280    if [ $? -gt 0 ] ; then
281        echo "IGCM_sys_SendMail : erreur."
282        IGCM_debug_Exit "IGCM_sys_SendMail"
283    fi
284    IGCM_debug_PopStack "IGCM_sys_SendMail"
285}
286
287#D-#==================================================
288#D-function IGCM_sys_Mkdir
289#D-* Purpose: Master locale mkdir command
290#D-* Examples:
291#D-
292function IGCM_sys_Mkdir {
293    IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
294    if ( $DEBUG_sys ) ; then
295        echo "IGCM_sys_Mkdir :" $@
296    fi
297    if [ ! -d ${1} ]; then
298        \mkdir -p $1
299        if [ $? -gt 0 ] ; then
300            echo "IGCM_sys_Mkdir : erreur."
301            IGCM_debug_Exit "IGCM_sys_Mkdir"
302        fi
303    fi
304    # vérification :
305    if [ ! -d ${1} ] ; then
306        echo "IGCM_sys_Mkdir : erreur."
307        IGCM_debug_Exit "IGCM_sys_Mkdir"
308    fi
309    IGCM_debug_PopStack "IGCM_sys_Mkdir"
310}
311
312#D-#==================================================
313#D-function IGCM_sys_MkdirArchive
314#D-* Purpose: Mkdir on Archive
315#D-* Examples:
316#D-
317function IGCM_sys_MkdirArchive {
318    IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
319    if ( $DEBUG_sys ) ; then
320        echo "IGCM_sys_MkdirArchive :" $@
321    fi
322    #- creation de repertoire sur le serveur fichier
323    rsh ${STOREHOST} -n mkdir -p $1
324
325    if [ $? -gt 0 ] ; then
326        echo "IGCM_sys_MkdirArchive : erreur."
327        IGCM_debug_Exit "IGCM_sys_MkdirArchive"
328    fi
329    IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
330}
331
332#D-#==================================================
333#D-function IGCM_sys_MkdirWork
334#D-* Purpose: Mkdir on Work
335#D-* Examples:
336#D-
337function IGCM_sys_MkdirWork {
338    IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
339    if ( $DEBUG_sys ) ; then
340        echo "IGCM_sys_MkdirWork :" $@
341    fi
342    #- creation de repertoire sur le serveur fichier
343    if [ ! -d ${1} ]; then 
344        \mkdir -p $1
345        if [ $? -gt 0 ] ; then
346            echo "IGCM_sys_MkdirWork : erreur."
347            IGCM_debug_Exit "IGCM_sys_MkdirWork"
348        fi
349    fi
350    IGCM_debug_PopStack "IGCM_sys_MkdirWork"
351}
352
353#D-#==================================================
354#D-function IGCM_sys_Cd
355#D-* Purpose: master cd command
356#D-* Examples:
357#D-
358function IGCM_sys_Cd {
359    IGCM_debug_PushStack "IGCM_sys_Cd" $@
360    if ( $DEBUG_sys ) ; then
361        echo "IGCM_sys_Cd :" $@
362    fi
363    \cd $1
364    if [ $? -gt 0 ] ; then
365        echo "IGCM_sys_Cd : erreur."
366        IGCM_debug_Exit "IGCM_sys_Cd"
367    fi
368    IGCM_debug_PopStack "IGCM_sys_Cd"
369}
370
371#D-#==================================================
372#D-function IGCM_sys_Chmod
373#D-* Purpose: Chmod
374#D-* Examples:
375#D-
376function IGCM_sys_Chmod {
377    IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
378    if ( $DEBUG_sys ) ; then
379        echo "IGCM_sys_Chmod :" $@
380    fi
381    if [ $DRYRUN -le 1 ]; then
382        \chmod $@
383        if [ $? -gt 0 ] ; then
384            echo "IGCM_sys_Chmod : erreur."
385            IGCM_debug_Exit "IGCM_sys_Chmod"
386        fi
387    else
388        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
389    fi
390    IGCM_debug_PopStack "IGCM_sys_Chmod"
391}
392
393#D-#==================================================
394#D-function IGCM_sys_FileSize
395#D-* Purpose: Filesize
396#D-* Examples:
397#D-
398function IGCM_sys_FileSize {
399    IGCM_debug_PushStack "IGCM_sys_FileSize" $@
400
401    typeset sizeF
402    set +A sizeF -- $( ls -la ${1} )
403    if [ $? -gt 0 ] ; then
404        IGCM_debug_Exit "IGCM_sys_FileSize"
405    fi
406    eval ${2}=${sizeF[4]}
407
408    IGCM_debug_PopStack "IGCM_sys_FileSize"
409}
410
411#D-#==================================================
412#D-function IGCM_sys_TestDir
413#D-* Purpose: Test Directory that must exists
414#D-* Examples:
415#D-
416function IGCM_sys_TestDir {
417    IGCM_debug_PushStack "IGCM_sys_TestDir" $@
418    if ( $DEBUG_sys ) ; then
419        echo "IGCM_sys_TestDir :" $@
420    fi
421    typeset ExistFlag
422    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
423    IGCM_debug_PopStack "IGCM_sys_TestDir"
424
425    return ${ExistFlag}
426}
427
428#D-#==================================================
429#D-function IGCM_sys_TestDirArchive
430#D-* Purpose: Test Directory that must exists on Archive
431#D-* Examples:
432#D-
433function IGCM_sys_TestDirArchive {
434    IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
435    if ( $DEBUG_sys ) ; then
436        echo "IGCM_sys_TestDirArchive :" $@
437    fi
438    typeset ExistFlag
439    ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" )
440    IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
441
442    return ${ExistFlag}
443}
444
445#D-#==================================================
446#D-function IGCM_sys_TestFileArchive
447#D-* Purpose: Test file that must NOT EXISTS on Archive
448#D-* Examples:
449#D-
450function IGCM_sys_TestFileArchive {
451    IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
452    typeset ExistFlag
453    ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" )
454    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
455
456    return ${ExistFlag}
457}
458
459#D-#==================================================
460#D-function IGCM_sys_CountFileArchive
461#D-* Purpose: Count files on Archive filesystem
462#D-* Examples:
463#D-
464function IGCM_sys_CountFileArchive {
465    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
466    IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l"
467    if [ $? -gt 0 ] ; then
468        echo "IGCM_sys_CountFileArchive : erreur."
469    fi
470    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
471}
472
473#D-#==================================================
474#D-function IGCM_sys_Tree
475#D-* Purpose: Tree directories with files on ${ARCHIVE}
476#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
477#D-
478function IGCM_sys_Tree {
479    IGCM_debug_PushStack "IGCM_sys_Tree" $@
480    if ( $DEBUG_sys ) ; then
481        echo "IGCM_sys_Tree :" $@
482    fi
483
484    \mfls -r $@
485
486    IGCM_debug_PopStack "IGCM_sys_Tree"
487}
488
489#D-#==================================================
490#D-function IGCM_sys_Tar
491#D-* Purpose: master un-tar command
492#D-* Examples:
493#D-
494function IGCM_sys_Tar {
495    IGCM_debug_PushStack "IGCM_sys_Tar" $@
496    if ( $DEBUG_sys ) ; then
497        echo "IGCM_sys_Tar :" $@
498    fi
499    \tar cf $@
500    if [ $? -gt 0 ] ; then
501        echo "IGCM_sys_Tar : erreur."
502        IGCM_debug_Exit "IGCM_sys_Tar"
503    fi
504    IGCM_debug_PopStack "IGCM_sys_Tar"
505}
506
507#D-#==================================================
508#D-function IGCM_sys_UnTar
509#D-* Purpose: master un-tar command
510#D-* Examples:
511#D-
512function IGCM_sys_UnTar {
513    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
514    if ( $DEBUG_sys ) ; then
515        echo "IGCM_sys_UnTar :" $@
516    fi
517    \tar xvf $1
518    if [ $? -gt 0 ] ; then
519        echo "IGCM_sys_UnTar : erreur."
520        IGCM_debug_Exit "IGCM_sys_UnTar"
521    fi
522    IGCM_debug_PopStack "IGCM_sys_UnTar"
523}
524
525#D-#==================================================
526#D-function IGCM_sys_Qsub
527#D-* Purpose: Qsub new job
528#D-* Examples:
529#D-
530function IGCM_sys_Qsub {
531    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
532    if ( $DEBUG_sys ) ; then
533        echo "IGCM_sys_Qsub :" $@
534    fi
535    # We have to change output/error file
536    [ ${#@} = 1 ] &&  REP_FOR_JOB=$LOADL_STEP_INITDIR
537    [ ${#@} = 2 ] &&  REP_FOR_JOB=$2
538    sed -e "s/\# \@ output *= .*/\# \@ output = ${Script_Output}/" -e "s/\# \@ error *= .*/\# \@ error = ${Script_Output}/" <$1 >${REP_FOR_JOB}/JOB_FOR_IGCM
539    {
540       [ ${#@} = 1 ] &&  ( cd $LOADL_STEP_INITDIR ; /usr/local/bin/llsubmit JOB_FOR_IGCM ; ERROR=$? ; cd - ; )
541       [ ${#@} = 2 ] &&  ( cd $2 ; /usr/local/bin/llsubmit JOB_FOR_IGCM ; ERROR=$? ; cd - ; )
542    }
543    if [ ${ERROR} -gt 0 ] ; then
544       echo "IGCM_sys_Qsub : erreur $@."
545       IGCM_debug_Exit "IGCM_sys_Qsub"
546    fi
547    IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM
548    IGCM_debug_PopStack "IGCM_sys_Qsub"
549
550}
551
552#D-#==================================================
553#D-function IGCM_sys_QsubPost
554#D-* Purpose: Qsub new job on scalaire
555#D-* Examples:
556#D-
557function IGCM_sys_QsubPost {
558    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
559    if ( $DEBUG_sys ) ; then
560        echo "IGCM_sys_QsubPost :" $@
561    fi
562    cd ${POST_DIR}
563    /opt/ibmll/LoadL/full/bin/llsubmit ${libIGCM_POST}/$1.job
564    cd -
565    if [ $? -gt 0 ] ; then
566        echo "IGCM_sys_QsubPost : erreur " $@
567        IGCM_debug_Exit "IGCM_sys_QsubPost"
568    fi
569    IGCM_debug_PopStack "IGCM_sys_QsubPost"
570}
571
572#D-*************************
573#D- File transfer functions
574#D-*************************
575#D-
576
577#D-#==================================================
578#D-function IGCM_sys_Rsync_out
579#D-* Purpose: treat return val of rsync
580#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
581#D-  Error values and explanations can depend on your system version.
582function IGCM_sys_Rsync_out {
583    RET=$1
584    if [ ! $RET ] ; then
585        echo "rsync error !"
586    fi
587
588    if [ $MYLANG = "fr" ]; then
589        case $RET in
590            0)  return ;;
591            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
592                echo "Erreur de syntaxe ou d'utilisation."
593                return;;
594            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
595                echo "Incompatibilité de protocole."
596                return;;
597            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
598                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
599                echo "répertoires"
600                return;;
601            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
602                echo "Action demandée non supportée : une tentative de manipulation de"
603                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
604                echo "été faite ; ou une option qui est supportée par le  client  mais"
605                echo "pas par le serveur a été spécifiée."
606                return;;
607            10) echo "Erreur de rsync ; RERR_SOCKETIO"
608                echo "Erreur dans le socket d'entrée sortie"
609                return;;
610            11) echo "Erreur de rsync ; RERR_FILEIO"
611                echo "Erreur d'entrée sortie fichier"
612                return;;
613            12) echo "Erreur de rsync ; RERR_STREAMIO"
614                echo "Erreur dans flux de donnée du protocole rsync"
615                return;;
616            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
617                echo "Erreur avec les diagnostics du programme"
618                return;;
619            14) echo "Erreur de rsync ; RERR_IPC"
620                echo "Erreur dans le code IPC"
621                return;;
622            20) echo "Erreur de rsync ; RERR_SIGNAL"
623                echo "SIGUSR1 ou SIGINT reçu"
624                return;;
625            21) echo "Erreur de rsync ; RERR_WAITCHILD"
626                echo "Une erreur retournée par waitpid()"
627                return;;
628            22) echo "Erreur de rsync ; RERR_MALLOC"
629                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
630                return;;
631            23) echo ""
632                echo "Erreur fichier inexistant"
633                return;;
634            30) echo "Erreur de rsync ; RERR_TIMEOUT"
635                echo "Temps d'attente écoulé dans l'envoi/réception de données"
636                return;;
637            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
638                return;;
639        esac
640    elif [ $MYLANG = "en" ] ; then
641        case $RET in
642            0)  return;;               
643            1)  echo "rsync error : Syntax or usage error "
644                return;;
645            2)  echo "rsync error : Protocol incompatibility "
646                return;;
647            3)  echo "rsync error : Errors selecting input/output files, dirs"
648                return;;
649            4)  echo "rsync error : Requested action not supported: an attempt"
650                echo "was made to manipulate 64-bit files on a platform that cannot support"
651                echo "them; or an option was specified that is supported by the client and"
652                echo "not by the server."
653                return;;
654            5)  echo "rsync error : Error starting client-server protocol"
655                return;;
656            10) echo "rsync error : Error in socket I/O "
657                return;;
658            11) echo "rsync error : Error in file I/O "
659                return;;
660            12) echo "rsync error : Error in rsync protocol data stream "
661                return;;
662            13) echo "rsync error : Errors with program diagnostics "
663                return;;
664            14) echo "rsync error : Error in IPC code "
665                return;;
666            20) echo "rsync error : Received SIGUSR1 or SIGINT "
667                return;;
668            21) echo "rsync error : Some error returned by waitpid() "
669                return;;
670            22) echo "rsync error : Error allocating core memory buffers "
671                return;;
672            23) echo "rsync error : Partial transfer due to error"
673                return;;
674            24) echo "rsync error : Partial transfer due to vanished source files"
675                return;;
676            30) echo "rsync error : Timeout in data send/receive "
677                return;;
678            *)  echo "rsync error : return code of rsync unknown :" $RET
679                return;;
680        esac
681    else
682        echo "unknown language $MYLANG."
683        return
684    fi
685}
686   
687
688#D-#==================================================
689#D-function IGCM_sys_Miror_libIGCM
690#D-* Purpose: Mirror libIGCM PATH and lib to ulam
691#D-* Examples:
692#D-
693function IGCM_sys_Mirror_libIGCM {
694    IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
695    if ( $DEBUG_sys ) ; then
696        echo "IGCM_sys_Mirror_libIGCM"
697    fi
698
699    typeset RET
700
701    IGCM_sys_RshPost <<-EOF
702    mkdir -p ${HOME_POST}/MIRROR/${PATHlibIGCM}
703EOF
704    rsh ulam -n hostname > /dev/null 2>&1
705    RET=$?
706    if [ $RET -eq 0 ] ; then
707        echo ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME_POST}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
708        ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME_POST}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
709        RET=$?
710
711        if [ ${RET} -gt 0 ] ; then
712            echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on ulam."
713            cat out_rsync
714        fi
715    else
716        echo "No POST-TREATMENT avaible because ulam is down."
717    fi
718    IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
719}
720
721#====================================================
722#- Call IGCM_sys_Mirror_libIGCM now !
723if ( $MirrorlibIGCM ) ; then
724    IGCM_sys_Mirror_libIGCM
725fi
726
727#D-#==================================================
728#D-function IGCM_sys_Cp
729#D-* Purpose: generic cp
730#D-* Examples:
731#D-
732function IGCM_sys_Cp {
733    IGCM_debug_PushStack "IGCM_sys_Cp" $@
734    if ( $DEBUG_sys ) ; then
735        echo "IGCM_sys_Cp :" $@
736    fi
737
738    typeset RET
739
740    echo cp $@ > out_rsync 2>&1
741    \cp $@ >> out_rsync 2>&1
742    RET=$?
743
744    if [ ${RET} -gt 0 ] ; then
745        echo "IGCM_sys_Cp : error."
746        cat out_rsync
747        IGCM_debug_Exit "IGCM_sys_Cp"
748     else
749         \rm out_rsync
750    fi
751    IGCM_debug_PopStack "IGCM_sys_Cp"
752}
753
754#D-#==================================================
755#D-function IGCM_sys_Rm
756#D-* Purpose: generic rm
757#D-* Examples:
758#D-
759function IGCM_sys_Rm {
760    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
761    if ( $DEBUG_sys ) ; then
762        echo "IGCM_sys_Rm :" $@
763    fi
764
765    typeset RET
766
767    echo rm $@ > out_rsync 2>&1
768    \rm $@ >> out_rsync 2>&1
769    RET=$?
770
771    if [ ${RET} -gt 0 ] ; then
772        echo "IGCM_sys_Rm : error."
773        cat out_rsync
774        IGCM_debug_Exit "IGCM_sys_Rm"
775    else
776        \rm out_rsync
777    fi
778    IGCM_debug_PopStack "IGCM_sys_Rm"
779}
780
781#D-#==================================================
782#D-function IGCM_sys_RmRunDir
783#D-* Purpose: rm tmpdir (dummy function most of the time batch
784#D-                      scheduler will do the job)
785#D-* Examples:
786#D-
787function IGCM_sys_RmRunDir {
788    IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
789    if ( $DEBUG_sys ) ; then
790        echo "IGCM_sys_RmRunDir :" $@
791        echo "Dummy call, let the scheduler do that."
792    fi
793    IGCM_debug_PopStack "IGCM_sys_RmRunDir"
794}
795
796#D-#==================================================
797#D-function IGCM_sys_Mv
798#D-* Purpose: generic move
799#D-* Examples:
800#D-
801function IGCM_sys_Mv {
802    IGCM_debug_PushStack "IGCM_sys_Mv" $@
803    if ( $DEBUG_sys ) ; then
804        echo "IGCM_sys_Mv :" $@
805    fi
806
807    if [ $DRYRUN = 0 ]; then
808
809        typeset RET
810           
811        echo mv $@ > out_rsync 2>&1
812        \mv $@ >> out_rsync 2>&1
813        RET=$?
814   
815        if [ ${RET} -gt 0 ] ; then
816            echo "IGCM_sys_Mv : error in mv."
817            cat out_rsync
818            IGCM_debug_Exit "IGCM_sys_Mv"
819        else
820            \rm out_rsync
821        fi
822    else
823        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
824    fi
825
826    IGCM_debug_PopStack "IGCM_sys_Mv"
827}
828
829#D-#==================================================
830#D-function IGCM_sys_Put_Dir
831#D-* Purpose: Copy a complete directory on $(ARCHIVE)
832#D-* Examples:
833#D-
834function IGCM_sys_Put_Dir {
835    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
836    if ( $DEBUG_sys ) ; then
837        echo "IGCM_sys_Put_Dir :" $@
838    fi
839    if [ $DRYRUN = 0 ]; then
840        if [ ! -d ${1} ] ; then
841            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
842            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
843            return
844        fi
845
846        typeset RET
847
848        # Only if we use rsync
849        #IGCM_sys_TestDirArchive $( dirname $2 )
850        #
851        #USUAL WAY
852        rcp -r $1 ${STOREHOST}:$2 > out_rsync 2>&1
853        RET=$?
854
855        if [ ${RET} -gt 0 ] ; then
856            echo "IGCM_sys_Put_Dir : error."
857            cat out_rsync
858            IGCM_debug_Exit "IGCM_sys_Put_Dir"
859        else
860            \rm out_rsync
861        fi
862    else
863        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
864    fi
865    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
866}
867
868#D-#==================================================
869#D-function IGCM_sys_Get_Dir
870#D-* Purpose: Copy a complete directory from $(ARCHIVE)
871#D-* Examples:
872#D-
873function IGCM_sys_Get_Dir {
874    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
875    if ( $DEBUG_sys ) ; then
876        echo "IGCM_sys_Get_Dir :" $@
877    fi
878    if [ $DRYRUN = 0 ]; then
879        if [ ! -d ${1} ] ; then
880            echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
881            IGCM_debug_PopStack "IGCM_sys_Get_Dir"
882            return
883        fi
884
885        typeset RET
886
887        #USUAL WAY
888        rcp -rp ${STOREHOST}:$1 $2 > out_rsync 2>&1
889        RET=$?
890
891        if [ ${RET} -gt 0 ] ; then
892            echo "IGCM_sys_Get_Dir : error."
893            cat out_rsync
894            IGCM_debug_Exit "IGCM_sys_Get_Dir"
895        fi
896    else
897        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
898    fi
899    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
900}
901
902#D-#==================================================
903#D-function IGCM_sys_Put_Rest
904#D-* Purpose: Put computied restarts on $(ARCHIVE).
905#D-           File and target directory must exist.
906#D-* Examples:
907#D-
908function IGCM_sys_Put_Rest {
909    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
910    if ( $DEBUG_sys ) ; then
911        echo "IGCM_sys_Put_Rest :" $@
912    fi
913    if [ $DRYRUN = 0 ]; then
914        if [ ! -f ${1} ] ; then
915            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
916            IGCM_debug_Exit "IGCM_sys_Put_Rest"
917        fi
918
919        typeset RET
920        #
921        if [ X${JobType} = XRUN ] ; then
922            IGCM_sys_Chmod 444 ${1}
923        fi
924        #
925        # Only if we use rsync
926        #IGCM_sys_MkdirArchive $( dirname $2 )
927        #
928        #USUAL WAY
929        mfput $1 $2 > out_rsync 2>&1
930        RET=$?
931
932#       #RSYNC WITH NETWORK RSH CALL
933#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
934#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
935
936#       #RSYNC WITH NFS USE
937#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
938#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
939       
940#       RET=$?
941#       IGCM_sys_Rsync_out $RET
942
943#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
944#       (( RET=RET+$? ))
945
946        if [ ${RET} -gt 0 ] ; then
947            echo "IGCM_sys_Put_Rest : error."
948            cat out_rsync
949            IGCM_debug_Exit "IGCM_sys_Put_Rest"
950        else
951            \rm out_rsync
952        fi
953    else
954        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
955    fi
956    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
957}
958
959#D-#==================================================
960#D-function IGCM_sys_Put_Out
961#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
962#D-* Examples:
963#D-
964function IGCM_sys_Put_Out {
965    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
966    if ( $DEBUG_sys ) ; then
967        echo "IGCM_sys_Put_Out :" $@
968    fi
969    if [ $DRYRUN = 0 ]; then
970        if [ ! -f ${1} ] ; then
971            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
972            IGCM_debug_PopStack "IGCM_sys_Put_Out"
973            return 1
974        fi
975
976        typeset RET
977        #
978        if [ X${JobType} = XRUN ] ; then
979            if [ X${3} = X ] ; then
980                IGCM_sys_Chmod 444 ${1}
981            fi
982        fi
983        #
984        # Only if we use rsync
985        #IGCM_sys_MkdirArchive $( dirname $2 )
986        #
987        #USUAL WAY
988        mfput $1 $2 > out_rsync 2>&1
989        RET=$?
990
991#       #RSYNC WITH NETWORK RSH CALL
992#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
993#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
994
995#       #RSYNC WITH NFS USE
996#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
997#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
998
999#       RET=$?
1000#       IGCM_sys_Rsync_out $RET
1001
1002#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1003#       (( RET=RET+$? ))
1004
1005        if [ ${RET} -gt 0 ] ; then
1006            echo "IGCM_sys_Put_Out : error."
1007            cat out_rsync
1008            IGCM_debug_Exit "IGCM_sys_Put_Out"
1009        else
1010            \rm out_rsync
1011        fi
1012    else
1013        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1014    fi
1015    IGCM_debug_PopStack "IGCM_sys_Put_Out"
1016    return 0
1017}
1018
1019#D-#==================================================
1020#D-function IGCM_sys_Get
1021#D-* Purpose: Get a file from ${ARCHIVE}
1022#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1023#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1024function IGCM_sys_Get {
1025    IGCM_debug_PushStack "IGCM_sys_Get" $@
1026
1027    typeset DEST RET dm_liste ifile target
1028
1029    if ( $DEBUG_sys ) ; then
1030        echo "IGCM_sys_Get :" $@
1031    fi
1032    if [ $DRYRUN -le 2 ]; then
1033        if [ X${1} = X'/l' ] ; then
1034            # test if the first file is present in the old computation :
1035            eval set +A dm_liste \${${2}}
1036        else
1037            dm_liste=${1}
1038        fi
1039        eval DEST=\${${#}}
1040
1041        # test if the (first) file is present in the old computation :
1042        IGCM_sys_TestFileArchive ${dm_liste[0]}
1043        RET=$?
1044        if [ ${RET} -gt 0 ] ; then
1045            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1046            IGCM_debug_Exit "IGCM_sys_Get"
1047            return
1048        fi
1049
1050        # SD : dm_liste is not suited for computing job
1051        #      because we change filename during transfert
1052        #      dm_liste is better suited for post-treatment
1053        #dm_liste=" "
1054        #(( ifile=1 ))
1055        #while [ $ifile -lt $# ] ; do
1056        #    dm_liste=$( eval echo ${dm_liste} " "\${${ifile}} )
1057        #    (( ifile = ifile + 1 ))
1058        #done
1059        #DEST=$( eval echo \${${#}} )
1060
1061        #USUAL WAY
1062        mfget ${dm_liste[*]} ${DEST} > out_rsync 2>&1
1063        #mfget $1 $2 > out_rsync 2>&1
1064        RET=$?
1065
1066#       #RSYNC WITH NETWORK RSH CALL
1067#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1068#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1069
1070#       #RSYNC WITH NFS USE
1071#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1072#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1073
1074#       RET=$?
1075#       IGCM_sys_Rsync_out $RET
1076
1077#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1078#       (( RET=RET+$? ))
1079
1080        if [ ${RET} -gt 0 ] ; then
1081            echo "IGCM_sys_Get : copy error."
1082            cat out_rsync
1083            IGCM_debug_Exit "IGCM_sys_Get"
1084        else
1085            \rm out_rsync
1086        fi
1087    else
1088        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1089    fi
1090    IGCM_debug_PopStack "IGCM_sys_Get"
1091}
1092
1093############################################################## A FINIR !!
1094
1095#D-#==================================================
1096#D-function IGCM_sys_GetDate_FichWork
1097#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1098#D-* Examples:
1099#D-
1100function IGCM_sys_GetDate_FichWork {
1101    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1102    if ( $DEBUG_sys ) ; then
1103        echo "IGCM_sys_GetDate_FichWork :" $@
1104    fi
1105    typeset dateF
1106    set +A dateF -- $( rsh ${MASTER} -n /opt/freeware/bin/ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1107    eval ${2}=${dateF[5]}
1108
1109    # donne la date filesys d'un fichier sur la machine work
1110    IGCM_debug_PopStack "IGCM_sys_FichWork"
1111}
1112
1113#D-#==================================================
1114#D-function IGCM_sys_GetDate_FichArchive
1115#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1116#D-* Examples:
1117#D-
1118function IGCM_sys_GetDate_FichArchive {
1119    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1120    if ( $DEBUG_sys ) ; then
1121        echo "IGCM_sys_GetDate_FichArchive :" $@
1122    fi
1123    typeset dateF
1124    set +A dateF -- $( rsh ${STOREHOST} -n ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1125    eval ${2}=${dateF[5]}
1126
1127    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1128}
1129
1130##############################################################
1131# REBUILD OPERATOR
1132
1133function IGCM_sys_rebuild {
1134    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1135    if ( $DEBUG_sys ) ; then
1136        echo "IGCM_sys_rebuild :" $@
1137    fi
1138    /homegpfs/rech/psl/rpsl035/bin/rebuild -f -o $@
1139    if [ $? -gt 0 ] ; then
1140       echo "IGCM_sys_rebuild : erreur ${@}."
1141       IGCM_debug_Exit "rebuild"
1142    fi
1143
1144    IGCM_debug_PopStack "IGCM_sys_rebuild"
1145}
1146
1147############################################################
1148# Activate Running Environnment Variables
1149
1150function IGCM_sys_activ_variables {
1151    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1152    if ( $DEBUG_sys ) ; then
1153        echo "IGCM_sys_activ_variables "
1154    fi
1155
1156# --------------------------------------------------------------------
1157#D- MPI specifications
1158# --------------------------------------------------------------------
1159
1160# --------------------------------------------------------------------
1161#D- Other specifications
1162# --------------------------------------------------------------------
1163
1164    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1165
1166}
1167
1168############################################################
1169# Desactivate Running Environnment Variables
1170
1171function IGCM_sys_desactiv_variables {
1172    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1173    if ( $DEBUG_sys ) ; then
1174        echo "IGCM_sys_desactiv_variables "
1175    fi
1176# --------------------------------------------------------------------
1177#D- MPI specifications
1178# --------------------------------------------------------------------
1179
1180# --------------------------------------------------------------------
1181#D- Other specifications
1182# --------------------------------------------------------------------
1183
1184    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1185 
1186}
1187
1188############################################################
1189# Build run file
1190
1191function IGCM_sys_build_run_file {
1192    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1193set -x
1194    if ( $DEBUG_sys ) ; then
1195        echo "IGCM_sys_build_run_file " $@
1196    fi
1197
1198    NUM_PROC_OASIS=1
1199
1200    # Set the number of processors for OCE here
1201    NUM_PROC_OCE=5
1202
1203    (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - NUM_PROC_OASIS - NUM_PROC_OCE ))
1204   
1205    if [ $1 = MPI2 ]; then
1206       echo "IGCM_sys_build_run_file : error - MPI2 not available on vargas. "
1207       IGCM_debug_Exit "IGCM_sys_build_run_file"
1208    elif [ $1 = MPI1 ]; then
1209        cat <<EOF > run_file
1210./oasis
1211EOF
1212
1213        typeset i
1214        (( i = 0 ))
1215        while [ ${i} -lt ${NUM_PROC_ATM} ] ; do
1216            (( i = i + 1 ))
1217            cat <<EOF >> run_file
1218./lmdz.x
1219EOF
1220        done
1221
1222        (( i = 0 ))
1223        while [ ${i} -lt ${NUM_PROC_OCE} ] ; do
1224            (( i = i + 1 ))
1225            cat <<EOF >> run_file
1226./opa.xx
1227EOF
1228        done
1229
1230        wc -l run_file
1231    fi
1232set +x
1233    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1234}
Note: See TracBrowser for help on using the repository browser.