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

Last change on this file since 434 was 434, checked in by mmaipsl, 13 years ago

correct a typo in Message send by mail.

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