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

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

R_IN_ECMWF was not define like it should

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