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

Last change on this file since 559 was 558, checked in by mafoipsl, 12 years ago

Add default number of processors in libIGCM_sys library. Adapted and tested on vargas and SX9.

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