source: branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_cesium.ksh @ 489

Last change on this file since 489 was 462, checked in by mafoipsl, 13 years ago

delete useless sleep on cesium.

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