source: tags/libIGCM_v1_11/libIGCM_sys/libIGCM_sys_mercure.ksh @ 1170

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