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

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

On SX9 correction to use BATCH_NUM_PROC_TOT variable set in HEADER.

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