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

Last change on this file since 434 was 434, checked in by mmaipsl, 13 years ago

correct a typo in Message send by mail.

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