source: branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_cesium.ksh @ 559

Last change on this file since 559 was 521, checked in by sdipsl, 12 years ago

Dont exit during dmget error (can be ignore most of the time in fact). Stop later if the cp commands fails.
Homogenize commands between titane, cesium and mercure scalaire.

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