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

Last change on this file since 456 was 456, checked in by aclsce, 13 years ago

For obelix machine (i.e in libIGCM_sys_obelix.ksh), replaced rebuild by path of rebuild command :
/home/users/igcmg/rebuild/bin/rebuild

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