source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh @ 465

Last change on this file since 465 was 463, checked in by mafoipsl, 13 years ago

Delete useless sleep.

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