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

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

First test on mono-executable (sequential, MPI or hybrid MPI/OpenMP) on vargas and first try to use default value adapted to IPSLCM5A in multi-executable mode (OASIS/1 , ATM/26 and OCE/5)

  • Property svn:keywords set to Revision Author Date
File size: 38.0 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#D-#==================================================
650#D-function IGCM_sys_Rm
651#D-* Purpose: generic rm
652#D-* Examples:
653#D-
654function IGCM_sys_Rm {
655    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
656    if ( $DEBUG_sys ) ; then
657        echo "IGCM_sys_Rm :" $@
658    fi
659
660    typeset RET
661
662    echo rm $@ > out_rsync 2>&1
663    \rm $@ >> out_rsync 2>&1
664    RET=$?
665
666    if [ ${RET} -gt 0 ] ; then
667        echo "IGCM_sys_Rm : error."
668        cat out_rsync
669        IGCM_debug_Exit "IGCM_sys_Rm"
670    fi
671    IGCM_debug_PopStack "IGCM_sys_Rm"
672}
673
674#D-#==================================================
675#D-function IGCM_sys_Miror_libIGCM
676#D-* Purpose: Mirror libIGCM PATH and lib to ulam
677#D-* Examples:
678#D-
679function IGCM_sys_Mirror_libIGCM {
680    IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
681    if ( $DEBUG_sys ) ; then
682        echo "IGCM_sys_Mirror_libIGCM"
683    fi
684
685    typeset RET
686
687    IGCM_sys_RshPost <<-EOF
688    mkdir -p ${HOME_POST}/MIRROR/${PATHlibIGCM}
689EOF
690    rsh ulam -n hostname > /dev/null 2>&1
691    RET=$?
692    if [ $RET -eq 0 ] ; then
693        echo ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME_POST}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
694        ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME_POST}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
695        RET=$?
696
697        if [ ${RET} -gt 0 ] ; then
698            echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on ulam."
699            cat out_rsync
700        fi
701        IGCM_sys_Rm out_rsync
702    else
703        echo "No POST-TREATMENT avaible because ulam is down."
704    fi
705    IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
706}
707
708#====================================================
709#- Call IGCM_sys_Mirror_libIGCM now !
710if ( $MirrorlibIGCM ) ; then
711    IGCM_sys_Mirror_libIGCM
712fi
713
714#D-#==================================================
715#D-function IGCM_sys_Cp
716#D-* Purpose: generic cp
717#D-* Examples:
718#D-
719function IGCM_sys_Cp {
720    IGCM_debug_PushStack "IGCM_sys_Cp" $@
721    if ( $DEBUG_sys ) ; then
722        echo "IGCM_sys_Cp :" $@
723    fi
724
725    typeset RET
726
727    echo cp $@ > out_rsync 2>&1
728    \cp $@ >> out_rsync 2>&1
729    RET=$?
730
731    if [ ${RET} -gt 0 ] ; then
732        echo "IGCM_sys_Cp : error."
733        cat out_rsync
734        IGCM_debug_Exit "IGCM_sys_Cp"
735    fi
736    IGCM_debug_PopStack "IGCM_sys_Cp"
737}
738
739#D-#==================================================
740#D-function IGCM_sys_RmRunDir
741#D-* Purpose: rm tmpdir (dummy function most of the time batch
742#D-                      scheduler will do the job)
743#D-* Examples:
744#D-
745function IGCM_sys_RmRunDir {
746    IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
747    if ( $DEBUG_sys ) ; then
748        echo "IGCM_sys_RmRunDir :" $@
749        echo "Dummy call, let the scheduler do that."
750    fi
751    IGCM_debug_PopStack "IGCM_sys_RmRunDir"
752}
753
754#D-#==================================================
755#D-function IGCM_sys_Mv
756#D-* Purpose: generic move
757#D-* Examples:
758#D-
759function IGCM_sys_Mv {
760    IGCM_debug_PushStack "IGCM_sys_Mv" $@
761    if ( $DEBUG_sys ) ; then
762        echo "IGCM_sys_Mv :" $@
763    fi
764
765    if [ $DRYRUN = 0 ]; then
766
767        typeset RET
768           
769        echo mv $@ > out_rsync 2>&1
770        \mv $@ >> out_rsync 2>&1
771        RET=$?
772   
773        if [ ${RET} -gt 0 ] ; then
774            echo "IGCM_sys_Mv : error in mv."
775            cat out_rsync
776            IGCM_debug_Exit "IGCM_sys_Mv"
777        fi
778    else
779        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
780    fi
781
782    IGCM_debug_PopStack "IGCM_sys_Mv"
783}
784
785#D-#==================================================
786#D-function IGCM_sys_Put_Dir
787#D-* Purpose: Copy a complete directory on $(ARCHIVE)
788#D-* Examples:
789#D-
790function IGCM_sys_Put_Dir {
791    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
792    if ( $DEBUG_sys ) ; then
793        echo "IGCM_sys_Put_Dir :" $@
794    fi
795    if [ $DRYRUN = 0 ]; then
796        if [ ! -d ${1} ] ; then
797            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
798            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
799            return
800        fi
801
802        typeset RET
803
804        # Only if we use rsync
805        #IGCM_sys_TestDirArchive $( dirname $2 )
806        #
807        #USUAL WAY
808        rcp -r $1 gaya:$2 > out_rsync 2>&1
809        RET=$?
810
811        if [ ${RET} -gt 0 ] ; then
812            echo "IGCM_sys_Put_Dir : error."
813            cat out_rsync
814            IGCM_debug_Exit "IGCM_sys_Put_Dir"
815        fi
816    else
817        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
818    fi
819    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
820}
821
822#D-#==================================================
823#D-function IGCM_sys_Get_Dir
824#D-* Purpose: Copy a complete directory from $(ARCHIVE)
825#D-* Examples:
826#D-
827function IGCM_sys_Get_Dir {
828    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
829    if ( $DEBUG_sys ) ; then
830        echo "IGCM_sys_Get_Dir :" $@
831    fi
832    if [ $DRYRUN = 0 ]; then
833        if [ ! -d ${1} ] ; then
834            echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
835            IGCM_debug_PopStack "IGCM_sys_Get_Dir"
836            return
837        fi
838
839        typeset RET
840
841        #USUAL WAY
842        rcp -rp gaya:$1 $2 > out_rsync 2>&1
843        RET=$?
844
845        if [ ${RET} -gt 0 ] ; then
846            echo "IGCM_sys_Get_Dir : error."
847            cat out_rsync
848            IGCM_debug_Exit "IGCM_sys_Get_Dir"
849        fi
850    else
851        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
852    fi
853    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
854}
855
856#D-#==================================================
857#D-function IGCM_sys_Put_Rest
858#D-* Purpose: Put computied restarts on $(ARCHIVE).
859#D-           File and target directory must exist.
860#D-* Examples:
861#D-
862function IGCM_sys_Put_Rest {
863    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
864    if ( $DEBUG_sys ) ; then
865        echo "IGCM_sys_Put_Rest :" $@
866    fi
867    if [ $DRYRUN = 0 ]; then
868        if [ ! -f ${1} ] ; then
869            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
870            IGCM_debug_Exit "IGCM_sys_Put_Rest"
871        fi
872
873        typeset RET
874        #
875        if [ X${JobType} = XRUN ] ; then
876            IGCM_sys_Chmod 444 ${1}
877        fi
878        #
879        # Only if we use rsync
880        #IGCM_sys_MkdirArchive $( dirname $2 )
881        #
882        #USUAL WAY
883        mfput $1 $2 > out_rsync 2>&1
884        RET=$?
885
886#       #RSYNC WITH NETWORK RSH CALL
887#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
888#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
889
890#       #RSYNC WITH NFS USE
891#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
892#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
893       
894#       RET=$?
895#       IGCM_sys_Rsync_out $RET
896
897#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
898#       (( RET=RET+$? ))
899
900        if [ ${RET} -gt 0 ] ; then
901            echo "IGCM_sys_Put_Rest : error."
902            cat out_rsync
903            IGCM_debug_Exit "IGCM_sys_Put_Rest"
904        fi
905    else
906        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
907    fi
908    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
909}
910
911#D-#==================================================
912#D-function IGCM_sys_Put_Out
913#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
914#D-* Examples:
915#D-
916function IGCM_sys_Put_Out {
917    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
918    if ( $DEBUG_sys ) ; then
919        echo "IGCM_sys_Put_Out :" $@
920    fi
921    if [ $DRYRUN = 0 ]; then
922        if [ ! -f ${1} ] ; then
923            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
924            IGCM_debug_PopStack "IGCM_sys_Put_Out"
925            return 1
926        fi
927
928        typeset RET
929        #
930        if [ X${JobType} = XRUN ] ; then
931            if [ X${3} = X ] ; then
932                IGCM_sys_Chmod 444 ${1}
933            fi
934        fi
935        #
936        # Only if we use rsync
937        #IGCM_sys_MkdirArchive $( dirname $2 )
938        #
939        #USUAL WAY
940        mfput $1 $2 > out_rsync 2>&1
941        RET=$?
942
943#       #RSYNC WITH NETWORK RSH CALL
944#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
945#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
946
947#       #RSYNC WITH NFS USE
948#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
949#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
950
951#       RET=$?
952#       IGCM_sys_Rsync_out $RET
953
954#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
955#       (( RET=RET+$? ))
956
957        if [ ${RET} -gt 0 ] ; then
958            echo "IGCM_sys_Put_Out : error."
959            cat out_rsync
960            IGCM_debug_Exit "IGCM_sys_Put_Out"
961        fi
962        IGCM_sys_Rm out_rsync
963    else
964        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
965    fi
966    IGCM_debug_PopStack "IGCM_sys_Put_Out"
967    return 0
968}
969
970#D-#==================================================
971#D-function IGCM_sys_Get
972#D-* Purpose: Get a file from ${ARCHIVE}
973#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
974#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
975function IGCM_sys_Get {
976    IGCM_debug_PushStack "IGCM_sys_Get" $@
977
978    typeset DEST RET dm_liste ifile target
979
980    if ( $DEBUG_sys ) ; then
981        echo "IGCM_sys_Get :" $@
982    fi
983    if [ $DRYRUN -le 2 ]; then
984        if [ X${1} = X'/l' ] ; then
985            # test if the first file is present in the old computation :
986            eval set +A dm_liste \${${2}}
987        else
988            dm_liste=${1}
989        fi
990        eval DEST=\${${#}}
991
992        # test if the (first) file is present in the old computation :
993        IGCM_sys_TestFileArchive ${dm_liste[0]}
994        RET=$?
995        if [ ${RET} -gt 0 ] ; then
996            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
997            IGCM_debug_Exit "IGCM_sys_Get"
998            return
999        fi
1000
1001        # SD : dm_liste is not suited for computing job
1002        #      because we change filename during transfert
1003        #      dm_liste is better suited for post-treatment
1004        #dm_liste=" "
1005        #(( ifile=1 ))
1006        #while [ $ifile -lt $# ] ; do
1007        #    dm_liste=$( eval echo ${dm_liste} " "\${${ifile}} )
1008        #    (( ifile = ifile + 1 ))
1009        #done
1010        #DEST=$( eval echo \${${#}} )
1011
1012        #USUAL WAY
1013        mfget ${dm_liste[*]} ${DEST} > out_rsync 2>&1
1014        #mfget $1 $2 > out_rsync 2>&1
1015        RET=$?
1016
1017#       #RSYNC WITH NETWORK RSH CALL
1018#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1019#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1020
1021#       #RSYNC WITH NFS USE
1022#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1023#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1024
1025#       RET=$?
1026#       IGCM_sys_Rsync_out $RET
1027
1028#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1029#       (( RET=RET+$? ))
1030
1031        if [ ${RET} -gt 0 ] ; then
1032            echo "IGCM_sys_Get : copy error."
1033            cat out_rsync
1034            IGCM_debug_Exit "IGCM_sys_Get"
1035        fi
1036    else
1037        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1038    fi
1039    IGCM_debug_PopStack "IGCM_sys_Get"
1040}
1041
1042############################################################## A FINIR !!
1043
1044#D-#==================================================
1045#D-function IGCM_sys_GetDate_FichWork
1046#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1047#D-* Examples:
1048#D-
1049function IGCM_sys_GetDate_FichWork {
1050    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1051    if ( $DEBUG_sys ) ; then
1052        echo "IGCM_sys_GetDate_FichWork :" $@
1053    fi
1054    # donne la date filesys d'un fichier sur la machine work
1055    IGCM_debug_PopStack "IGCM_sys_FichWork"
1056}
1057
1058#D-#==================================================
1059#D-function IGCM_sys_GetDate_FichArchive
1060#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1061#D-* Examples:
1062#D-
1063function IGCM_sys_GetDate_FichArchive {
1064    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1065    if ( $DEBUG_sys ) ; then
1066        echo "IGCM_sys_GetDate_FichArchive :" $@
1067    fi
1068    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1069}
1070
1071##############################################################
1072# REBUILD OPERATOR
1073
1074function IGCM_sys_rebuild {
1075    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1076    if ( $DEBUG_sys ) ; then
1077        echo "IGCM_sys_rebuild :" $@
1078    fi
1079    /homegpfs/rech/psl/rpsl035/bin/rebuild -f -o $@
1080    if [ $? -gt 0 ] ; then
1081       echo "IGCM_sys_rebuild : erreur ${@}."
1082       IGCM_debug_Exit "rebuild"
1083    fi
1084
1085    IGCM_debug_PopStack "IGCM_sys_rebuild"
1086}
1087
1088############################################################
1089# Activate Running Environnment Variables
1090
1091function IGCM_sys_activ_variables {
1092    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1093    if ( $DEBUG_sys ) ; then
1094        echo "IGCM_sys_activ_variables "
1095    fi
1096
1097# --------------------------------------------------------------------
1098#D- MPI specifications
1099# --------------------------------------------------------------------
1100
1101# --------------------------------------------------------------------
1102#D- Other specifications
1103# --------------------------------------------------------------------
1104
1105    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1106
1107}
1108
1109############################################################
1110# Desactivate Running Environnment Variables
1111
1112function IGCM_sys_desactiv_variables {
1113    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1114    if ( $DEBUG_sys ) ; then
1115        echo "IGCM_sys_desactiv_variables "
1116    fi
1117# --------------------------------------------------------------------
1118#D- MPI specifications
1119# --------------------------------------------------------------------
1120
1121# --------------------------------------------------------------------
1122#D- Other specifications
1123# --------------------------------------------------------------------
1124
1125    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1126 
1127}
1128
1129############################################################
1130# Build MPI/OMP scripts
1131function IGCM_sys_build_execution_scripts
1132{
1133    IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1134    if ( $DEBUG_sys ) ; then
1135        echo "IGCM_sys_build_execution_scripts " $@
1136    fi
1137
1138    typeset NbNodes_Job NbProc_Job comp_proc_mpi_loc comp_proc_omp_loc mpi_count
1139   
1140    if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then
1141        IGCM_debug_Exit "IGCM_sys_vargas build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} "
1142    fi
1143
1144    if [ -f run_file ] ; then
1145        IGCM_sys_Rm -f run_file
1146    fi
1147    touch run_file
1148
1149    if ( ${OK_PARA_MPMD} ) ; then
1150
1151        if ( ${OK_PARA_OMP} ) ; then
1152# NEW : 2 Noeuds
1153# @ task_geometry={(0)(1,2,3)}
1154# Nombre de processus demandes
1155            echo "Job_${config_UserChoices_JobName} includes task_geometry = \c"
1156            cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" 
1157            echo "Job_${config_UserChoices_JobName} includes task_geometry  with NbNodes = \c"
1158            cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c
1159            NbNodes_Job=$(( $( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c ) - 1 ))
1160
1161            if [ ${NbNodes_Job} -eq 0 ] ; then
1162                IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no task_geometry defined with OpenMP run."
1163                exit 1
1164            fi
1165        else
1166# OLD :
1167# @ total_tasks = 3
1168# @ environment = "BATCH_NUM_PROC_TOT=3"
1169# Pas d OpenMP
1170# @ resources = ConsumableCpus(1)
1171            echo "Job_${config_UserChoices_JobName} includes total_tasks = \c"
1172            cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" 
1173            NbProc_Job=$( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" )
1174            NbProc_Job=${NbProc_Job:=0}
1175            if [ ${NbProc_Job} -eq 0 ] ; then
1176                IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no total_tasks defined with MPI only run."
1177                exit 1
1178            fi
1179            if ( $( egrep '^# *@ *resources *= *ConsumableCpus\(1\)' ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} >/dev/null 2>&1 ) ) ; then
1180                IGCM_debug_Print 2 "ressources =  ConsumableCpus(1) line found into Job_${config_UserChoices_JobName}"
1181            else
1182                IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources = line not found. Job should include resources = ConsumableCpus(1) "
1183                exit 1
1184            fi           
1185        fi
1186
1187# run_file construction
1188
1189# Then first loop on the components for the coupler ie oasis
1190
1191### the coupler ie oasis must be the first one
1192    for comp in ${config_ListOfComponents[*]} ; do
1193       
1194        eval ExeNameIn=\${config_Executable_${comp}[0]}
1195        eval ExeNameOut=\${config_Executable_${comp}[1]}
1196           
1197        # Only if we really have an executable for the component :
1198        if [ "X${comp}" = "XCPL" ] ; then
1199
1200            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1201            eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1202           
1203            if ( ${OK_PARA_MPI} ) ; then 
1204
1205                (( mpi_count = 1 ))
1206                until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
1207                    if ( ${OK_PARA_OMP} ) ; then
1208                        echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1209                    else
1210                        echo "./${ExeNameOut}" >> run_file
1211                    fi
1212                    (( mpi_count = mpi_count + 1 ))
1213                done
1214            else
1215                if ( ${OK_PARA_OMP} ) ; then
1216                    echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1217                else
1218                    echo "./${ExeNameOut} " >> run_file
1219                fi
1220            fi
1221        fi
1222    done
1223
1224# Then second loop on the components
1225
1226    for comp in ${config_ListOfComponents[*]} ; do
1227       
1228        eval ExeNameIn=\${config_Executable_${comp}[0]}
1229        eval ExeNameOut=\${config_Executable_${comp}[1]}
1230           
1231        # Only if we really have an executable for the component and not the coupler ie oasis:
1232        if ( [ "X${ExeNameOut}" != X ] && [ "X${comp}" != "XCPL" ] ) ; then
1233
1234            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1235            eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1236           
1237            if ( ${OK_PARA_MPI} ) ; then 
1238
1239                (( mpi_count = 1 ))
1240                until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
1241                    if ( ${OK_PARA_OMP} ) ; then
1242                        echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1243                    else
1244                        echo "./${ExeNameOut}" >> run_file
1245                    fi
1246                    (( mpi_count = mpi_count + 1 ))
1247                done
1248            else
1249                if ( ${OK_PARA_OMP} ) ; then
1250                    echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
1251                else
1252                    # to be tested : no MPI only OpenMP into MPMD mode
1253                    echo "./${ExeNameOut} " >> run_file
1254                fi
1255            fi
1256        fi
1257    done
1258
1259    EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file"
1260
1261else # Only one executable. launch it.
1262
1263    for comp in ${config_ListOfComponents[*]} ; do
1264
1265        eval ExeNameIn=\${config_Executable_${comp}[0]}
1266        eval ExeNameOut=\${config_Executable_${comp}[1]}
1267        # to suppress "" coming from config.card
1268        eval ExeNameToLaunch=${ExeNameOut}
1269
1270        [ "X${ExeNameToLaunch}" != X ] &&  EXECUTION="time ./${ExeNameToLaunch}"
1271
1272    done
1273
1274fi
1275
1276    IGCM_sys_Chmod u+x run_file
1277    if ( $DEBUG_sys ) ; then
1278      echo "run_file contains : "
1279      cat run_file
1280    fi
1281
1282    IGCM_debug_Print 1 "sys vargas : execution command is "
1283    IGCM_debug_Print 1 "$EXECUTION"
1284
1285    IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1286}
1287
1288function IGCM_sys_build_run_file {
1289
1290IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1291
1292}
1293
Note: See TracBrowser for help on using the repository browser.