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

Last change on this file since 437 was 437, checked in by sdipsl, 13 years ago

Send mail notification when computing job stops
It could be that we send a notification if a post-processing job stops in PROD mode ---> need some refactoring and caution...

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