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

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

On vargas : use component/CPL instead of executable/oasis, add rm of useless out_rsync.

  • 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        IGCM_sys_Rm out_rsync
964    else
965        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
966    fi
967    IGCM_debug_PopStack "IGCM_sys_Put_Out"
968    return 0
969}
970
971#D-#==================================================
972#D-function IGCM_sys_Get
973#D-* Purpose: Get a file from ${ARCHIVE}
974#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
975#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
976function IGCM_sys_Get {
977    IGCM_debug_PushStack "IGCM_sys_Get" $@
978
979    typeset DEST RET dm_liste ifile target
980
981    if ( $DEBUG_sys ) ; then
982        echo "IGCM_sys_Get :" $@
983    fi
984    if [ $DRYRUN -le 2 ]; then
985        if [ X${1} = X'/l' ] ; then
986            # test if the first file is present in the old computation :
987            eval set +A dm_liste \${${2}}
988        else
989            dm_liste=${1}
990        fi
991        eval DEST=\${${#}}
992
993        # test if the (first) file is present in the old computation :
994        IGCM_sys_TestFileArchive ${dm_liste[0]}
995        RET=$?
996        if [ ${RET} -gt 0 ] ; then
997            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
998            IGCM_debug_Exit "IGCM_sys_Get"
999            return
1000        fi
1001
1002        # SD : dm_liste is not suited for computing job
1003        #      because we change filename during transfert
1004        #      dm_liste is better suited for post-treatment
1005        #dm_liste=" "
1006        #(( ifile=1 ))
1007        #while [ $ifile -lt $# ] ; do
1008        #    dm_liste=$( eval echo ${dm_liste} " "\${${ifile}} )
1009        #    (( ifile = ifile + 1 ))
1010        #done
1011        #DEST=$( eval echo \${${#}} )
1012
1013        #USUAL WAY
1014        mfget ${dm_liste[*]} ${DEST} > out_rsync 2>&1
1015        #mfget $1 $2 > out_rsync 2>&1
1016        RET=$?
1017
1018#       #RSYNC WITH NETWORK RSH CALL
1019#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1020#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1021
1022#       #RSYNC WITH NFS USE
1023#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1024#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1025
1026#       RET=$?
1027#       IGCM_sys_Rsync_out $RET
1028
1029#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1030#       (( RET=RET+$? ))
1031
1032        if [ ${RET} -gt 0 ] ; then
1033            echo "IGCM_sys_Get : copy error."
1034            cat out_rsync
1035            IGCM_debug_Exit "IGCM_sys_Get"
1036        fi
1037    else
1038        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1039    fi
1040    IGCM_debug_PopStack "IGCM_sys_Get"
1041}
1042
1043############################################################## A FINIR !!
1044
1045#D-#==================================================
1046#D-function IGCM_sys_GetDate_FichWork
1047#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1048#D-* Examples:
1049#D-
1050function IGCM_sys_GetDate_FichWork {
1051    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1052    if ( $DEBUG_sys ) ; then
1053        echo "IGCM_sys_GetDate_FichWork :" $@
1054    fi
1055    # donne la date filesys d'un fichier sur la machine work
1056    IGCM_debug_PopStack "IGCM_sys_FichWork"
1057}
1058
1059#D-#==================================================
1060#D-function IGCM_sys_GetDate_FichArchive
1061#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1062#D-* Examples:
1063#D-
1064function IGCM_sys_GetDate_FichArchive {
1065    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1066    if ( $DEBUG_sys ) ; then
1067        echo "IGCM_sys_GetDate_FichArchive :" $@
1068    fi
1069    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1070}
1071
1072##############################################################
1073# REBUILD OPERATOR
1074
1075function IGCM_sys_rebuild {
1076    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1077    if ( $DEBUG_sys ) ; then
1078        echo "IGCM_sys_rebuild :" $@
1079    fi
1080    /homegpfs/rech/psl/rpsl035/bin/rebuild -f -o $@
1081    if [ $? -gt 0 ] ; then
1082       echo "IGCM_sys_rebuild : erreur ${@}."
1083       IGCM_debug_Exit "rebuild"
1084    fi
1085
1086    IGCM_debug_PopStack "IGCM_sys_rebuild"
1087}
1088
1089############################################################
1090# Activate Running Environnment Variables
1091
1092function IGCM_sys_activ_variables {
1093    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1094    if ( $DEBUG_sys ) ; then
1095        echo "IGCM_sys_activ_variables "
1096    fi
1097
1098# --------------------------------------------------------------------
1099#D- MPI specifications
1100# --------------------------------------------------------------------
1101
1102# --------------------------------------------------------------------
1103#D- Other specifications
1104# --------------------------------------------------------------------
1105
1106    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1107
1108}
1109
1110############################################################
1111# Desactivate Running Environnment Variables
1112
1113function IGCM_sys_desactiv_variables {
1114    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1115    if ( $DEBUG_sys ) ; then
1116        echo "IGCM_sys_desactiv_variables "
1117    fi
1118# --------------------------------------------------------------------
1119#D- MPI specifications
1120# --------------------------------------------------------------------
1121
1122# --------------------------------------------------------------------
1123#D- Other specifications
1124# --------------------------------------------------------------------
1125
1126    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1127 
1128}
1129
1130############################################################
1131# Build MPI/OMP scripts
1132function IGCM_sys_build_execution_scripts
1133{
1134    IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1135    if ( $DEBUG_sys ) ; then
1136        echo "IGCM_sys_build_execution_scripts " $@
1137    fi
1138
1139    typeset NbNodes_Job NbProc_Job comp_proc_mpi_loc comp_proc_omp_loc mpi_count
1140   
1141    # Verification with PBS parameter
1142    if [ X${BATCH_NUM_PROC_TOT} != X ] ; then
1143
1144        if ( ${OK_PARA_MPI} ) ; then
1145            EXECUTION=${HOST_MPIRUN_COMMAND}
1146        else
1147            if [ ${BATCH_NUM_PROC_TOT} -eq 1 ] ; then
1148                EXECUTION=${MPIRUN_COMMAND:="time "}
1149            fi
1150        fi
1151    else
1152        if ( ! ${OK_PARA_MPI} ) ; then
1153            EXECUTION=${MPIRUN_COMMAND:="time "}
1154        fi
1155    fi
1156
1157    if [ ${PROCESSUS_NUMBER} -gt 1 ] ; then
1158   
1159        EXECUTION="${EXECUTION} -pgmmodel mpmd -cmdfile ./runfile" 
1160
1161        IGCM_debug_Print 1 "sys vargas : execution command is "
1162        IGCM_debug_Print 1 "$EXECUTION"
1163
1164        if ( ${OK_PARA_OMP} ) ; then
1165# NEW : 2 Noeuds
1166# @ task_geometry={(0)(1,2,3)}
1167# Nombre de processus demandes
1168            echo "Job_${config_UserChoices_JobName} includes task_geometry = \c"
1169            cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" 
1170            echo "Job_${config_UserChoices_JobName} includes task_geometry  with NbNodes = \c"
1171            cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c
1172            NbNodes_Job=$(( $( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c ) - 1 ))
1173
1174            if [ ${NbNodes_Job} -eq 0 ] ; then
1175                IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no task_geometry defined with OpenMP run."
1176                exit 1
1177            fi
1178        else
1179# OLD :
1180# @ total_tasks = 3
1181# @ environment = "BATCH_NUM_PROC_TOT=3"
1182# Pas d OpenMP
1183# @ resources = ConsumableCpus(1)
1184            echo "Job_${config_UserChoices_JobName} includes total_tasks = \c"
1185            cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" 
1186            NbProc_Job=$( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" )
1187            NbProc_Job=${NbProc_Job:=0}
1188            if [ ${NbProc_Job} -eq 0 ] ; then
1189                IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no total_tasks defined with MPI only run."
1190                exit 1
1191            fi
1192            if ( $( egrep '^# *@ *resources *= *ConsumableCpus\(1\)' ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} >/dev/null 2>&1 ) ) ; then
1193                IGCM_debug_Print 2 "ressources =  ConsumableCpus(1) line found into Job_${config_UserChoices_JobName}"
1194            else
1195                IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources = line not found. Job should include resources = ConsumableCpus(1) "
1196                exit 1
1197            fi           
1198        fi
1199        if [ -f runfile ] ; then
1200            IGCM_sys_Rm -f runfile
1201            touch runfile
1202        fi
1203    fi
1204
1205# Then loop on the components
1206
1207### the coupler ie oasis must be the first one
1208    for comp in ${config_ListOfComponents[*]} ; do
1209       
1210        eval ExeNameIn=\${config_Executable_${comp}[0]}
1211        eval ExeNameOut=\${config_Executable_${comp}[1]}
1212           
1213        # Only if we really have an executable for the component :
1214        if [ "X${comp}" = "XCPL" ] ; then
1215
1216            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1217            eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1218           
1219            if ( ${OK_PARA_MPI} ) ; then 
1220
1221                (( mpi_count = 1 ))
1222                until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
1223                    if ( ${OK_PARA_OMP} ) ; then
1224                        echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> runfile
1225                    else
1226                        echo "./${ExeNameOut}" >> runfile
1227                    fi
1228                    (( mpi_count = mpi_count + 1 ))
1229                done
1230            else
1231                if ( ${OK_PARA_OMP} ) ; then
1232                    echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> runfile
1233                else
1234                    echo "./${ExeNameOut} " >> runfile
1235                fi
1236            fi
1237        fi
1238    done
1239
1240    for comp in ${config_ListOfComponents[*]} ; do
1241       
1242        eval ExeNameIn=\${config_Executable_${comp}[0]}
1243        eval ExeNameOut=\${config_Executable_${comp}[1]}
1244           
1245        # Only if we really have an executable for the component and not the coupler ie oasis:
1246        if ( [ "X${ExeNameOut}" != X ] && [ "X${comp}" = "XCPL" ] ) ; then
1247
1248            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1249            eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1250           
1251            if ( ${OK_PARA_MPI} ) ; then 
1252
1253                (( mpi_count = 1 ))
1254                until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
1255                    if ( ${OK_PARA_OMP} ) ; then
1256                        echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> runfile
1257                    else
1258                        echo "./${ExeNameOut}" >> runfile
1259                    fi
1260                    (( mpi_count = mpi_count + 1 ))
1261                done
1262            else
1263                if ( ${OK_PARA_OMP} ) ; then
1264                    echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> runfile
1265                else
1266                    echo "./${ExeNameOut} " >> runfile
1267                fi
1268            fi
1269        fi
1270    done
1271    IGCM_sys_Chmod u+x runfile
1272
1273    if ( $DEBUG_sys ) ; then
1274        echo "runfile contains : "
1275        cat runfile
1276    fi
1277
1278
1279    IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1280}
1281
1282
Note: See TracBrowser for help on using the repository browser.