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

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