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

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

Homogenize sleeping period in libIGCM_sys

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