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

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

Send mail notification when computing job stops
It could be that we send a notification if a post-processing job stops in PROD mode ---> need some refactoring and caution...

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