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

Last change on this file since 409 was 409, checked in by sdipsl, 13 years ago
  • correct bug with TS 3D without chunck see ticket #52
  • catch return code from all nco operator except ncrcat and exit if SpaceName? is PROD. clean error code handling. Special case for cdo command. see ticket #51
    • it means that if SpaceName?=PROD all must run absolutely perfectly ; otherwise libIGCM will stop.
  • For Smooth file, first access is always true for Period=1. Get Files when SmoothMin?<CumulPeriod?<SmoothMax? and modulo [min]:[modulo:][max] is true. see ticket #44
  • Under testing : do not use unless you are willing to help testing.
  • 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}
120
121#====================================================
122#- OUT
123typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
124
125#====================================================
126#- OUT_SCR (ONLY FOR double copy an scratch)
127typeset -r R_OUT_SCR=${SCRATCHDIR}/IGCM_OUT
128
129#====================================================
130#- OUT_POST
131typeset -r R_OUT_POST=${SCRATCHDIR}/IGCM_OUT
132
133#====================================================
134#- RUN_DIR_PATH : Temporary working directory (=> TMP)
135PBS_JOBID=${PBS_JOBID:=TEMPDIR$$}
136typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/${PBS_JOBID}}
137
138#====================================================
139#- Max number of arguments passed to nco operator or demigration command
140UNIX_MAX_LIMIT=360
141
142#D-#==================================================
143#D-function IGCM_sys_RshMaster
144#D-* Purpose: Just a fake command to wrapp
145#D-           IGCM_card call in post-treatment
146#D-           Ulam do not see brodie filesystem
147#D-           Cesium do not see all mercure filesystem
148#D-           That's why we need this hack.
149#D-* Examples:
150#D-
151function IGCM_sys_RshMaster {
152    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
153    typeset NB_ESSAI DELAI status i
154    # number of tentative
155    NB_ESSAI=10
156    # time delay between tentative
157    DELAI=30
158    #
159    sleep ${DELAI}
160    (( i = 0 ))
161    while [ $i -lt $NB_ESSAI ] ; do
162        ssh ${MASTER} exec /bin/ksh <<-EOF
163    export libIGCM=${libIGCM_SX}
164    export DEBUG_debug=${DEBUG_debug}
165    . ${libIGCM_SX}/libIGCM_debug/libIGCM_debug.ksh
166    . ${libIGCM_SX}/libIGCM_card/libIGCM_card.ksh
167    ${@}
168EOF
169        status=$?
170        if [ ${status} -gt 0 ]; then
171            IGCM_debug_Print 2 "IGCM_sys_RshMaster : ssh failed ${i}/${NB_ESSAI}"
172            IGCM_debug_Print 2 "IGCM_sys_RshMaster : sleep ${DELAI} seconds and try again."
173            sleep $DELAI
174        else
175            break
176        fi
177        (( i = i + 1 ))
178    done
179
180    IGCM_debug_PopStack "IGCM_sys_RshMaster"
181}
182
183#D-#==================================================
184#D-function IGCM_sys_RshArchive
185#D-* Purpose: Archive rsh command
186#D-* Examples:
187#D-
188function IGCM_sys_RshArchive {
189    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
190    /bin/ksh <<-EOF
191    ${@}
192EOF
193    if [ $? -gt 0 ] ; then
194        echo "IGCM_sys_RshArchive : erreur."
195        IGCM_debug_Exit "IGCM_sys_RshArchive"
196    fi
197    IGCM_debug_PopStack "IGCM_sys_RshArchive"
198}
199
200#D-#==================================================
201#D-function IGCM_sys_RshPost
202#D-* Purpose: Post-process rsh command
203#D-* Examples:
204#D-
205function IGCM_sys_RshPost {
206    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
207    if ( $DEBUG_sys ) ; then
208        echo "IGCM_sys_RshPost :" $@
209    fi
210    /bin/ksh ${@}
211    if [ $? -gt 0 ] ; then
212        echo "IGCM_sys_RshPost : erreur."
213        IGCM_debug_Exit "IGCM_sys_RshPost"
214    fi
215    IGCM_debug_PopStack "IGCM_sys_RshPost"
216}
217
218#D-#==================================================
219#D-function IGCM_sys_SendMail
220#D-* Purpose: Send mail when simulation is over
221#D-* Examples:
222#D-
223function IGCM_sys_SendMail {
224    IGCM_debug_PushStack "IGCM_sys_SendMail" $@
225    if ( $DEBUG_sys ) ; then
226        echo "IGCM_sys_SendMail :" $@
227    fi
228
229    IGCM_sys_RshPost <<-EOF
230    export LOGIN=${LOGIN}
231    export config_UserChoices_JobName=${config_UserChoices_JobName}
232    export config_UserChoices_MailName=${config_UserChoices_MailName}
233    export DateBegin=${DateBegin}
234    export DateEnd=${DateEnd}
235    export R_SAVE=${R_SAVE}
236    export SUBMIT_DIR=${SUBMIT_DIR}
237
238    cat  << END_MAIL > job_end.mail
239Dear ${LOGIN},
240
241  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
242  Job started : ${DateBegin}
243  Job ended   : ${DateEnd}
244  Ouput files are available in ${R_SAVE}
245  Script files and Script Outputs are available in ${SUBMIT_DIR}
246END_MAIL
247
248    if [ ! -z ${config_UserChoices_MailName} ] ; then
249       mailx -s "${config_UserChoices_JobName} completed" ${config_UserChoices_MailName} <  job_end.mail
250    elif [ -f ~/.forward ] ; then
251       mailx -s "${config_UserChoices_JobName} completed" $( cat ~/.forward ) < job_end.mail
252    fi
253
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    else
1188        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1189    fi
1190    return $RET
1191}
1192
1193
1194#D-#==================================================
1195#D-function IGCM_sys_Dods_Cp
1196#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1197#D-* Examples:
1198#D-
1199function IGCM_sys_Dods_Cp {
1200    if ( $DEBUG_sys ) ; then
1201        echo "IGCM_sys_Dods_Cp :" $@
1202    fi
1203    typeset RET
1204    RET=0
1205    if [ $DRYRUN = 0 ]; then
1206        if [ ! -d ${R_SAVE}/${1} ] ; then
1207            echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1208            echo "Nothing has been done."
1209            return
1210        fi
1211        #
1212        dods_cp ${1} public/${LOGIN}/${R_DODS}
1213# > 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    else
1224        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1225    fi
1226    return $RET
1227}
1228
1229#D-#==================================================
1230#D-function IGCM_sys_Put_Dods
1231#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1232#D-* Examples:
1233#D-
1234function IGCM_sys_Put_Dods {
1235    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1236    if ( $DEBUG_sys ) ; then
1237        echo "IGCM_sys_Put_Dods :" $@
1238    fi
1239    if [ $DRYRUN = 0 ]; then
1240        if [ ! -d ${R_SAVE}/${1} ] ; then
1241            echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
1242            IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1243            return
1244        fi
1245
1246        typeset RET
1247        #
1248        cd ${R_SAVE}
1249        IGCM_sys_Dods_Rm ${1}
1250        IGCM_sys_Dods_Cp ${1}
1251        RET=0
1252       
1253        if [ ${RET} -gt 0 ] ; then
1254            echo "IGCM_sys_Put_Dods : error."
1255            IGCM_debug_Exit "IGCM_sys_Put_Dods"
1256        fi
1257    else
1258        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1259    fi
1260    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1261}
1262
1263############################################################## A FINIR !!
1264
1265#D-#==================================================
1266#D-function IGCM_sys_GetDate_FichWork
1267#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1268#D-* Examples:
1269#D-
1270function IGCM_sys_GetDate_FichWork {
1271    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1272    if ( $DEBUG_sys ) ; then
1273        echo "IGCM_sys_GetDate_FichWork :" $@
1274    fi
1275    # donne la date filesys d'un fichier sur la machine work
1276    IGCM_debug_PopStack "IGCM_sys_FichWork"
1277}
1278
1279#D-#==================================================
1280#D-function IGCM_sys_GetDate_FichArchive
1281#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1282#D-* Examples:
1283#D-
1284function IGCM_sys_GetDate_FichArchive {
1285    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1286    if ( $DEBUG_sys ) ; then
1287        echo "IGCM_sys_GetDate_FichArchive :" $@
1288    fi
1289    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1290}
1291
1292##############################################################
1293# REBUILD OPERATOR
1294
1295function IGCM_sys_rebuild {
1296    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1297    if ( $DEBUG_sys ) ; then
1298        echo "IGCM_sys_rebuild :" $@
1299    fi
1300    /home/cont003/p86ipsl/CESIUM/bin/rebuild -f -o $@
1301    if [ $? -gt 0 ] ; then
1302       echo "IGCM_sys_rebuild : erreur ${@}."
1303       IGCM_debug_Exit "rebuild"
1304    fi
1305
1306    IGCM_debug_PopStack "IGCM_sys_rebuild"
1307}
1308
1309##############################################################
1310# NCO OPERATOR
1311
1312function IGCM_sys_ncap2 {
1313    IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1314    if ( $DEBUG_sys ) ; then
1315        echo "IGCM_sys_ncap2 :" $@
1316    fi
1317    ncap2 "$@"
1318    if [ $? -gt 0 ] ; then
1319       echo "IGCM_sys_ncap2 : erreur ${@}."
1320       IGCM_debug_Exit "ncap2"
1321    fi
1322
1323    IGCM_debug_PopStack "IGCM_sys_ncap2"
1324}
1325
1326function IGCM_sys_ncatted {
1327    IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1328    if ( $DEBUG_sys ) ; then
1329        echo "IGCM_sys_ncatted :" $@
1330    fi
1331    ncatted "$@"
1332    if [ $? -gt 0 ] ; then
1333       echo "IGCM_sys_ncatted : erreur ${@}."
1334       IGCM_debug_Exit "ncatted"
1335    fi
1336
1337    IGCM_debug_PopStack "IGCM_sys_ncatted"
1338}
1339
1340function IGCM_sys_ncbo {
1341    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1342    if ( $DEBUG_sys ) ; then
1343        echo "IGCM_sys_ncbo :" $@
1344    fi
1345    ncbo $@
1346    if [ $? -gt 0 ] ; then
1347       echo "IGCM_sys_ncbo : erreur ${@}."
1348       IGCM_debug_Exit "ncbo"
1349    fi
1350
1351    IGCM_debug_PopStack "IGCM_sys_ncbo"
1352}
1353
1354function IGCM_sys_ncdiff {
1355    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1356    if ( $DEBUG_sys ) ; then
1357        echo "IGCM_sys_ncdiff :" $@
1358    fi
1359    ncdiff $@
1360    if [ $? -gt 0 ] ; then
1361       echo "IGCM_sys_ncdiff : erreur ${@}."
1362       IGCM_debug_Exit "ncdiff"
1363    fi
1364
1365    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1366}
1367
1368function IGCM_sys_ncea {
1369    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1370    if ( $DEBUG_sys ) ; then
1371        echo "IGCM_sys_ncea :" $@
1372    fi
1373    ncea $@
1374    if [ $? -gt 0 ] ; then
1375       echo "IGCM_sys_ncea : erreur ${@}."
1376       IGCM_debug_Exit "ncea"
1377    fi
1378
1379    IGCM_debug_PopStack "IGCM_sys_ncea"
1380}
1381
1382function IGCM_sys_ncecat {
1383    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1384    if ( $DEBUG_sys ) ; then
1385        echo "IGCM_sys_ncecat :" $@
1386    fi
1387    ncecat $@
1388    if [ $? -gt 0 ] ; then
1389       echo "IGCM_sys_ncecat : erreur ${@}."
1390       IGCM_debug_Exit "ncecat"
1391    fi
1392
1393    IGCM_debug_PopStack "IGCM_sys_ncecat"
1394}
1395
1396function IGCM_sys_ncflint {
1397    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1398    if ( $DEBUG_sys ) ; then
1399        echo "IGCM_sys_ncflint :" $@
1400    fi
1401    ncflint $@
1402    if [ $? -gt 0 ] ; then
1403       echo "IGCM_sys_ncflint : erreur ${@}."
1404       IGCM_debug_Exit "ncflint"
1405    fi
1406
1407    IGCM_debug_PopStack "IGCM_sys_ncflint"
1408}
1409
1410function IGCM_sys_ncks {
1411    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1412    if ( $DEBUG_sys ) ; then
1413        echo "IGCM_sys_ncks :" $@
1414    fi
1415    ncks $@
1416    if [ $? -gt 0 ] ; then
1417       echo "IGCM_sys_ncks : erreur ${@}."
1418       IGCM_debug_Exit "ncks"
1419    fi
1420
1421    IGCM_debug_PopStack "IGCM_sys_ncks"
1422}
1423
1424function IGCM_sys_ncpdq {
1425    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1426    if ( $DEBUG_sys ) ; then
1427        echo "IGCM_sys_ncpdq :" $@
1428    fi
1429    ncpdq $@
1430    if [ $? -gt 0 ] ; then
1431       echo "IGCM_sys_ncpdq : erreur ${@}."
1432       IGCM_debug_Exit "ncpdq"
1433    fi
1434
1435    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1436}
1437
1438function IGCM_sys_ncra {
1439    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1440    if ( $DEBUG_sys ) ; then
1441        echo "IGCM_sys_ncra :" $@
1442    fi
1443    ncra $@
1444    if [ $? -gt 0 ] ; then
1445       echo "IGCM_sys_ncra : erreur ${@}."
1446       IGCM_debug_Exit "ncra"
1447    fi
1448
1449    IGCM_debug_PopStack "IGCM_sys_ncra"
1450}
1451
1452function IGCM_sys_ncrcat {
1453    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1454    if ( $DEBUG_sys ) ; then
1455        echo "IGCM_sys_ncrcat :" $@
1456    fi
1457    ncrcat $@
1458    if [ $? -gt 0 ] ; then
1459       echo "IGCM_sys_ncrcat : erreur ${@}."
1460#       IGCM_debug_Exit "ncrcat"
1461    fi
1462
1463    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1464}
1465
1466function IGCM_sys_ncrename {
1467    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1468    if ( $DEBUG_sys ) ; then
1469        echo "IGCM_sys_ncrename :" $@
1470    fi
1471    ncrename $@
1472    if [ $? -gt 0 ] ; then
1473       echo "IGCM_sys_ncrename : erreur ${@}."
1474       IGCM_debug_Exit "ncrename"
1475    fi
1476
1477    IGCM_debug_PopStack "IGCM_sys_ncrename"
1478}
1479
1480function IGCM_sys_ncwa {
1481    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1482    if ( $DEBUG_sys ) ; then
1483        echo "IGCM_sys_ncwa :" $@
1484    fi
1485    ncwa $@
1486    if [ $? -gt 0 ] ; then
1487       echo "IGCM_sys_ncwa : erreur ${@}."
1488       IGCM_debug_Exit "ncwa"
1489    fi
1490
1491    IGCM_debug_PopStack "IGCM_sys_ncwa"
1492}
1493
1494##############################################################
1495# CDO OPERATOR
1496
1497function IGCM_sys_cdo {
1498    IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1499
1500    \cdo $@
1501    if [ $? -gt 0 ] ; then
1502       echo "IGCM_sys_cdo : erreur ${@}."
1503       IGCM_debug_PopStack "IGCM_sys_cdo"
1504       return 1
1505    else
1506        IGCM_debug_PopStack "IGCM_sys_cdo"
1507        return 0
1508    fi
1509
1510    IGCM_debug_PopStack "IGCM_sys_cdo"
1511}
1512
1513############################################################
1514# Activate Running Environnment Variables
1515
1516function IGCM_sys_activ_variables {
1517    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1518    if ( $DEBUG_sys ) ; then
1519        echo "IGCM_sys_activ_variables"
1520    fi
1521    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1522}
1523
1524############################################################
1525# Desactivate Running Environnment Variables
1526
1527function IGCM_sys_desactiv_variables {
1528    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1529    if ( $DEBUG_sys ) ; then
1530        echo "IGCM_sys_desactiv_variables"
1531    fi
1532    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1533}
1534
1535############################################################
1536# Build run file
1537
1538function IGCM_sys_build_run_file {
1539    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1540    if ( $DEBUG_sys ) ; then
1541        echo "IGCM_sys_build_run_file"
1542    fi
1543    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1544}
Note: See TracBrowser for help on using the repository browser.