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

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

Delete useless sleep.

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

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