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

Last change on this file since 387 was 387, checked in by sdipsl, 14 years ago
  • function IGCM_sys_Get_Master on cesium will try 10 times to scp files from master machine. Hopefully the last cesium consolidation
  • function IGCM_config_Check will check chunck2D/3D consistency with TimeSeriesFrequency?.
  • change the way the output from post-processing script was named. We will now have:

-rebuild_fromWorkdir.20051231.out
-create_ts.20051231.2D.out
-create_ts.20051231.3D.out
-atlas_PISCES.19991231.out
-create_ts.20051231.Chunck2D.ATM.POST_1D_histday.out
-create_ts.20051231.Chunck2D.OCE.POST_1D_grid_T.out

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