source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh @ 409

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