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

Last change on this file since 453 was 453, checked in by sdipsl, 13 years ago
  • Continuation of [452] and cleaning
  • Property svn:keywords set to Revision Author Date
File size: 38.7 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        sleep 10
815
816        #USUAL WAY
817        \cp -r $1 $2 > out_rsync 2>&1
818        RET=$?
819
820        if [ ${RET} -gt 0 ] ; then
821            echo "IGCM_sys_Get_Master : error."
822            cat out_rsync
823            IGCM_debug_Exit "IGCM_sys_Get_Master"
824        else
825            \rm out_rsync
826        fi
827    else
828        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
829    fi
830    IGCM_debug_PopStack "IGCM_sys_Get_Master"
831}
832
833#D-#==================================================
834#D-function IGCM_sys_Put_Rest
835#D-* Purpose: Put computied restarts on $(ARCHIVE).
836#D-           File and target directory must exist.
837#D-* Examples:
838#D-
839function IGCM_sys_Put_Rest {
840    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
841    if ( $DEBUG_sys ) ; then
842        echo "IGCM_sys_Put_Rest :" $@
843    fi
844    if [ $DRYRUN = 0 ]; then
845        if [ ! -f ${1} ] ; then
846            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
847            IGCM_debug_Exit "IGCM_sys_Put_Rest"
848        fi
849
850        typeset RET
851        #
852        if [ X${JobType} = XRUN ] ; then
853            IGCM_sys_Chmod 444 ${1}
854        fi
855        #
856        IGCM_sys_TestDirArchive $( dirname $2 )
857        #
858        # USUAL WAY
859        putfer $1 $2 > out_rsync 2>&1
860        RET=$?
861
862#       #RSYNC WITH NETWORK SSH CALL
863#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
864#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
865
866#       #RSYNC WITH NFS USE
867#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
868#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
869
870#       RET=$?
871#       IGCM_sys_Rsync_out $RET
872
873#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
874#       (( RET=RET+$? ))
875
876        if [ ${RET} -gt 0 ] ; then
877            echo "IGCM_sys_Put_Rest : error."
878            cat out_rsync
879            IGCM_debug_Exit "IGCM_sys_Put_Rest"
880        else
881            \rm out_rsync
882        fi
883    else
884        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
885    fi
886    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
887}
888
889#D-#==================================================
890#D-function IGCM_sys_Put_Out
891#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
892#D-* Examples:
893#D-
894function IGCM_sys_Put_Out {
895    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
896    if ( $DEBUG_sys ) ; then
897        echo "IGCM_sys_Put_Out :" $@
898    fi
899    if [ $DRYRUN = 0 ]; then
900        if [ ! -f ${1} ] ; then
901            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
902            IGCM_debug_PopStack "IGCM_sys_Put_Out"
903            return 1
904        fi
905        #
906        IGCM_sys_MkdirArchive $( dirname $2 )
907        #
908        typeset RET exist skip
909        #
910        if [ X${JobType} = XRUN ] ; then
911            if [ X${3} = X ] ; then
912                IGCM_sys_Chmod 444 ${1}
913            fi
914        fi
915
916        exist=false
917        skip=false
918        if [ -f $2 ] ; then
919            IGCM_debug_Print 1 "$2 already exist"
920            dmget $2
921            exist=true
922            if [ "X$( diff $1 $2 )" = X ] ; then
923                IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
924                skip=true
925            else
926                IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
927                skip=false
928            fi
929        fi
930        #
931        if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
932            IGCM_sys_Chmod u+w $2
933        fi
934        # USUAL WAY
935        if [ X${skip} = Xfalse ] ; then
936            \cp $1 $2 > out_rsync 2>&1
937            RET=$?
938            if [ ${RET} -gt 0 ] ; then
939                echo "IGCM_sys_Put_Out : error."
940                cat out_rsync
941                IGCM_debug_Exit "IGCM_sys_Put_Out"
942            else
943                \rm out_rsync
944            fi
945        fi
946
947#       #RSYNC WITH NETWORK RSH CALL
948#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
949#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
950
951#       #RSYNC WITH NFS USE
952#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
953#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
954
955#       RET=$?
956#       IGCM_sys_Rsync_out $RET
957
958#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
959#       (( RET=RET+$? ))
960
961    else
962        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
963    fi
964    IGCM_debug_PopStack "IGCM_sys_Put_Out"
965    return 0
966}
967
968#D-#==================================================
969#D-function IGCM_sys_Get
970#D-* Purpose: Get a file from ${ARCHIVE}
971#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
972#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
973function IGCM_sys_Get {
974    IGCM_debug_PushStack "IGCM_sys_Get" $@
975
976    typeset DEST RET dm_liste ifile target file_work
977
978    if ( $DEBUG_sys ) ; then
979        echo "IGCM_sys_Get :" $@
980    fi
981    if [ $DRYRUN -le 2 ]; then
982        if [ X${1} = X'/l' ] ; then
983            # test if the first file is present in the old computation :
984            eval set +A dm_liste \${${2}}
985        else
986            eval set +A dm_liste ${1}
987        fi
988        eval DEST=\${${#}}
989
990        #=====================================================
991        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
992        #=====================================================
993
994        # Is it an R_OUT file (not R_IN) ?
995        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
996        #if [ $? -eq 0 ] ; then
997        #    # Yes  ? then we try to get it in SCRATCHDIR
998        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
999        #    if [ -f ${file_work[0]} ] ; then
1000        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
1001        #       IGCM_debug_PopStack "IGCM_sys_Get"
1002        #       return
1003        #    fi
1004        #fi
1005
1006        # test if the (first) file is present in the old computation :
1007        IGCM_sys_TestFileArchive ${dm_liste[0]}
1008        RET=$?
1009        if [ ${RET} -gt 0 ] ; then
1010            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1011            IGCM_debug_Exit "IGCM_sys_Get"
1012            #IGCM_debug_PopStack "IGCM_sys_Get"
1013            #return
1014        fi
1015
1016        dmget ${dm_liste[*]} > out_rsync 2>&1
1017        RET=$?
1018        if [ ${RET} -gt 0 ] ; then
1019            echo "WARNING IGCM_sys_Get : demigration error."
1020            cat out_rsync
1021            #IGCM_debug_Exit "IGCM_sys_Get"
1022            #IGCM_debug_PopStack "IGCM_sys_Get"
1023            #return
1024        fi
1025
1026        #USUAL WAY
1027        (( RET=0 ))
1028        if [ X${1} = X'/l' ] ; then
1029            (( RET=0 ))
1030            for target in ${dm_liste[*]} ; do
1031                local_file=$( basename ${target} )
1032                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1033                (( RET = RET + $? ))
1034            done
1035        else
1036            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1037            RET=$?
1038        fi
1039
1040#       #RSYNC WITH NETWORK RSH CALL
1041#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1042#       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1043
1044#       #RSYNC WITH NFS USE
1045#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1046#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1047
1048#       RET=$?
1049#       IGCM_sys_Rsync_out $RET
1050
1051#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1052#       (( RET=RET+$? ))
1053
1054        if [ ${RET} -gt 0 ] ; then
1055            echo "IGCM_sys_Get : copy error."
1056            cat out_rsync
1057#           IGCM_debug_Exit "IGCM_sys_Get"
1058        else
1059            \rm out_rsync
1060        fi
1061    else
1062        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1063    fi
1064    IGCM_debug_PopStack "IGCM_sys_Get"
1065}
1066
1067#D-#==================================================
1068#D-function IGCM_sys_Dods_Rm
1069#D-* Purpose: DO NOTHING ! Put $(ARCHIVE) files on DODS internet protocole.
1070#D-* Examples:
1071#D-
1072function IGCM_sys_Dods_Rm {
1073    if ( $DEBUG_sys ) ; then
1074        echo "IGCM_sys_Dods_Rm :" $@
1075    fi
1076    typeset RET
1077    RET=0
1078    if [ $DRYRUN = 0 ]; then
1079        if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
1080            echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
1081            echo "Nothing has been done."
1082            return
1083        fi
1084        dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
1085        RET=$?
1086       
1087#       if [ ${RET} -gt 0 ] ; then
1088#           echo "IGCM_sys_Dods_Rm : error."
1089#           cat out_dods_rm
1090#           IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1091#       else
1092#           rm out_dods_rm
1093#       fi
1094
1095    else
1096        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1097    fi
1098    return $RET
1099}
1100
1101
1102#D-#==================================================
1103#D-function IGCM_sys_Dods_Cp
1104#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1105#D-* Examples:
1106#D-
1107function IGCM_sys_Dods_Cp {
1108    if ( $DEBUG_sys ) ; then
1109        echo "IGCM_sys_Dods_Cp :" $@
1110    fi
1111    typeset RET
1112    RET=0
1113    if [ $DRYRUN = 0 ]; then
1114        if [ ! -d ${R_SAVE}/${1} ] ; then
1115            echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1116            echo "Nothing has been done."
1117            return
1118        fi
1119        #
1120        dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
1121        RET=$?
1122       
1123#       if [ ${RET} -gt 0 ] ; then
1124#           echo "IGCM_sys_Dods_Cp : error."
1125#           cat out_dods_cp
1126#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1127#       else
1128#           rm out_dods_cp
1129#       fi
1130
1131    else
1132        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1133    fi
1134    return $RET
1135}
1136
1137#D-#==================================================
1138#D-function IGCM_sys_Put_Dods
1139#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1140#D-* Examples:
1141#D-
1142function IGCM_sys_Put_Dods {
1143    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1144    if ( $DEBUG_sys ) ; then
1145        echo "IGCM_sys_Put_Dods :" $@
1146    fi
1147    if [ $DRYRUN = 0 ]; then
1148        if [ ! -d ${R_SAVE}/${1} ] ; then
1149            echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
1150            IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1151            return
1152        fi
1153
1154        typeset RET
1155        #
1156        cd ${R_SAVE}
1157        IGCM_sys_Dods_Rm ${1}
1158        IGCM_sys_Dods_Cp ${1}
1159        RET=0
1160       
1161        if [ ${RET} -gt 0 ] ; then
1162            echo "IGCM_sys_Put_Dods : error."
1163            IGCM_debug_Exit "IGCM_sys_Put_Dods"
1164        fi
1165    else
1166        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1167    fi
1168    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1169}
1170
1171############################################################## A FINIR !!
1172
1173#D-#==================================================
1174#D-function IGCM_sys_GetDate_FichWork
1175#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1176#D-* Examples:
1177#D-
1178function IGCM_sys_GetDate_FichWork {
1179    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1180    if ( $DEBUG_sys ) ; then
1181        echo "IGCM_sys_GetDate_FichWork :" $@
1182    fi
1183    # donne la date filesys d'un fichier sur la machine work
1184    IGCM_debug_PopStack "IGCM_sys_FichWork"
1185}
1186
1187#D-#==================================================
1188#D-function IGCM_sys_GetDate_FichArchive
1189#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1190#D-* Examples:
1191#D-
1192function IGCM_sys_GetDate_FichArchive {
1193    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1194    if ( $DEBUG_sys ) ; then
1195        echo "IGCM_sys_GetDate_FichArchive :" $@
1196    fi
1197    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1198}
1199
1200##############################################################
1201# REBUILD OPERATOR
1202
1203function IGCM_sys_rebuild {
1204    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1205    if ( $DEBUG_sys ) ; then
1206        echo "IGCM_sys_rebuild :" $@
1207    fi
1208    /home/cont003/p86ipsl/X86_64/bin/rebuild -f -o $@
1209    if [ $? -gt 0 ] ; then
1210       echo "IGCM_sys_rebuild : erreur ${@}."
1211       IGCM_debug_Exit "rebuild"
1212    fi
1213
1214    IGCM_debug_PopStack "IGCM_sys_rebuild"
1215}
1216
1217##############################################################
1218# NCO OPERATOR
1219
1220function IGCM_sys_ncap2 {
1221    IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1222    if ( $DEBUG_sys ) ; then
1223        echo "IGCM_sys_ncap2 :" $@
1224    fi
1225    ncap2 "$@"
1226    if [ $? -gt 0 ] ; then
1227       echo "IGCM_sys_ncap2 : erreur ${@}."
1228       IGCM_debug_Exit "ncap2"
1229    fi
1230
1231    IGCM_debug_PopStack "IGCM_sys_ncap2"
1232}
1233
1234function IGCM_sys_ncatted {
1235    IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1236    if ( $DEBUG_sys ) ; then
1237        echo "IGCM_sys_ncatted :" $@
1238    fi
1239    ncatted "$@"
1240    if [ $? -gt 0 ] ; then
1241       echo "IGCM_sys_ncatted : erreur ${@}."
1242       IGCM_debug_Exit "ncatted"
1243    fi
1244
1245    IGCM_debug_PopStack "IGCM_sys_ncatted"
1246}
1247
1248function IGCM_sys_ncbo {
1249    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1250    if ( $DEBUG_sys ) ; then
1251        echo "IGCM_sys_ncbo :" $@
1252    fi
1253    ncbo $@
1254    if [ $? -gt 0 ] ; then
1255       echo "IGCM_sys_ncbo : erreur ${@}."
1256       IGCM_debug_Exit "ncbo"
1257    fi
1258
1259    IGCM_debug_PopStack "IGCM_sys_ncbo"
1260}
1261
1262function IGCM_sys_ncdiff {
1263    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1264    if ( $DEBUG_sys ) ; then
1265        echo "IGCM_sys_ncdiff :" $@
1266    fi
1267    ncdiff $@
1268    if [ $? -gt 0 ] ; then
1269       echo "IGCM_sys_ncdiff : erreur ${@}."
1270       IGCM_debug_Exit "ncdiff"
1271    fi
1272
1273    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1274}
1275
1276function IGCM_sys_ncea {
1277    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1278    if ( $DEBUG_sys ) ; then
1279        echo "IGCM_sys_ncea :" $@
1280    fi
1281    ncea $@
1282    if [ $? -gt 0 ] ; then
1283       echo "IGCM_sys_ncea : erreur ${@}."
1284       IGCM_debug_Exit "ncea"
1285    fi
1286
1287    IGCM_debug_PopStack "IGCM_sys_ncea"
1288}
1289
1290function IGCM_sys_ncecat {
1291    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1292    if ( $DEBUG_sys ) ; then
1293        echo "IGCM_sys_ncecat :" $@
1294    fi
1295    ncecat $@
1296    if [ $? -gt 0 ] ; then
1297       echo "IGCM_sys_ncecat : erreur ${@}."
1298       IGCM_debug_Exit "ncecat"
1299    fi
1300
1301    IGCM_debug_PopStack "IGCM_sys_ncecat"
1302}
1303
1304function IGCM_sys_ncflint {
1305    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1306    if ( $DEBUG_sys ) ; then
1307        echo "IGCM_sys_ncflint :" $@
1308    fi
1309    ncflint $@
1310    if [ $? -gt 0 ] ; then
1311       echo "IGCM_sys_ncflint : erreur ${@}."
1312       IGCM_debug_Exit "ncflint"
1313    fi
1314
1315    IGCM_debug_PopStack "IGCM_sys_ncflint"
1316}
1317
1318function IGCM_sys_ncks {
1319    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1320    if ( $DEBUG_sys ) ; then
1321        echo "IGCM_sys_ncks :" $@
1322    fi
1323    ncks $@
1324    if [ $? -gt 0 ] ; then
1325       echo "IGCM_sys_ncks : erreur ${@}."
1326       IGCM_debug_Exit "ncks"
1327    fi
1328
1329    IGCM_debug_PopStack "IGCM_sys_ncks"
1330}
1331
1332function IGCM_sys_ncpdq {
1333    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1334    if ( $DEBUG_sys ) ; then
1335        echo "IGCM_sys_ncpdq :" $@
1336    fi
1337    ncpdq $@
1338    if [ $? -gt 0 ] ; then
1339       echo "IGCM_sys_ncpdq : erreur ${@}."
1340       IGCM_debug_Exit "ncpdq"
1341    fi
1342
1343    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1344}
1345
1346function IGCM_sys_ncra {
1347    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1348    if ( $DEBUG_sys ) ; then
1349        echo "IGCM_sys_ncra :" $@
1350    fi
1351    ncra $@
1352    if [ $? -gt 0 ] ; then
1353       echo "IGCM_sys_ncra : erreur ${@}."
1354       IGCM_debug_Exit "ncra"
1355    fi
1356
1357    IGCM_debug_PopStack "IGCM_sys_ncra"
1358}
1359
1360function IGCM_sys_ncrcat {
1361    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1362    if ( $DEBUG_sys ) ; then
1363        echo "IGCM_sys_ncrcat :" $@
1364    fi
1365    ncrcat $@
1366    if [ $? -gt 0 ] ; then
1367       echo "IGCM_sys_ncrcat : erreur ${@}."
1368#       IGCM_debug_Exit "ncrcat"
1369    fi
1370
1371    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1372}
1373
1374function IGCM_sys_ncrename {
1375    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1376    if ( $DEBUG_sys ) ; then
1377        echo "IGCM_sys_ncrename :" $@
1378    fi
1379    ncrename $@
1380    if [ $? -gt 0 ] ; then
1381       echo "IGCM_sys_ncrename : erreur ${@}."
1382       IGCM_debug_Exit "ncrename"
1383    fi
1384
1385    IGCM_debug_PopStack "IGCM_sys_ncrename"
1386}
1387
1388function IGCM_sys_ncwa {
1389    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1390    if ( $DEBUG_sys ) ; then
1391        echo "IGCM_sys_ncwa :" $@
1392    fi
1393    ncwa $@
1394    if [ $? -gt 0 ] ; then
1395       echo "IGCM_sys_ncwa : erreur ${@}."
1396       IGCM_debug_Exit "ncwa"
1397    fi
1398
1399    IGCM_debug_PopStack "IGCM_sys_ncwa"
1400}
1401
1402##############################################################
1403# CDO OPERATOR
1404
1405function IGCM_sys_cdo {
1406    IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1407
1408    \cdo $@
1409    if [ $? -gt 0 ] ; then
1410       echo "IGCM_sys_cdo : erreur ${@}."
1411       IGCM_debug_PopStack "IGCM_sys_cdo"
1412       return 1
1413    else
1414        IGCM_debug_PopStack "IGCM_sys_cdo"
1415        return 0
1416    fi
1417
1418    IGCM_debug_PopStack "IGCM_sys_cdo"
1419}
1420
1421############################################################
1422# Activate Running Environnment Variables
1423
1424function IGCM_sys_activ_variables {
1425    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1426    if ( $DEBUG_sys ) ; then
1427        echo "IGCM_sys_activ_variables"
1428    fi
1429    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1430}
1431
1432############################################################
1433# Desactivate Running Environnment Variables
1434
1435function IGCM_sys_desactiv_variables {
1436    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1437    if ( $DEBUG_sys ) ; then
1438        echo "IGCM_sys_desactiv_variables"
1439    fi
1440    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1441}
1442
1443############################################################
1444# Build run file
1445
1446function IGCM_sys_build_run_file {
1447    IGCM_debug_PushStack "IGCM_sys_build_run_file"
1448    if ( $DEBUG_sys ) ; then
1449        echo "IGCM_sys_build_run_file"
1450    fi
1451    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1452}
Note: See TracBrowser for help on using the repository browser.