source: tags/libIGCM_v2.0_beta2/libIGCM_sys/libIGCM_sys_platine.ksh @ 1456

Last change on this file since 1456 was 651, checked in by aclsce, 12 years ago

Added check to be sure there is enough space on temporary filesystems (only on vargas, titane and mercure sx9).
If there is not enough space, we stop.

  • 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.9 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    typeset ExistFlag
417    ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
418    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
419
420    return ${ExistFlag}
421}
422
423#D-#==================================================
424#D-function IGCM_sys_CountFileArchive
425#D-* Purpose: Count files on Archive filesystem
426#D-* Examples:
427#D-
428function IGCM_sys_CountFileArchive {
429    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
430    ls ${@} 2>/dev/null | wc -l
431    if [ $? -gt 0 ] ; then
432        echo "IGCM_sys_CountFileArchive : erreur."
433    fi
434    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
435}
436
437#D-#==================================================
438#D-function IGCM_sys_Tree
439#D-* Purpose: Tree directories with files on ${ARCHIVE}
440#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
441#D-
442function IGCM_sys_Tree {
443    IGCM_debug_PushStack "IGCM_sys_Tree" $@
444    if ( $DEBUG_sys ) ; then
445        echo "IGCM_sys_Tree :" $@
446    fi
447
448    \tree -f $@
449
450    IGCM_debug_PopStack "IGCM_sys_Tree"
451}
452
453#D-#==================================================
454#D-function IGCM_sys_Tar
455#D-* Purpose: master un-tar command
456#D-* Examples:
457#D-
458function IGCM_sys_Tar {
459    IGCM_debug_PushStack "IGCM_sys_Tar" $@
460    if ( $DEBUG_sys ) ; then
461        echo "IGCM_sys_Tar :" $@
462    fi
463    \tar cvf $@
464    if [ $? -gt 0 ] ; then
465        echo "IGCM_sys_Tar : erreur."
466        IGCM_debug_Exit "IGCM_sys_Tar"
467    fi
468    \tar tvf $1
469
470    IGCM_debug_PopStack "IGCM_sys_Tar"
471}
472
473#D-#==================================================
474#D-function IGCM_sys_UnTar
475#D-* Purpose: master un-tar command
476#D-* Examples:
477#D-
478function IGCM_sys_UnTar {
479    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
480    if ( $DEBUG_sys ) ; then
481        echo "IGCM_sys_UnTar :" $@
482    fi
483    \tar xvf $1
484    if [ $? -gt 0 ] ; then
485        echo "IGCM_sys_UnTar : erreur."
486        IGCM_debug_Exit "IGCM_sys_UnTar"
487    fi
488    IGCM_debug_PopStack "IGCM_sys_UnTar"
489}
490
491#D-#==================================================
492#D-function IGCM_sys_Qsub
493#D-* Purpose: Qsub new job
494#D-* Examples:
495#D-
496function IGCM_sys_Qsub {
497    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
498    if ( $DEBUG_sys ) ; then
499        echo "IGCM_sys_Qsub :" $@
500    fi
501    bsub -o ${Script_Output} -J ${config_UserChoices_JobName}.${CumulPeriod} < $1
502    if [ $? -gt 0 ] ; then
503        echo "IGCM_sys_Qsub : erreur " $@
504        IGCM_debug_Exit "IGCM_sys_Qsub"
505    fi
506    IGCM_debug_PopStack "IGCM_sys_Qsub"
507}
508
509#D-#==================================================
510#D-function IGCM_sys_QsubPost
511#D-* Purpose: Qsub new job on scalaire
512#D-* Examples:
513#D-
514function IGCM_sys_QsubPost {
515    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
516    if ( $DEBUG_sys ) ; then
517        echo "IGCM_sys_QsubPost :" $@
518    fi
519    bsub -o ${POST_DIR}/${Script_Post_Output}.out < ${libIGCM_POST}/$1.job
520    if [ $? -gt 0 ] ; then
521        echo "IGCM_sys_QsubPost : erreur " $@
522        IGCM_debug_Exit "IGCM_sys_QsubPost"
523    fi
524    IGCM_debug_PopStack "IGCM_sys_QsubPost"
525}
526
527#D-*************************
528#D- File transfer functions
529#D-*************************
530#D-
531
532#D-#==================================================
533#D-function IGCM_sys_Rsync_out
534#D-* Purpose: treat return val of rsync
535#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
536#D-  Error values and explanations can depend on your system version.
537function IGCM_sys_Rsync_out {
538    RET=$1
539    if [ ! $RET ] ; then
540        echo "rsync error !"
541    fi
542
543    if [ $MYLANG = "fr" ]; then
544        case $RET in
545            0)  return ;;
546            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
547                echo "Erreur de syntaxe ou d'utilisation."
548                return;;
549            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
550                echo "Incompatibilité de protocole."
551                return;;
552            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
553                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
554                echo "répertoires"
555                return;;
556            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
557                echo "Action demandée non supportée : une tentative de manipulation de"
558                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
559                echo "été faite ; ou une option qui est supportée par le  client  mais"
560                echo "pas par le serveur a été spécifiée."
561                return;;
562            10) echo "Erreur de rsync ; RERR_SOCKETIO"
563                echo "Erreur dans le socket d'entrée sortie"
564                return;;
565            11) echo "Erreur de rsync ; RERR_FILEIO"
566                echo "Erreur d'entrée sortie fichier"
567                return;;
568            12) echo "Erreur de rsync ; RERR_STREAMIO"
569                echo "Erreur dans flux de donnée du protocole rsync"
570                return;;
571            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
572                echo "Erreur avec les diagnostics du programme"
573                return;;
574            14) echo "Erreur de rsync ; RERR_IPC"
575                echo "Erreur dans le code IPC"
576                return;;
577            20) echo "Erreur de rsync ; RERR_SIGNAL"
578                echo "SIGUSR1 ou SIGINT reçu"
579                return;;
580            21) echo "Erreur de rsync ; RERR_WAITCHILD"
581                echo "Une erreur retournée par waitpid()"
582                return;;
583            22) echo "Erreur de rsync ; RERR_MALLOC"
584                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
585                return;;
586            23) echo ""
587                echo "Erreur fichier inexistant"
588                return;;
589            30) echo "Erreur de rsync ; RERR_TIMEOUT"
590                echo "Temps d'attente écoulé dans l'envoi/réception de données"
591                return;;
592            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
593                return;;
594        esac
595    elif [ $MYLANG = "en" ] ; then
596        case $RET in
597            0)  return;;               
598            1)  echo "rsync error : Syntax or usage error "
599                return;;
600            2)  echo "rsync error : Protocol incompatibility "
601                return;;
602            3)  echo "rsync error : Errors selecting input/output files, dirs"
603                return;;
604            4)  echo "rsync error : Requested action not supported: an attempt"
605                echo "was made to manipulate 64-bit files on a platform that cannot support"
606                echo "them; or an option was specified that is supported by the client and"
607                echo "not by the server."
608                return;;
609            5)  echo "rsync error : Error starting client-server protocol"
610                return;;
611            10) echo "rsync error : Error in socket I/O "
612                return;;
613            11) echo "rsync error : Error in file I/O "
614                return;;
615            12) echo "rsync error : Error in rsync protocol data stream "
616                return;;
617            13) echo "rsync error : Errors with program diagnostics "
618                return;;
619            14) echo "rsync error : Error in IPC code "
620                return;;
621            20) echo "rsync error : Received SIGUSR1 or SIGINT "
622                return;;
623            21) echo "rsync error : Some error returned by waitpid() "
624                return;;
625            22) echo "rsync error : Error allocating core memory buffers "
626                return;;
627            23) echo "rsync error : Partial transfer due to error"
628                return;;
629            24) echo "rsync error : Partial transfer due to vanished source files"
630                return;;
631            30) echo "rsync error : Timeout in data send/receive "
632                return;;
633            *)  echo "rsync error : return code of rsync unknown :" $RET
634                return;;
635        esac
636    else
637        echo "unknown language $MYLANG."
638        return
639    fi
640}
641   
642#D-#==================================================
643#D-function IGCM_sys_Cp
644#D-* Purpose: generic cp
645#D-* Examples:
646#D-
647function IGCM_sys_Cp {
648    IGCM_debug_PushStack "IGCM_sys_Cp" $@
649    if ( $DEBUG_sys ) ; then
650        echo "IGCM_sys_Cp :" $@
651    fi
652
653    typeset RET
654
655    echo cp $@ > out_rsync 2>&1
656    \cp $@ >> out_rsync 2>&1
657    RET=$?
658
659    if [ ${RET} -gt 0 ] ; then
660        echo "IGCM_sys_Cp : error."
661        cat out_rsync
662        IGCM_debug_Exit "IGCM_sys_Cp"
663     else
664         \rm out_rsync
665    fi
666    IGCM_debug_PopStack "IGCM_sys_Cp"
667}
668
669#D-#==================================================
670#D-function IGCM_sys_Rm
671#D-* Purpose: generic rm
672#D-* Examples:
673#D-
674function IGCM_sys_Rm {
675    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
676    if ( $DEBUG_sys ) ; then
677        echo "IGCM_sys_Rm :" $@
678    fi
679
680    typeset RET
681
682    echo rm $@ > out_rsync 2>&1
683    \rm $@ >> out_rsync 2>&1
684    RET=$?
685
686    if [ ${RET} -gt 0 ] ; then
687        echo "IGCM_sys_Rm : error."
688        cat out_rsync
689        IGCM_debug_Exit "IGCM_sys_Rm"
690    else
691        \rm out_rsync
692    fi
693    IGCM_debug_PopStack "IGCM_sys_Rm"
694}
695
696#D-#==================================================
697#D-function IGCM_sys_RmRunDir
698#D-* Purpose: rm tmpdir (dummy function most of the time batch
699#D-                      scheduler will do the job)
700#D-* Examples:
701#D-
702function IGCM_sys_RmRunDir {
703    IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
704    if ( $DEBUG_sys ) ; then
705        echo "IGCM_sys_RmRunDir :" $@
706        echo "Dummy call, let the scheduler do that."
707    fi
708    IGCM_debug_PopStack "IGCM_sys_RmRunDir"
709}
710
711#D-#==================================================
712#D-function IGCM_sys_Mv
713#D-* Purpose: generic move
714#D-* Examples:
715#D-
716function IGCM_sys_Mv {
717    IGCM_debug_PushStack "IGCM_sys_Mv" $@
718    if ( $DEBUG_sys ) ; then
719        echo "IGCM_sys_Mv :" $@
720    fi
721
722    if [ $DRYRUN = 0 ]; then
723
724        typeset RET
725           
726        echo mv $@ > out_rsync 2>&1
727        \mv $@ >> out_rsync 2>&1
728        RET=$?
729   
730        if [ ${RET} -gt 0 ] ; then
731            echo "IGCM_sys_Mv : error in mv."
732            cat out_rsync
733            IGCM_debug_Exit "IGCM_sys_Mv"
734        else
735            \rm out_rsync
736        fi
737    else
738        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
739    fi
740
741    IGCM_debug_PopStack "IGCM_sys_Mv"
742}
743
744#D-#==================================================
745#D-function IGCM_sys_Put_Dir
746#D-* Purpose: Copy a complete directory on $(ARCHIVE)
747#D-* Examples:
748#D-
749function IGCM_sys_Put_Dir {
750    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
751    if ( $DEBUG_sys ) ; then
752        echo "IGCM_sys_Put_Dir :" $@
753    fi
754    if [ $DRYRUN = 0 ]; then
755        if [ ! -d ${1} ] ; then
756            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
757            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
758            return
759        fi
760
761        typeset RET
762
763        # Only if we use rsync
764        #IGCM_sys_TestDirArchive $( dirname $2 )
765        #
766        #USUAL WAY
767        \cp -r $1 $2 > out_rsync 2>&1
768        RET=$?
769
770        if [ ${RET} -gt 0 ] ; then
771            echo "IGCM_sys_Put_Dir : error."
772            cat out_rsync
773            IGCM_debug_Exit "IGCM_sys_Put_Dir"
774        else
775            \rm out_rsync
776        fi
777    else
778        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
779    fi
780    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
781}
782
783#D-#==================================================
784#D-function IGCM_sys_Get_Dir
785#D-* Purpose: Copy a complete directory from $(ARCHIVE)
786#D-* Examples:
787#D-
788function IGCM_sys_Get_Dir {
789    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
790    if ( $DEBUG_sys ) ; then
791        echo "IGCM_sys_Get_Dir :" $@
792    fi
793    if [ $DRYRUN = 0 ]; then
794#       if [ ! -d ${1} ] ; then
795#           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
796#           IGCM_debug_PopStack "IGCM_sys_Get_Dir"
797#           return
798#       fi
799
800        typeset RET
801
802        # Only if we use rsync
803        #IGCM_sys_TestDirArchive $( dirname $2 )
804        #
805        #USUAL WAY
806        \cp -r $1 $2 > out_rsync 2>&1
807        RET=$?
808
809        if [ ${RET} -gt 0 ] ; then
810            echo "IGCM_sys_Get_Dir : error."
811            cat out_rsync
812            IGCM_debug_Exit "IGCM_sys_Get_Dir"
813        else
814            \rm out_rsync
815        fi
816    else
817        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
818    fi
819    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
820}
821
822#D-#==================================================
823#D-function IGCM_sys_Get_Master
824#D-* Purpose: Copy a complete directory from MASTER filesystem
825#D-* Examples:
826#D-
827function IGCM_sys_Get_Master {
828    IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
829    if ( $DEBUG_sys ) ; then
830        echo "IGCM_sys_Get_Master :" $@
831    fi
832    if [ $DRYRUN = 0 ]; then
833        if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then
834            echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
835            IGCM_debug_PopStack "IGCM_sys_Get_Master"
836            return
837        fi
838
839        typeset RET
840
841        #USUAL WAY
842        \cp -r $1 $2 > out_rsync 2>&1
843        RET=$?
844
845        if [ ${RET} -gt 0 ] ; then
846            echo "IGCM_sys_Get_Master : error."
847            cat out_rsync
848            IGCM_debug_Exit "IGCM_sys_Get_Master"
849        fi
850    else
851        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
852    fi
853    IGCM_debug_PopStack "IGCM_sys_Get_Master"
854}
855
856#D-#==================================================
857#D-function IGCM_sys_Put_Rest
858#D-* Purpose: Put computied restarts on $(ARCHIVE).
859#D-           File and target directory must exist.
860#D-* Examples:
861#D-
862function IGCM_sys_Put_Rest {
863    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
864    if ( $DEBUG_sys ) ; then
865        echo "IGCM_sys_Put_Rest :" $@
866    fi
867    if [ $DRYRUN = 0 ]; then
868        if [ ! -f ${1} ] ; then
869            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
870            IGCM_debug_Exit "IGCM_sys_Put_Rest"
871        fi
872
873        typeset RET
874        #
875        if [ X${JobType} = XRUN ] ; then
876            IGCM_sys_Chmod 444 ${1}
877        fi
878        #
879        IGCM_sys_TestDirArchive $( dirname $2 )
880        #
881        # USUAL WAY
882        putfer $1 $2 > out_rsync 2>&1
883        RET=$?
884
885#       #RSYNC WITH NETWORK RSH CALL
886#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
887#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
888
889#       #RSYNC WITH NFS USE
890#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
891#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
892
893#       RET=$?
894#       IGCM_sys_Rsync_out $RET
895
896#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
897#       (( RET=RET+$? ))
898
899        if [ ${RET} -gt 0 ] ; then
900            echo "IGCM_sys_Put_Rest : error."
901            cat out_rsync
902            IGCM_debug_Exit "IGCM_sys_Put_Rest"
903        else
904            \rm out_rsync
905        fi
906    else
907        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
908    fi
909    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
910}
911
912#D-#==================================================
913#D-function IGCM_sys_Put_Out
914#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
915#D-* Examples:
916#D-
917function IGCM_sys_Put_Out {
918    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
919    if ( $DEBUG_sys ) ; then
920        echo "IGCM_sys_Put_Out :" $@
921    fi
922    if [ $DRYRUN = 0 ]; then
923        if [ ! -f ${1} ] ; then
924            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
925            IGCM_debug_PopStack "IGCM_sys_Put_Out"
926            return 1
927        fi
928        #
929        IGCM_sys_MkdirArchive $( dirname $2 )
930        #
931        typeset RET
932        #
933        if [ X${JobType} = XRUN ] ; then
934            if [ X${3} = X ] ; then
935                IGCM_sys_Chmod 444 ${1}
936            fi
937        fi
938        #
939        # USUAL WAY
940        putfer $1 $2 > out_rsync 2>&1
941        RET=$?
942
943#       #RSYNC WITH NETWORK RSH CALL
944#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
945#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
946
947#       #RSYNC WITH NFS USE
948#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
949#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
950
951#       RET=$?
952#       IGCM_sys_Rsync_out $RET
953
954#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
955#       (( RET=RET+$? ))
956
957        if [ ${RET} -gt 0 ] ; then
958            echo "IGCM_sys_Put_Out : error."
959            cat out_rsync
960            IGCM_debug_Exit "IGCM_sys_Put_Out"
961        else
962            \rm out_rsync
963        fi
964    else
965        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
966    fi
967    IGCM_debug_PopStack "IGCM_sys_Put_Out"
968    return 0
969}
970
971#D-#==================================================
972#D-function IGCM_sys_Get
973#D-* Purpose: Get a file from ${ARCHIVE}
974#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
975#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
976function IGCM_sys_Get {
977    IGCM_debug_PushStack "IGCM_sys_Get" $@
978
979    typeset DEST RET dm_liste ifile target file_work
980
981    if ( $DEBUG_sys ) ; then
982        echo "IGCM_sys_Get :" $@
983    fi
984    if [ $DRYRUN -le 2 ]; then
985        if [ X${1} = X'/l' ] ; then
986            # test if the first file is present in the old computation :
987            eval set +A dm_liste \${${2}}
988        else
989            eval set +A dm_liste ${1}
990        fi
991        eval DEST=\${${#}}
992
993        #=====================================================
994        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
995        #=====================================================
996
997        # Is it an R_OUT file (not R_IN) ?
998        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
999        #if [ $? -eq 0 ] ; then
1000        #    # Yes  ? then we try to get it in SCRATCHDIR
1001        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
1002        #    if [ -f ${file_work[0]} ] ; then
1003        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
1004        #       IGCM_debug_PopStack "IGCM_sys_Get"
1005        #       return
1006        #    fi
1007        #fi
1008
1009        # test if the (first) file is present in the old computation :
1010        IGCM_sys_TestFileArchive ${dm_liste[0]}
1011        RET=$?
1012        if [ ${RET} -gt 0 ] ; then
1013            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1014            IGCM_debug_Exit "IGCM_sys_Get"
1015            #IGCM_debug_PopStack "IGCM_sys_Get"
1016            #return
1017        fi
1018
1019#       dmget ${dm_liste[*]} > out_rsync 2>&1
1020#       RET=$?
1021#       if [ ${RET} -gt 0 ] ; then
1022#           echo "IGCM_sys_Get : demigration error."
1023#           cat out_rsync
1024#           IGCM_debug_Exit "IGCM_sys_Get"
1025#           IGCM_debug_PopStack "IGCM_sys_Get"
1026#           return
1027#       fi
1028
1029        #USUAL WAY
1030        (( RET=0 ))
1031        if [ X${1} = X'/l' ] ; then
1032            (( RET=0 ))
1033            for target in ${dm_liste[*]} ; do
1034                local_file=$( basename ${target} )
1035                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1036                (( RET = RET + $? ))
1037            done
1038        else
1039            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1040            RET=$?
1041        fi
1042
1043#       #RSYNC WITH NETWORK RSH CALL
1044#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1045#       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1046
1047#       #RSYNC WITH NFS USE
1048#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1049#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1050
1051#       RET=$?
1052#       IGCM_sys_Rsync_out $RET
1053
1054#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1055#       (( RET=RET+$? ))
1056
1057        if [ ${RET} -gt 0 ] ; then
1058            echo "IGCM_sys_Get : copy error."
1059            cat out_rsync
1060            IGCM_debug_Exit "IGCM_sys_Get"
1061        else
1062            \rm out_rsync
1063        fi
1064    else
1065        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1066    fi
1067    IGCM_debug_PopStack "IGCM_sys_Get"
1068}
1069
1070#D-#==================================================
1071#D-function IGCM_sys_Dods_Rm
1072#D-* Purpose: DO NOTHING ! Put $(ARCHIVE) files on DODS internet protocole.
1073#D-* Examples:
1074#D-
1075function IGCM_sys_Dods_Rm {
1076    if ( $DEBUG_sys ) ; then
1077        echo "IGCM_sys_Dods_Rm :" $@
1078    fi
1079    typeset RET
1080    RET=0
1081    if [ $DRYRUN = 0 ]; then
1082        if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
1083            echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
1084            echo "Nothing has been done."
1085            return
1086        fi
1087        dods_rm public/${LOGIN}/${R_DODS}/${1} #> out_dods_rm 2>&1
1088        RET=$?
1089       
1090#       if [ ${RET} -gt 0 ] ; then
1091#           echo "IGCM_sys_Put_Dods : error."
1092#           cat out_dods_rm
1093#           IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1094#       else
1095#           rm out_dods_rm
1096#       fi
1097
1098    else
1099        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1100    fi
1101    return $RET
1102}
1103
1104
1105#D-#==================================================
1106#D-function IGCM_sys_Dods_Cp
1107#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1108#D-* Examples:
1109#D-
1110function IGCM_sys_Dods_Cp {
1111    if ( $DEBUG_sys ) ; then
1112        echo "IGCM_sys_Dods_Cp :" $@
1113    fi
1114    typeset RET
1115    RET=0
1116    if [ $DRYRUN = 0 ]; then
1117        if [ ! -d ${R_SAVE}/${1} ] ; then
1118            echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1119            echo "Nothing has been done."
1120            return
1121        fi
1122        #
1123        dods_cp ${1} public/${LOGIN}/${R_DODS} #> out_dods_cp 2>&1
1124        RET=$?
1125       
1126#       if [ ${RET} -gt 0 ] ; then
1127#           echo "IGCM_sys_Dods_Cp : error."
1128#           cat out_dods_cp
1129#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1130#       else
1131#           rm out_dods_cp
1132#       fi
1133
1134    else
1135        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1136    fi
1137    return $RET
1138}
1139
1140#D-#==================================================
1141#D-function IGCM_sys_Put_Dods
1142#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1143#D-* Examples:
1144#D-
1145function IGCM_sys_Put_Dods {
1146    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1147    if ( $DEBUG_sys ) ; then
1148        echo "IGCM_sys_Put_Dods :" $@
1149    fi
1150    if [ $DRYRUN = 0 ]; then
1151        if [ ! -d ${R_SAVE}/${1} ] ; then
1152            echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
1153            IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1154            return
1155        fi
1156
1157        typeset RET
1158        #
1159        cd ${R_SAVE}
1160        IGCM_sys_Dods_Rm ${1}
1161        IGCM_sys_Dods_Cp ${1}
1162        RET=0
1163
1164        if [ ${RET} -gt 0 ] ; then
1165            echo "IGCM_sys_Put_Dods : error."
1166            IGCM_debug_Exit "IGCM_sys_Put_Dods"
1167        fi
1168    else
1169        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1170    fi
1171    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1172}
1173
1174############################################################## A FINIR !!
1175
1176#D-#==================================================
1177#D-function IGCM_sys_GetDate_FichWork
1178#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1179#D-* Examples:
1180#D-
1181function IGCM_sys_GetDate_FichWork {
1182    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1183    if ( $DEBUG_sys ) ; then
1184        echo "IGCM_sys_GetDate_FichWork :" $@
1185    fi
1186    # donne la date filesys d'un fichier sur la machine work
1187    IGCM_debug_PopStack "IGCM_sys_FichWork"
1188}
1189
1190#D-#==================================================
1191#D-function IGCM_sys_GetDate_FichArchive
1192#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1193#D-* Examples:
1194#D-
1195function IGCM_sys_GetDate_FichArchive {
1196    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1197    if ( $DEBUG_sys ) ; then
1198        echo "IGCM_sys_GetDate_FichArchive :" $@
1199    fi
1200    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1201}
1202
1203##############################################################
1204# REBUILD OPERATOR
1205
1206function IGCM_sys_rebuild {
1207    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1208    if ( $DEBUG_sys ) ; then
1209        echo "IGCM_sys_rebuild :" $@
1210    fi
1211    /home/cont003/p86ipsl/IA64/bin/rebuild -f -o $@
1212    if [ $? -gt 0 ] ; then
1213       echo "IGCM_sys_rebuild : erreur ${@}."
1214       IGCM_debug_Exit "rebuild"
1215    fi
1216
1217    IGCM_debug_PopStack "IGCM_sys_rebuild"
1218}
1219
1220##############################################################
1221# NCO OPERATOR
1222
1223function IGCM_sys_ncap2 {
1224    IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1225    if ( $DEBUG_sys ) ; then
1226        echo "IGCM_sys_ncap2 :" $@
1227    fi
1228    /applications/nco/bin/ncap2 "$@"
1229    if [ $? -gt 0 ] ; then
1230       echo "IGCM_sys_ncap2 : erreur ${@}."
1231       IGCM_debug_Exit "ncap2"
1232    fi
1233
1234    IGCM_debug_PopStack "IGCM_sys_ncap2"
1235}
1236
1237function IGCM_sys_ncatted {
1238    IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1239    if ( $DEBUG_sys ) ; then
1240        echo "IGCM_sys_ncatted :" $@
1241    fi
1242    /usr/local/bin/ncatted "$@"
1243    if [ $? -gt 0 ] ; then
1244       echo "IGCM_sys_ncatted : erreur ${@}."
1245       IGCM_debug_Exit "ncatted"
1246    fi
1247
1248    IGCM_debug_PopStack "IGCM_sys_ncatted"
1249}
1250
1251function IGCM_sys_ncbo {
1252    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1253    if ( $DEBUG_sys ) ; then
1254        echo "IGCM_sys_ncbo :" $@
1255    fi
1256    /applications/nco/bin/ncbo $@
1257    if [ $? -gt 0 ] ; then
1258       echo "IGCM_sys_ncbo : erreur ${@}."
1259       IGCM_debug_Exit "ncbo"
1260    fi
1261
1262    IGCM_debug_PopStack "IGCM_sys_ncbo"
1263}
1264
1265function IGCM_sys_ncdiff {
1266    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1267    if ( $DEBUG_sys ) ; then
1268        echo "IGCM_sys_ncdiff :" $@
1269    fi
1270    /applications/nco/bin/ncdiff $@
1271    if [ $? -gt 0 ] ; then
1272       echo "IGCM_sys_ncdiff : erreur ${@}."
1273       IGCM_debug_Exit "ncdiff"
1274    fi
1275
1276    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1277}
1278
1279function IGCM_sys_ncea {
1280    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1281    if ( $DEBUG_sys ) ; then
1282        echo "IGCM_sys_ncea :" $@
1283    fi
1284    /applications/nco/bin/ncea $@
1285    if [ $? -gt 0 ] ; then
1286       echo "IGCM_sys_ncea : erreur ${@}."
1287       IGCM_debug_Exit "ncea"
1288    fi
1289
1290    IGCM_debug_PopStack "IGCM_sys_ncea"
1291}
1292
1293function IGCM_sys_ncecat {
1294    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1295    if ( $DEBUG_sys ) ; then
1296        echo "IGCM_sys_ncecat :" $@
1297    fi
1298    /applications/nco/bin/ncecat $@
1299    if [ $? -gt 0 ] ; then
1300       echo "IGCM_sys_ncecat : erreur ${@}."
1301       IGCM_debug_Exit "ncecat"
1302    fi
1303
1304    IGCM_debug_PopStack "IGCM_sys_ncecat"
1305}
1306
1307function IGCM_sys_ncflint {
1308    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1309    if ( $DEBUG_sys ) ; then
1310        echo "IGCM_sys_ncflint :" $@
1311    fi
1312    /usr/local/bin/ncflint $@
1313    if [ $? -gt 0 ] ; then
1314       echo "IGCM_sys_ncflint : erreur ${@}."
1315       IGCM_debug_Exit "ncflint"
1316    fi
1317
1318    IGCM_debug_PopStack "IGCM_sys_ncflint"
1319}
1320
1321function IGCM_sys_ncks {
1322    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1323    if ( $DEBUG_sys ) ; then
1324        echo "IGCM_sys_ncks :" $@
1325    fi
1326    /applications/nco/bin/ncks $@
1327    if [ $? -gt 0 ] ; then
1328       echo "IGCM_sys_ncks : erreur ${@}."
1329       IGCM_debug_Exit "ncks"
1330    fi
1331
1332    IGCM_debug_PopStack "IGCM_sys_ncks"
1333}
1334
1335function IGCM_sys_ncpdq {
1336    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1337    if ( $DEBUG_sys ) ; then
1338        echo "IGCM_sys_ncpdq :" $@
1339    fi
1340    /applications/nco/bin/ncpdq $@
1341    if [ $? -gt 0 ] ; then
1342       echo "IGCM_sys_ncpdq : erreur ${@}."
1343       IGCM_debug_Exit "ncpdq"
1344    fi
1345
1346    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1347}
1348
1349function IGCM_sys_ncra {
1350    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1351    if ( $DEBUG_sys ) ; then
1352        echo "IGCM_sys_ncra :" $@
1353    fi
1354    /applications/nco/bin/ncra $@
1355    if [ $? -gt 0 ] ; then
1356       echo "IGCM_sys_ncra : erreur ${@}."
1357       IGCM_debug_Exit "ncra"
1358    fi
1359
1360    IGCM_debug_PopStack "IGCM_sys_ncra"
1361}
1362
1363function IGCM_sys_ncrcat {
1364    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1365    if ( $DEBUG_sys ) ; then
1366        echo "IGCM_sys_ncrcat :" $@
1367    fi
1368    /applications/nco/bin/ncrcat $@
1369    if [ $? -gt 0 ] ; then
1370       echo "IGCM_sys_ncrcat : erreur ${@}."
1371#       IGCM_debug_Exit "ncrcat"
1372    fi
1373
1374    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1375}
1376
1377function IGCM_sys_ncrename {
1378    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1379    if ( $DEBUG_sys ) ; then
1380        echo "IGCM_sys_ncrename :" $@
1381    fi
1382    /applications/nco/bin/ncrename $@
1383    if [ $? -gt 0 ] ; then
1384       echo "IGCM_sys_ncrename : erreur ${@}."
1385       IGCM_debug_Exit "ncrename"
1386    fi
1387
1388    IGCM_debug_PopStack "IGCM_sys_ncrename"
1389}
1390
1391function IGCM_sys_ncwa {
1392    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1393    if ( $DEBUG_sys ) ; then
1394        echo "IGCM_sys_ncwa :" $@
1395    fi
1396    /applications/nco/bin/ncwa $@
1397    if [ $? -gt 0 ] ; then
1398       echo "IGCM_sys_ncwa : erreur ${@}."
1399       IGCM_debug_Exit "ncwa"
1400    fi
1401
1402    IGCM_debug_PopStack "IGCM_sys_ncwa"
1403}
1404
1405##############################################################
1406# CDO OPERATOR
1407
1408function IGCM_sys_cdo {
1409    IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1410
1411    \cdo $@
1412    if [ $? -gt 0 ] ; then
1413        echo "IGCM_sys_cdo : erreur ${@}."
1414        IGCM_debug_PopStack "IGCM_sys_cdo"
1415        return 1
1416    else
1417        IGCM_debug_PopStack "IGCM_sys_cdo"
1418        return 0
1419    fi
1420
1421    IGCM_debug_PopStack "IGCM_sys_cdo"
1422}
1423
1424############################################################
1425# Activate Running Environnment Variables
1426
1427function IGCM_sys_activ_variables {
1428    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1429    if ( $DEBUG_sys ) ; then
1430        echo "IGCM_sys_activ_variables"
1431    fi
1432    ulimit -s 2097152
1433    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1434}
1435
1436############################################################
1437# Desactivate Running Environnment Variables
1438
1439function IGCM_sys_desactiv_variables {
1440    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1441    if ( $DEBUG_sys ) ; then
1442        echo "IGCM_sys_desactiv_variables"
1443    fi
1444    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1445}
1446
1447############################################################
1448# Build run file
1449
1450function IGCM_sys_build_run_file {
1451    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1452    if ( $DEBUG_sys ) ; then
1453        echo "IGCM_sys_build_run_file " $@
1454    fi
1455    NUM_PROC_OCE=1
1456    (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE - 1))
1457    (( nb_tot_m1    = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE ))
1458    if [ $1 = MPI1 ]; then
1459        cat <<EOF > run_file
1460#!/bin/bash
1461if [ \$SLURM_PROCID -eq 0 ]
1462  then ./oasis ;
1463elif ( [ \$SLURM_PROCID -ge 1 ] && [ \$SLURM_PROCID -lt ${nb_tot_m1} ] )
1464  then ./lmdz.x ;
1465else ./opa.xx ;
1466fi
1467EOF
1468        config_UserChoices_JobRunOptions='"-n ${BATCH_NUM_PROC_TOT}"'
1469        IGCM_sys_Chmod u+x run_file
1470    fi
1471    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1472 
1473}
1474
1475############################################################
1476# Check of space available on temporary filesytems
1477function IGCM_sys_check_quota {
1478    IGCM_debug_PushStack "IGCM_sys_check_quota"
1479    if ( $DEBUG_sys ) ; then
1480        echo "IGCM_sys_check_quota"
1481    fi
1482    IGCM_debug_PopStack "IGCM_sys_check_quota"
1483}
Note: See TracBrowser for help on using the repository browser.