source: branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_vargas.ksh @ 493

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

Adaptation and test on vargas for MPI only coupled run. No test with only one component. No test with OpenMP/MPI mixture.

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