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

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

Some update needed for the DRYRUN

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