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

Last change on this file since 360 was 360, checked in by sdipsl, 14 years ago

Correct bad side effect

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