source: branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_curie.ksh @ 1572

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

Add curie and try without sourcing /etc/profile.

  • Property svn:keywords set to Revision Author Date
File size: 41.1 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip, Arnaud Caubel
5# Contact: Arnaud.Caubel__at__lsce.ipsl.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 Titane
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# $hostname ou hostname
66typeset  HOST=${HOST:=$( hostname )}
67# $username ou whoami
68typeset  LOGIN=${LOGIN:=$( whoami )}
69# $hostname of the MASTER job
70typeset MASTER=curie
71
72#D-
73#D-#==================================================
74#D-Program used in libIGCM
75#D-#==================================================
76
77# rsync with path
78typeset -r RSYNC=/usr/bin/rsync
79# RSYNC_opt args to rsync
80typeset -r RSYNC_opt="-va"
81# ie storage filesystem
82typeset -r RHOST=curie
83
84#====================================================
85# Source default environment
86#====================================================
87##. /etc/profile
88
89#====================================================
90# Set environment tools (ferret, nco, cdo)
91#====================================================
92. /ccc/cont003/home/dsm/p86ipsl/.atlas_env_curie_ksh
93
94#====================================================
95# Specific for ocean additionnal diagnostic
96export FER_GO="$FER_GO /home/cont003/p86denv/IGCM_POST_UTIL/JNL /home/cont003/p86denv/GRAF /home/cont003/p86denv/GRAF/GO"
97export FER_PALETTE="$FER_PALETTE /home/cont003/p86denv/GRAF/PALET"
98
99#====================================================
100# Host specific DIRECTORIES
101#====================================================
102
103#====================================================
104#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
105typeset -r R_EXE="${MODIPSL}/bin"
106
107#====================================================
108#- SUBMIT_DIR : submission dir
109typeset SUBMIT_DIR=${SUBMIT_DIR:=${BRIDGE_MSUB_PWD}}
110
111#====================================================
112#- ARCHIVE
113typeset -r ARCHIVE=${CCCSTOREDIR}
114
115#====================================================
116typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
117
118#====================================================
119#- libIGCM_POST
120typeset -r libIGCM_POST=${libIGCM}
121
122#====================================================
123#- IN
124typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM}
125typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/ccc/work/cont003/dsm/p24data}
126
127#====================================================
128#- OUT
129typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
130
131#====================================================
132#- OUT_SCR (ONLY FOR double copy an scratch)
133typeset -r R_OUT_SCR=${SCRATCHDIR}/IGCM_OUT
134
135#====================================================
136#- OUT_POST
137typeset -r R_OUT_POST=${SCRATCHDIR}/IGCM_OUT_POST
138
139#====================================================
140#- RUN_DIR_PATH : Temporary working directory (=> TMP)
141if [ ! X${BRIDGE_MSUB_NPROC} = X1 ] ; then
142    typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${BRIDGE_MSUB_JOBID}}
143else
144    typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/TMPDIR_IGCM/${BRIDGE_MSUB_JOBID}}
145fi
146
147#====================================================
148#- BIG_DIR : BIG_DIR to store files waiting for rebuild
149typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD}
150
151#====================================================
152#- HOST_MPIRUN_COMMAND
153typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time ccc_mprun"}
154
155#====================================================
156#- Max number of arguments passed to nco operator or demigration command
157UNIX_MAX_LIMIT=360
158
159NUM_COREPERNODE=8
160       
161
162#D-#==================================================
163#D-function IGCM_sys_RshMaster
164#D-* Purpose: Just a fake command to wrapp
165#D-           IGCM_card call in post-treatment
166#D-           Ulam do not see brodie filesystem
167#D-           Cesium do not see all mercure filesystem
168#D-           That's why we need this hack.
169#D-* Examples:
170#D-
171function IGCM_sys_RshMaster {
172    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
173    /bin/ksh <<-EOF
174    export libIGCM=${libIGCM}
175    export DEBUG_debug=${DEBUG_debug}
176    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
177    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
178    ${@}
179EOF
180    if [ $? -gt 0 ] ; then
181        echo "IGCM_sys_RshMaster : erreur."
182        IGCM_debug_Exit "IGCM_sys_RshMaster"
183    fi
184    IGCM_debug_PopStack "IGCM_sys_RshMaster"
185}
186
187#D-#==================================================
188#D-function IGCM_sys_RshArchive
189#D-* Purpose: Archive rsh command
190#D-* Examples:
191#D-
192function IGCM_sys_RshArchive {
193    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
194    /bin/ksh <<-EOF
195    ${@}
196EOF
197    if [ $? -gt 0 ] ; then
198        echo "IGCM_sys_RshArchive : erreur."
199        IGCM_debug_Exit "IGCM_sys_RshArchive"
200    fi
201    IGCM_debug_PopStack "IGCM_sys_RshArchive"
202}
203
204#D-#==================================================
205#D-function IGCM_sys_RshPost
206#D-* Purpose: Post-process rsh command
207#D-* Examples:
208#D-
209function IGCM_sys_RshPost {
210    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
211    if ( $DEBUG_sys ) ; then
212        echo "IGCM_sys_RshPost :" $@
213    fi
214
215        /bin/ksh ${@}
216        if [ $? -gt 0 ] ; then
217            echo "IGCM_sys_RshPost : erreur."
218            IGCM_debug_Exit "IGCM_sys_RshPost"
219        fi
220    IGCM_debug_PopStack "IGCM_sys_RshPost"
221}
222
223#D-#==================================================
224#D-function IGCM_sys_SendMail
225#D-* Purpose: Send mail when simulation is over
226#D-* Examples:
227#D-
228function IGCM_sys_SendMail {
229    IGCM_debug_PushStack "IGCM_sys_SendMail" $@
230    if ( $DEBUG_sys ) ; then
231       echo "IGCM_sys_SendMail :" $@
232    fi
233
234    if ( ${ExitFlag} ) ; then
235        status=failed
236    else
237        status=completed
238    fi
239
240    cat  << END_MAIL > job_end.mail
241Dear ${LOGIN},
242
243  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
244  Job started : ${DateBegin}
245  Job ended   : ${DateEnd}
246  Output files are available in ${R_SAVE}
247  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
248END_MAIL
249
250    if [ ! -z ${config_UserChoices_MailName} ] ; then
251        mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail
252    elif [ -f ~/.forward ] ; then
253        mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
254    else
255    mail -s "${config_UserChoices_JobName} ${status}" ${USER} < job_end.mail
256    fi
257
258    if [ $? -gt 0 ] ; then
259        echo "IGCM_sys_SendMail : erreur."
260        IGCM_debug_Exit "IGCM_sys_SendMail"
261    fi
262    IGCM_debug_PopStack "IGCM_sys_SendMail"
263}
264
265#D-#==================================================
266#D-function IGCM_sys_Mkdir
267#D-* Purpose: Master locale mkdir command
268#D-* Examples:
269#D-
270function IGCM_sys_Mkdir {
271    IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
272    if ( $DEBUG_sys ) ; then
273        echo "IGCM_sys_Mkdir :" $@
274    fi
275    if [ ! -d ${1} ]; then
276        \mkdir -p $1
277        if [ $? -gt 0 ] ; then
278            echo "IGCM_sys_Mkdir : erreur."
279            IGCM_debug_Exit "IGCM_sys_Mkdir"
280        fi
281    fi
282    # verification :
283    if [ ! -d ${1} ] ; then
284        echo "IGCM_sys_Mkdir : erreur."
285        IGCM_debug_Exit "IGCM_sys_Mkdir"
286    fi
287    IGCM_debug_PopStack "IGCM_sys_Mkdir"
288}
289
290#D-#==================================================
291#D-function IGCM_sys_MkdirArchive
292#D-* Purpose: Mkdir on Archive
293#D-* Examples:
294#D-
295function IGCM_sys_MkdirArchive {
296    IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
297    if ( $DEBUG_sys ) ; then
298        echo "IGCM_sys_MkdirArchive :" $@
299    fi
300    #- creation de repertoire sur le serveur fichier
301    if [ ! -d ${1} ]; then 
302        \mkdir -p $1
303        if [ $? -gt 0 ] ; then
304            echo "IGCM_sys_MkdirArchive : erreur."
305            IGCM_debug_Exit "IGCM_sys_MkdirArchive"
306        fi
307    fi
308    IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
309}
310
311#D-#==================================================
312#D-function IGCM_sys_MkdirWork
313#D-* Purpose: Mkdir on Work
314#D-* Examples:
315#D-
316function IGCM_sys_MkdirWork {
317    IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
318    if ( $DEBUG_sys ) ; then
319        echo "IGCM_sys_MkdirWork :" $@
320    fi
321    #- creation de repertoire sur le serveur fichier
322    if [ ! -d ${1} ]; then 
323        \mkdir -p $1
324        if [ $? -gt 0 ] ; then
325            echo "IGCM_sys_MkdirWork : erreur."
326            IGCM_debug_Exit "IGCM_sys_MkdirWork"
327        fi
328    fi
329    IGCM_debug_PopStack "IGCM_sys_MkdirWork"
330}
331
332#D-#==================================================
333#D-function IGCM_sys_Cd
334#D-* Purpose: master cd command
335#D-* Examples:
336#D-
337function IGCM_sys_Cd {
338    IGCM_debug_PushStack "IGCM_sys_Cd" $@
339    if ( $DEBUG_sys ) ; then
340        echo "IGCM_sys_Cd :" $@
341    fi
342    \cd $1
343    if [ $? -gt 0 ] ; then
344        echo "IGCM_sys_Cd : erreur."
345        IGCM_debug_Exit "IGCM_sys_Cd"
346    fi
347    IGCM_debug_PopStack "IGCM_sys_Cd"
348}
349
350#D-#==================================================
351#D-function IGCM_sys_Chmod
352#D-* Purpose: Chmod
353#D-* Examples:
354#D-
355function IGCM_sys_Chmod {
356    IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
357    if ( $DEBUG_sys ) ; then
358        echo "IGCM_sys_Chmod :" $@
359    fi
360    if [ $DRYRUN -le 1 ]; then
361        \chmod $@
362        if [ $? -gt 0 ] ; then
363            echo "IGCM_sys_Chmod : erreur."
364            IGCM_debug_Exit "IGCM_sys_Chmod"
365        fi
366    else
367        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
368    fi
369    IGCM_debug_PopStack "IGCM_sys_Chmod"
370}
371
372#D-#==================================================
373#D-function IGCM_sys_FileSize
374#D-* Purpose: Filesize
375#D-* Examples:
376#D-
377function IGCM_sys_FileSize {
378    IGCM_debug_PushStack "IGCM_sys_FileSize" $@
379
380    typeset sizeF
381    set +A sizeF -- $( ls -la ${1} )
382    if [ $? -gt 0 ] ; then
383        IGCM_debug_Exit "IGCM_sys_FileSize"
384    fi
385    eval ${2}=${sizeF[4]}
386
387    IGCM_debug_PopStack "IGCM_sys_FileSize"
388}
389
390#D-#==================================================
391#D-function IGCM_sys_TestDir
392#D-* Purpose: Test Directory that must exists
393#D-* Examples:
394#D-
395function IGCM_sys_TestDir {
396    IGCM_debug_PushStack "IGCM_sys_TestDir" $@
397    if ( $DEBUG_sys ) ; then
398        echo "IGCM_sys_TestDir :" $@
399    fi
400    typeset ExistFlag
401    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
402    IGCM_debug_PopStack "IGCM_sys_TestDir"
403
404    return ${ExistFlag}
405}
406
407#D-#==================================================
408#D-function IGCM_sys_TestDirArchive
409#D-* Purpose: Test Directory that must exists on Archive
410#D-* Examples:
411#D-
412function IGCM_sys_TestDirArchive {
413    IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
414    if ( $DEBUG_sys ) ; then
415        echo "IGCM_sys_TestDirArchive :" $@
416    fi
417    typeset ExistFlag
418    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
419    IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
420
421    return ${ExistFlag}
422}
423
424#D-#==================================================
425#D-function IGCM_sys_TestFileArchive
426#D-* Purpose: Test file that must NOT EXISTS on Archive
427#D-* Examples:
428#D-
429function IGCM_sys_TestFileArchive {
430    IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
431    typeset ExistFlag
432    ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
433    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
434
435    return ${ExistFlag}
436}
437
438#D-#==================================================
439#D-function IGCM_sys_CountFileArchive
440#D-* Purpose: Count files on Archive filesystem
441#D-* Examples:
442#D-
443function IGCM_sys_CountFileArchive {
444    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
445    ls ${@} 2>/dev/null | wc -l
446    if [ $? -gt 0 ] ; then
447        echo "IGCM_sys_CountFileArchive : erreur."
448    fi
449    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
450}
451
452#D-#==================================================
453#D-function IGCM_sys_Tree
454#D-* Purpose: Tree directories with files on ${ARCHIVE}
455#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
456#D-
457function IGCM_sys_Tree {
458    IGCM_debug_PushStack "IGCM_sys_Tree" $@
459    if ( $DEBUG_sys ) ; then
460        echo "IGCM_sys_Tree :" $@
461    fi
462
463    \ls -lR ${@}
464
465    IGCM_debug_PopStack "IGCM_sys_Tree"
466}
467
468#D-#==================================================
469#D-function IGCM_sys_Tar
470#D-* Purpose: master un-tar command
471#D-* Examples:
472#D-
473function IGCM_sys_Tar {
474    IGCM_debug_PushStack "IGCM_sys_Tar" $@
475    if ( $DEBUG_sys ) ; then
476        echo "IGCM_sys_Tar :" $@
477    fi
478    \tar xvf $1
479    if [ $? -gt 0 ] ; then
480        echo "IGCM_sys_Tar : erreur."
481        IGCM_debug_Exit "IGCM_sys_Tar"
482    fi
483    IGCM_debug_PopStack "IGCM_sys_Tar"
484}
485
486#D-#==================================================
487#D-function IGCM_sys_UnTar
488#D-* Purpose: master un-tar command
489#D-* Examples:
490#D-
491function IGCM_sys_UnTar {
492    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
493    if ( $DEBUG_sys ) ; then
494        echo "IGCM_sys_UnTar :" $@
495    fi
496    \tar xvf $1
497    if [ $? -gt 0 ] ; then
498        echo "IGCM_sys_UnTar : erreur."
499        IGCM_debug_Exit "IGCM_sys_UnTar"
500    fi
501    IGCM_debug_PopStack "IGCM_sys_UnTar"
502}
503
504#D-#==================================================
505#D-function IGCM_sys_Qsub
506#D-* Purpose: Qsub new job
507#D-* Examples:
508#D-
509function IGCM_sys_Qsub {
510    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
511    if ( $DEBUG_sys ) ; then
512        echo "IGCM_sys_Qsub :" $@
513    fi
514
515    if [ ${config_UserChoices_JobName}.${CumulPeriod} = "." ] ; then
516        /usr/bin/ccc_msub -o ${Script_Output} -e ${Script_Output} < $1
517    else
518        /usr/bin/ccc_msub -o ${Script_Output} -e ${Script_Output} -r ${config_UserChoices_JobName}.${CumulPeriod} < $1
519    fi
520
521    if [ $? -gt 0 ] ; then
522        echo "IGCM_sys_Qsub : erreur " $@
523        IGCM_debug_Exit "IGCM_sys_Qsub"
524    fi
525    IGCM_debug_PopStack "IGCM_sys_Qsub"
526}
527
528#D-#==================================================
529#D-function IGCM_sys_QsubPost
530#D-* Purpose: Qsub new job on scalaire
531#D-* Examples:
532#D-
533function IGCM_sys_QsubPost {
534    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
535    if ( $DEBUG_sys ) ; then
536        echo "IGCM_sys_QsubPost :" $@
537    fi
538    /usr/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out ${libIGCM_POST}/$1.job
539    if [ $? -gt 0 ] ; then
540        echo "IGCM_sys_QsubPost : erreur " $@
541        IGCM_debug_Exit "IGCM_sys_QsubPost"
542    fi
543    IGCM_debug_PopStack "IGCM_sys_QsubPost"
544}
545
546#D-*************************
547#D- File transfer functions
548#D-*************************
549#D-
550
551#D-#==================================================
552#D-function IGCM_sys_Rsync_out
553#D-* Purpose: treat return val of rsync
554#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
555#D-  Error values and explanations can depend on your system version.
556function IGCM_sys_Rsync_out {
557    RET=$1
558    if [ ! $RET ] ; then
559        echo "rsync error !"
560    fi
561
562    if [ $MYLANG = "fr" ]; then
563        case $RET in
564            0)  return ;;
565            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
566                echo "Erreur de syntaxe ou d'utilisation."
567                return;;
568            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
569                echo "Incompatibilité de protocole."
570                return;;
571            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
572                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
573                echo "répertoires"
574                return;;
575            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
576                echo "Action demandée non supportée : une tentative de manipulation de"
577                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
578                echo "été faite ; ou une option qui est supportée par le  client  mais"
579                echo "pas par le serveur a été spécifiée."
580                return;;
581            10) echo "Erreur de rsync ; RERR_SOCKETIO"
582                echo "Erreur dans le socket d'entrée sortie"
583                return;;
584            11) echo "Erreur de rsync ; RERR_FILEIO"
585                echo "Erreur d'entrée sortie fichier"
586                return;;
587            12) echo "Erreur de rsync ; RERR_STREAMIO"
588                echo "Erreur dans flux de donnée du protocole rsync"
589                return;;
590            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
591                echo "Erreur avec les diagnostics du programme"
592                return;;
593            14) echo "Erreur de rsync ; RERR_IPC"
594                echo "Erreur dans le code IPC"
595                return;;
596            20) echo "Erreur de rsync ; RERR_SIGNAL"
597                echo "SIGUSR1 ou SIGINT reçu"
598                return;;
599            21) echo "Erreur de rsync ; RERR_WAITCHILD"
600                echo "Une erreur retournée par waitpid()"
601                return;;
602            22) echo "Erreur de rsync ; RERR_MALLOC"
603                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
604                return;;
605            23) echo ""
606                echo "Erreur fichier inexistant"
607                return;;
608            30) echo "Erreur de rsync ; RERR_TIMEOUT"
609                echo "Temps d'attente écoulé dans l'envoi/réception de données"
610                return;;
611            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
612                return;;
613        esac
614    elif [ $MYLANG = "en" ] ; then
615        case $RET in
616            0)  return;;               
617            1)  echo "rsync error : Syntax or usage error "
618                return;;
619            2)  echo "rsync error : Protocol incompatibility "
620                return;;
621            3)  echo "rsync error : Errors selecting input/output files, dirs"
622                return;;
623            4)  echo "rsync error : Requested action not supported: an attempt"
624                echo "was made to manipulate 64-bit files on a platform that cannot support"
625                echo "them; or an option was specified that is supported by the client and"
626                echo "not by the server."
627                return;;
628            5)  echo "rsync error : Error starting client-server protocol"
629                return;;
630            10) echo "rsync error : Error in socket I/O "
631                return;;
632            11) echo "rsync error : Error in file I/O "
633                return;;
634            12) echo "rsync error : Error in rsync protocol data stream "
635                return;;
636            13) echo "rsync error : Errors with program diagnostics "
637                return;;
638            14) echo "rsync error : Error in IPC code "
639                return;;
640            20) echo "rsync error : Received SIGUSR1 or SIGINT "
641                return;;
642            21) echo "rsync error : Some error returned by waitpid() "
643                return;;
644            22) echo "rsync error : Error allocating core memory buffers "
645                return;;
646            23) echo "rsync error : Partial transfer due to error"
647                return;;
648            24) echo "rsync error : Partial transfer due to vanished source files"
649                return;;
650            30) echo "rsync error : Timeout in data send/receive "
651                return;;
652            *)  echo "rsync error : return code of rsync unknown :" $RET
653                return;;
654        esac
655    else
656        echo "unknown language $MYLANG."
657        return
658    fi
659}
660   
661
662#D-#==================================================
663#D-function IGCM_sys_Miror_libIGCM
664#D-* Purpose: Mirror libIGCM PATH and lib to cesium
665#D-* Examples:
666#D-
667function IGCM_sys_Mirror_libIGCM {
668    IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
669    if ( $DEBUG_sys ) ; then
670        echo "IGCM_sys_Mirror_libIGCM"
671    fi
672
673    typeset RET DEST
674
675    mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
676
677    echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
678    ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
679    RET=$?
680
681    if [ ${RET} -gt 0 ] ; then
682        echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium."
683        cat out_rsync
684    fi
685    IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
686}
687
688#====================================================
689#- Call IGCM_sys_Mirror_libIGCM now !
690if ( $MirrorlibIGCM ) ; then
691    IGCM_sys_Mirror_libIGCM
692fi
693
694#D-#==================================================
695#D-function IGCM_sys_Cp
696#D-* Purpose: generic cp
697#D-* Examples:
698#D-
699function IGCM_sys_Cp {
700    IGCM_debug_PushStack "IGCM_sys_Cp" $@
701    if ( $DEBUG_sys ) ; then
702        echo "IGCM_sys_Cp :" $@
703    fi
704
705    typeset RET
706
707    echo cp $@ > out_rsync 2>&1
708    \cp $@ >> out_rsync 2>&1
709    RET=$?
710
711    if [ ${RET} -gt 0 ] ; then
712        echo "IGCM_sys_Cp : error."
713        cat out_rsync
714        IGCM_debug_Exit "IGCM_sys_Cp"
715     else
716         \rm out_rsync
717    fi
718    IGCM_debug_PopStack "IGCM_sys_Cp"
719}
720
721#D-#==================================================
722#D-function IGCM_sys_Rm
723#D-* Purpose: generic rm
724#D-* Examples:
725#D-
726function IGCM_sys_Rm {
727    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
728    if ( $DEBUG_sys ) ; then
729        echo "IGCM_sys_Rm :" $@
730    fi
731
732    typeset RET
733
734    echo rm $@ > out_rsync 2>&1
735    \rm $@ >> out_rsync 2>&1
736    RET=$?
737
738    if [ ${RET} -gt 0 ] ; then
739        echo "IGCM_sys_Rm : error."
740        cat out_rsync
741        IGCM_debug_Exit "IGCM_sys_Rm"
742    else
743        \rm out_rsync
744    fi
745    IGCM_debug_PopStack "IGCM_sys_Rm"
746}
747
748#D-#==================================================
749#D-function IGCM_sys_RmRunDir
750#D-* Purpose: rm tmpdir (dummy function most of the time batch
751#D-                      scheduler will do the job)
752#D-* Examples:
753#D-
754function IGCM_sys_RmRunDir {
755    IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
756    if ( $DEBUG_sys ) ; then
757        echo "IGCM_sys_RmRunDir :" $@
758    fi
759
760    typeset RET
761
762    echo rm $@ > out_rsync 2>&1
763    \rm $@ >> out_rsync 2>&1
764    RET=$?
765
766    if [ ${RET} -gt 0 ] ; then
767        echo "IGCM_sys_RmRunDir : error."
768        cat out_rsync
769        IGCM_debug_Exit "IGCM_sys_RmRunDir"
770    else
771        \rm out_rsync
772    fi
773
774    IGCM_debug_PopStack "IGCM_sys_RmRunDir"
775}
776
777#D-#==================================================
778#D-function IGCM_sys_Mv
779#D-* Purpose: generic move
780#D-* Examples:
781#D-
782function IGCM_sys_Mv {
783    IGCM_debug_PushStack "IGCM_sys_Mv" $@
784    if ( $DEBUG_sys ) ; then
785        echo "IGCM_sys_Mv :" $@
786    fi
787
788    if [ $DRYRUN = 0 ]; then
789
790        typeset RET
791           
792        echo mv $@ > out_rsync 2>&1
793        \mv $@ >> out_rsync 2>&1
794        RET=$?
795   
796        if [ ${RET} -gt 0 ] ; then
797            echo "IGCM_sys_Mv : error in mv."
798            cat out_rsync
799            IGCM_debug_Exit "IGCM_sys_Mv"
800        else
801            \rm out_rsync
802        fi
803    else
804        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
805    fi
806
807    IGCM_debug_PopStack "IGCM_sys_Mv"
808}
809
810#D-#==================================================
811#D-function IGCM_sys_Put_Dir
812#D-* Purpose: Copy a complete directory on $(ARCHIVE)
813#D-* Examples:
814#D-
815function IGCM_sys_Put_Dir {
816    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
817    if ( $DEBUG_sys ) ; then
818        echo "IGCM_sys_Put_Dir :" $@
819    fi
820    if [ $DRYRUN = 0 ]; then
821        if [ ! -d ${1} ] ; then
822            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
823            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
824            return
825        fi
826
827        typeset RET
828
829        # Only if we use rsync
830        #IGCM_sys_TestDirArchive $( dirname $2 )
831        #
832        #USUAL WAY
833        \cp -r $1 $2 > out_rsync 2>&1
834        RET=$?
835
836        if [ ${RET} -gt 0 ] ; then
837            echo "IGCM_sys_Put_Dir : error."
838            cat out_rsync
839            IGCM_debug_Exit "IGCM_sys_Put_Dir"
840        else
841            \rm out_rsync
842        fi
843    else
844        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
845    fi
846    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
847}
848
849#D-#==================================================
850#D-function IGCM_sys_Get_Dir
851#D-* Purpose: Copy a complete directory from $(ARCHIVE)
852#D-* Examples:
853#D-
854function IGCM_sys_Get_Dir {
855    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
856    if ( $DEBUG_sys ) ; then
857        echo "IGCM_sys_Get_Dir :" $@
858    fi
859    if [ $DRYRUN = 0 ]; then
860#       if [ ! -d ${1} ] ; then
861#           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
862#           IGCM_debug_PopStack "IGCM_sys_Get_Dir"
863#           return
864#       fi
865
866        typeset RET
867
868        # Only if we use rsync
869        #IGCM_sys_TestDirArchive $( dirname $2 )
870        #
871        #USUAL WAY
872        # add get (to demigrate all offline files) to reduce time of this command :
873        ccc_hsm get $1/*
874        \cp -r $1 $2 > out_rsync 2>&1
875        RET=$?
876
877        if [ ${RET} -gt 0 ] ; then
878            echo "IGCM_sys_Get_Dir : error."
879            cat out_rsync
880            IGCM_debug_Exit "IGCM_sys_Get_Dir"
881        else
882            \rm out_rsync
883        fi
884    else
885        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
886    fi
887    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
888}
889
890#D-#==================================================
891#D-function IGCM_sys_Get_Master
892#D-* Purpose: Copy a complete directory from MASTER filesystem
893#D-* Examples:
894#D-
895function IGCM_sys_Get_Master {
896    IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
897    if ( $DEBUG_sys ) ; then
898        echo "IGCM_sys_Get_Master :" $@
899    fi
900    if [ $DRYRUN = 0 ]; then
901        if [ ! -d ${1} ] ; then
902            echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
903            IGCM_debug_PopStack "IGCM_sys_Get_Master"
904            return
905        fi
906
907        typeset RET
908
909        #USUAL WAY
910        \cp -r $1 $2 > out_rsync 2>&1
911        RET=$?
912
913        if [ ${RET} -gt 0 ] ; then
914            echo "IGCM_sys_Get_Master : error."
915            cat out_rsync
916            IGCM_debug_Exit "IGCM_sys_Get_Master"
917        fi
918    else
919        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
920    fi
921    IGCM_debug_PopStack "IGCM_sys_Get_Master"
922}
923
924#D-#==================================================
925#D-function IGCM_sys_Put_Rest
926#D-* Purpose: Put computied restarts on $(ARCHIVE).
927#D-           File and target directory must exist.
928#D-* Examples:
929#D-
930function IGCM_sys_Put_Rest {
931    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
932    if ( $DEBUG_sys ) ; then
933        echo "IGCM_sys_Put_Rest :" $@
934    fi
935    if [ $DRYRUN = 0 ]; then
936        if [ ! -f ${1} ] ; then
937            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
938            IGCM_debug_Exit "IGCM_sys_Put_Rest"
939        fi
940
941        typeset RET
942        #
943        if [ X${JobType} = XRUN ] ; then
944            IGCM_sys_Chmod 444 ${1}
945        fi
946        #
947        IGCM_sys_TestDirArchive $( dirname $2 )
948        #
949        # USUAL WAY
950        \cp $1 $2 > out_rsync 2>&1
951        RET=$?
952
953#       #RSYNC WITH NETWORK SSH CALL
954#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
955#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
956
957#       #RSYNC WITH NFS USE
958#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
959#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
960
961#       RET=$?
962#       IGCM_sys_Rsync_out $RET
963
964#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
965#       (( RET=RET+$? ))
966
967        if [ ${RET} -gt 0 ] ; then
968            echo "IGCM_sys_Put_Rest : error."
969            cat out_rsync
970            IGCM_debug_Exit "IGCM_sys_Put_Rest"
971        else
972            \rm out_rsync
973        fi
974    else
975        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
976    fi
977    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
978}
979
980#D-#==================================================
981#D-function IGCM_sys_Put_Out
982#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
983#D-* Examples:
984#D-
985function IGCM_sys_Put_Out {
986    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
987    if ( $DEBUG_sys ) ; then
988        echo "IGCM_sys_Put_Out :" $@
989    fi
990    if [ $DRYRUN = 0 ]; then
991        if [ ! -f ${1} ] ; then
992            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
993            IGCM_debug_PopStack "IGCM_sys_Put_Out"
994            return 1
995        fi
996        #
997        IGCM_sys_MkdirArchive $( dirname $2 )
998        #
999        typeset RET
1000
1001        #=====================================================
1002        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1003        #=====================================================
1004
1005        #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
1006        #if [ $? -eq 0 ] ; then
1007        #    typeset WORKPATH FILEPATH
1008        #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
1009        #    IGCM_sys_MkdirWork ${WORKPATH}
1010        #    FILEPATH=${WORKPATH}/$( basename $2 )
1011        #    #
1012        #    IGCM_sys_Cp ${1} ${FILEPATH}
1013        #fi
1014
1015        if [ X${JobType} = XRUN ] ; then
1016            if [ X${3} = X ] ; then
1017                IGCM_sys_Chmod 444 ${1}
1018            fi
1019        fi
1020        #
1021        # USUAL WAY
1022        \cp $1 $2 > out_rsync 2>&1
1023        RET=$?
1024
1025#       #RSYNC WITH NETWORK SSH CALL
1026#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
1027#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
1028
1029#       #RSYNC WITH NFS USE
1030#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1031#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1032
1033#       RET=$?
1034#       IGCM_sys_Rsync_out $RET
1035
1036#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1037#       (( RET=RET+$? ))
1038
1039        if [ ${RET} -gt 0 ] ; then
1040            echo "IGCM_sys_Put_Out : error."
1041            cat out_rsync
1042            IGCM_debug_Exit "IGCM_sys_Put_Out"
1043        else
1044            \rm out_rsync
1045        fi
1046    else
1047        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1048    fi
1049    IGCM_debug_PopStack "IGCM_sys_Put_Out"
1050    return 0
1051}
1052
1053#D-#==================================================
1054#D-function IGCM_sys_Get
1055#D-* Purpose: Get a file from ${ARCHIVE}
1056#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1057#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1058function IGCM_sys_Get {
1059    IGCM_debug_PushStack "IGCM_sys_Get" $@
1060
1061    typeset DEST RET dm_liste ifile target file_work
1062
1063    if ( $DEBUG_sys ) ; then
1064        echo "IGCM_sys_Get :" $@
1065    fi
1066    if [ $DRYRUN -le 2 ]; then
1067        if [ X${1} = X'/l' ] ; then
1068            # test if the first file is present in the old computation :
1069            eval set +A dm_liste \${${2}}
1070        else
1071            eval set +A dm_liste ${1}
1072        fi
1073        eval DEST=\${${#}}
1074
1075        #=====================================================
1076        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1077        #=====================================================
1078
1079        # Is it an R_OUT file (not R_IN) ?
1080        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1081        #if [ $? -eq 0 ] ; then
1082        #    # Yes  ? then we try to get it in SCRATCHDIR
1083        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
1084        #    if [ -f ${file_work[0]} ] ; then
1085        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
1086        #       IGCM_debug_PopStack "IGCM_sys_Get"
1087        #       return
1088        #    fi
1089        #fi
1090
1091        # test if the (first) file is present in the old computation :
1092        IGCM_sys_TestFileArchive ${dm_liste[0]}
1093        RET=$?
1094        if [ ${RET} -gt 0 ] ; then
1095            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1096            IGCM_debug_Exit "IGCM_sys_Get"
1097        fi
1098
1099        ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1100        RET=$?
1101
1102        if [ ${RET} -gt 0 ] ; then
1103            echo "WARNING IGCM_sys_Get : demigration error."
1104            cat out_rsync
1105            echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
1106        fi
1107
1108        #if [ ${RET} -gt 0 ] ; then
1109        #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
1110        #       cat out_rsync
1111        #       echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
1112        #       sleep 30
1113        #       echo "We try another time"
1114        #       dmget ${dm_liste[*]} > out_rsync 2>&1
1115        #       RET=$?
1116        #       if [ ${RET} -gt 0 ] ; then
1117        #           echo "ERROR IGCM_sys_Get : again demigration error :"
1118        #           cat out_rsync
1119        #           IGCM_debug_Exit "IGCM_sys_Get"
1120        #       fi
1121        #    else
1122        #       echo "ERROR IGCM_sys_Get : demigration error :"
1123        #       cat out_rsync
1124        #       IGCM_debug_Exit "IGCM_sys_Get"
1125        #    fi
1126        #fi
1127
1128        #USUAL WAY
1129        if [ X${1} = X'/l' ] ; then
1130            (( RET=0 ))
1131            for target in ${dm_liste[*]} ; do
1132                local_file=$( basename ${target} )
1133                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1134                (( RET = RET + $? ))
1135            done
1136        else
1137            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1138            RET=$?
1139        fi
1140
1141#       #RSYNC WITH NETWORK SSH CALL
1142#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1143#       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1144
1145#       #RSYNC WITH NFS USE
1146#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1147#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1148
1149#       RET=$?
1150#       IGCM_sys_Rsync_out $RET
1151
1152#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1153#       (( RET=RET+$? ))
1154
1155        if [ ${RET} -gt 0 ] ; then
1156            echo "IGCM_sys_Get : copy error."
1157            cat out_rsync
1158            IGCM_debug_Exit "IGCM_sys_Get"
1159        else
1160            \rm out_rsync
1161        fi
1162    else
1163        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1164    fi
1165    IGCM_debug_PopStack "IGCM_sys_Get"
1166}
1167
1168############################################################## A FINIR !!
1169
1170#D-#==================================================
1171#D-function IGCM_sys_GetDate_FichWork
1172#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1173#D-* Examples:
1174#D-
1175function IGCM_sys_GetDate_FichWork {
1176    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1177    if ( $DEBUG_sys ) ; then
1178        echo "IGCM_sys_GetDate_FichWork :" $@
1179    fi
1180    # donne la date filesys d'un fichier sur la machine work
1181    IGCM_debug_PopStack "IGCM_sys_FichWork"
1182}
1183
1184#D-#==================================================
1185#D-function IGCM_sys_GetDate_FichArchive
1186#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1187#D-* Examples:
1188#D-
1189function IGCM_sys_GetDate_FichArchive {
1190    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1191    if ( $DEBUG_sys ) ; then
1192        echo "IGCM_sys_GetDate_FichArchive :" $@
1193    fi
1194    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1195}
1196
1197##############################################################
1198# REBUILD OPERATOR
1199
1200function IGCM_sys_rebuild {
1201    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1202    if ( $DEBUG_sys ) ; then
1203        echo "IGCM_sys_rebuild :" $@
1204    fi
1205    ~p86ipsl/CESIUM/bin/rebuild -f -o $@
1206    if [ $? -gt 0 ] ; then
1207       echo "IGCM_sys_rebuild : erreur ${@}."
1208       IGCM_debug_Exit "rebuild"
1209    fi
1210
1211    IGCM_debug_PopStack "IGCM_sys_rebuild"
1212}
1213
1214############################################################
1215# Activate Running Environnment Variables
1216
1217function IGCM_sys_activ_variables {
1218    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1219    if ( $DEBUG_sys ) ; then
1220        echo "IGCM_sys_activ_variables"
1221    fi
1222
1223    ulimit -s unlimited
1224
1225    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1226}
1227
1228############################################################
1229# Desactivate Running Environnment Variables
1230
1231function IGCM_sys_desactiv_variables {
1232    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1233    if ( $DEBUG_sys ) ; then
1234        echo "IGCM_sys_desactiv_variables"
1235    fi
1236    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1237}
1238
1239
1240function IGCM_sys_build_run_file {
1241############################################################
1242# Build run file
1243
1244 IGCM_debug_Print 1 "Dummy IGCM_sys_build_run_file"
1245
1246}
1247
1248############################################################
1249# Build MPI/OMP scripts
1250function IGCM_sys_build_execution_scripts
1251{
1252    IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1253    if ( $DEBUG_sys ) ; then
1254        echo "IGCM_sys_build_execution_scripts " $@
1255    fi
1256
1257    # Verification with MSUB parameter
1258        EXECUTION=${HOST_MPIRUN_COMMAND}
1259
1260    if ( ${OK_PARA_MPMD} ) ; then
1261
1262        if [ -f run_file ] ; then
1263            IGCM_sys_Rm -f run_file
1264        fi
1265        touch run_file
1266
1267# run_file construction
1268
1269# Then first loop on the components for the coupler ie oasis
1270
1271### the coupler ie oasis must be the first one
1272    for comp in ${config_ListOfComponents[*]} ; do
1273
1274        eval ExeNameIn=\${config_Executable_${comp}[0]}
1275        eval ExeNameOut=\${config_Executable_${comp}[1]}
1276
1277        # for CPL component only
1278        if [ "X${comp}" = "XCPL" ] ; then
1279
1280            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1281            eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1282            echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1283        fi
1284    done
1285
1286# Then second loop on the components
1287
1288    for comp in ${config_ListOfComponents[*]} ; do
1289
1290        eval ExeNameIn=\${config_Executable_${comp}[0]}
1291        eval ExeNameOut=\${config_Executable_${comp}[1]}
1292
1293        # Only if we really have an executable for the component and not the coupler ie oasis:
1294        if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
1295
1296            eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1297            eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1298            echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
1299        fi
1300    done
1301
1302    EXECUTION="${HOST_MPIRUN_COMMAND} -f ./run_file"
1303
1304    IGCM_sys_Chmod u+x run_file
1305    if ( $DEBUG_sys ) ; then
1306      echo "run_file contains : "
1307      cat run_file
1308    fi
1309
1310else # Only one executable. launch it.
1311
1312    #
1313    for comp in ${config_ListOfComponents[*]} ; do
1314
1315        eval ExeNameIn=\${config_Executable_${comp}[0]}
1316        eval ExeNameOut=\${config_Executable_${comp}[1]}
1317
1318        if  [ "X${ExeNameOut}" != X\"\" ] ; then
1319            if ( ${OK_PARA_MPI} ) ; then
1320                eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1321                EXECUTION="${EXECUTION} -n ${comp_proc_mpi_loc} ./${ExeNameOut}"
1322            else
1323                EXECUTION="${EXECUTION} ./${ExeNameOut}"
1324            fi
1325            if ( ${OK_PARA_OMP} ) ; then
1326                eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1327                EXECUTION="export OMP_NUM_THREADS=${comp_proc_omp_loc} ; ${EXECUTION} "
1328            fi
1329        fi
1330
1331    done
1332
1333fi
1334
1335    IGCM_debug_Print 1 "sys Curie : execution command is "
1336    IGCM_debug_Print 1 "$EXECUTION"
1337
1338    IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
1339}
1340
1341
1342
1343##############################################################
1344# NCO OPERATOR
1345
1346function IGCM_sys_ncatted {
1347    IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1348    if ( $DEBUG_sys ) ; then
1349        echo "IGCM_sys_ncatted :" $@
1350    fi
1351    ncatted "$@"
1352    if [ $? -gt 0 ] ; then
1353       echo "IGCM_sys_ncatted : erreur ${@}."
1354       IGCM_debug_Exit "ncatted"
1355    fi
1356
1357    IGCM_debug_PopStack "IGCM_sys_ncatted"
1358}
1359
1360function IGCM_sys_ncbo {
1361    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1362    if ( $DEBUG_sys ) ; then
1363        echo "IGCM_sys_ncbo :" $@
1364    fi
1365    ncbo $@
1366    if [ $? -gt 0 ] ; then
1367       echo "IGCM_sys_ncbo : erreur ${@}."
1368       IGCM_debug_Exit "ncbo"
1369    fi
1370
1371    IGCM_debug_PopStack "IGCM_sys_ncbo"
1372}
1373
1374function IGCM_sys_ncdiff {
1375    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1376    if ( $DEBUG_sys ) ; then
1377        echo "IGCM_sys_ncdiff :" $@
1378    fi
1379    ncdiff $@
1380    if [ $? -gt 0 ] ; then
1381       echo "IGCM_sys_ncdiff : erreur ${@}."
1382       IGCM_debug_Exit "ncdiff"
1383    fi
1384
1385    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1386}
1387
1388function IGCM_sys_ncea {
1389    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1390    if ( $DEBUG_sys ) ; then
1391        echo "IGCM_sys_ncea :" $@
1392    fi
1393    ncea $@
1394    if [ $? -gt 0 ] ; then
1395       echo "IGCM_sys_ncea : erreur ${@}."
1396       IGCM_debug_Exit "ncea"
1397    fi
1398
1399    IGCM_debug_PopStack "IGCM_sys_ncea"
1400}
1401
1402function IGCM_sys_ncecat {
1403    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1404    if ( $DEBUG_sys ) ; then
1405        echo "IGCM_sys_ncecat :" $@
1406    fi
1407    ncecat $@
1408    if [ $? -gt 0 ] ; then
1409       echo "IGCM_sys_ncecat : erreur ${@}."
1410       IGCM_debug_Exit "ncecat"
1411    fi
1412
1413    IGCM_debug_PopStack "IGCM_sys_ncecat"
1414}
1415
1416function IGCM_sys_ncflint {
1417    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1418    if ( $DEBUG_sys ) ; then
1419        echo "IGCM_sys_ncflint :" $@
1420    fi
1421    ncflint $@
1422    if [ $? -gt 0 ] ; then
1423       echo "IGCM_sys_ncflint : erreur ${@}."
1424       IGCM_debug_Exit "ncflint"
1425    fi
1426
1427    IGCM_debug_PopStack "IGCM_sys_ncflint"
1428}
1429
1430function IGCM_sys_ncks {
1431    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1432    if ( $DEBUG_sys ) ; then
1433        echo "IGCM_sys_ncks :" $@
1434    fi
1435    ncks $@
1436    if [ $? -gt 0 ] ; then
1437       echo "IGCM_sys_ncks : erreur ${@}."
1438       IGCM_debug_Exit "ncks"
1439    fi
1440
1441    IGCM_debug_PopStack "IGCM_sys_ncks"
1442}
1443
1444function IGCM_sys_ncpdq {
1445    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1446    if ( $DEBUG_sys ) ; then
1447        echo "IGCM_sys_ncpdq :" $@
1448    fi
1449    ncpdq $@
1450    if [ $? -gt 0 ] ; then
1451       echo "IGCM_sys_ncpdq : erreur ${@}."
1452       IGCM_debug_Exit "ncpdq"
1453    fi
1454
1455    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1456}
1457
1458function IGCM_sys_ncra {
1459    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1460    if ( $DEBUG_sys ) ; then
1461        echo "IGCM_sys_ncra :" $@
1462    fi
1463    ncra $@
1464    if [ $? -gt 0 ] ; then
1465       echo "IGCM_sys_ncra : erreur ${@}."
1466       IGCM_debug_Exit "ncra"
1467    fi
1468
1469    IGCM_debug_PopStack "IGCM_sys_ncra"
1470}
1471
1472function IGCM_sys_ncrcat {
1473    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1474    if ( $DEBUG_sys ) ; then
1475        echo "IGCM_sys_ncrcat :" $@
1476    fi
1477    ncrcat $@
1478    if [ $? -gt 0 ] ; then
1479       echo "IGCM_sys_ncrcat : erreur ${@}."
1480#       IGCM_debug_Exit "ncrcat"
1481    fi
1482
1483    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1484}
1485
1486function IGCM_sys_ncrename {
1487    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1488    if ( $DEBUG_sys ) ; then
1489        echo "IGCM_sys_ncrename :" $@
1490    fi
1491    ncrename $@
1492    if [ $? -gt 0 ] ; then
1493       echo "IGCM_sys_ncrename : erreur ${@}."
1494       IGCM_debug_Exit "ncrename"
1495    fi
1496
1497    IGCM_debug_PopStack "IGCM_sys_ncrename"
1498}
1499
1500function IGCM_sys_ncwa {
1501    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1502    if ( $DEBUG_sys ) ; then
1503        echo "IGCM_sys_ncwa :" $@
1504    fi
1505    ncwa $@
1506    if [ $? -gt 0 ] ; then
1507       echo "IGCM_sys_ncwa : erreur ${@}."
1508       IGCM_debug_Exit "ncwa"
1509    fi
1510
1511    IGCM_debug_PopStack "IGCM_sys_ncwa"
1512}
Note: See TracBrowser for help on using the repository browser.