source: branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_mercure.ksh @ 559

Last change on this file since 559 was 521, checked in by sdipsl, 12 years ago

Dont exit during dmget error (can be ignore most of the time in fact). Stop later if the cp commands fails.
Homogenize commands between titane, cesium and mercure scalaire.

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