source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh @ 459

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