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

Last change on this file since 374 was 374, checked in by brocksce, 14 years ago

ncap needs to keep quotes from arguments when option -s is used :

ncap -Oh -s '..."..."...'

"$@" should be used everywhere

  • Property svn:keywords set to Revision Author Date
File size: 40.4 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}/$1.${PeriodDateEnd}.${TsTask}.${CompToRead}.${FlagToRead}.out -e ${POST_DIR}/$1.${PeriodDateEnd}.${TsTask}.${CompToRead}.${FlagToRead}.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        TEST=$( IGCM_sys_RshMaster [ -d $1 ] && echo 1 || echo 0 )
852        if [ ${TEST} -ne 1 ] ; then
853            echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ON ${MASTER}."
854            IGCM_debug_PopStack "IGCM_sys_Get_Master"
855            return
856        fi
857
858        typeset RET
859        sleep 60
860
861        #USUAL WAY
862        scp -r ${MASTER}:$1 $2 > out_rsync 2>&1
863        RET=$?
864
865        if [ ${RET} -gt 0 ] ; then
866            echo "IGCM_sys_Get_Master : error."
867            cat out_rsync
868            IGCM_debug_Exit "IGCM_sys_Get_Master"
869        else
870            rm out_rsync
871        fi
872    else
873        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
874    fi
875    IGCM_debug_PopStack "IGCM_sys_Get_Master"
876}
877
878#D-#==================================================
879#D-function IGCM_sys_Put_Rest
880#D-* Purpose: Put computied restarts on $(ARCHIVE).
881#D-           File and target directory must exist.
882#D-* Examples:
883#D-
884function IGCM_sys_Put_Rest {
885    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
886    if ( $DEBUG_sys ) ; then
887        echo "IGCM_sys_Put_Rest :" $@
888    fi
889    if [ $DRYRUN = 0 ]; then
890        if [ ! -f ${1} ] ; then
891            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
892            IGCM_debug_Exit "IGCM_sys_Put_Rest"
893        fi
894
895        typeset RET
896        #
897        if [ X${JobType} = XRUN ] ; then
898            IGCM_sys_Chmod 444 ${1}
899        fi
900        #
901        IGCM_sys_TestDirArchive $( dirname $2 )
902        #
903        # USUAL WAY
904        \cp $1 $2 > out_rsync 2>&1
905        RET=$?
906
907#       #RSYNC WITH NETWORK SSH CALL
908#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
909#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
910
911#       #RSYNC WITH NFS USE
912#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
913#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
914
915#       RET=$?
916#       IGCM_sys_Rsync_out $RET
917
918#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
919#       (( RET=RET+$? ))
920
921        if [ ${RET} -gt 0 ] ; then
922            echo "IGCM_sys_Put_Rest : error."
923            cat out_rsync
924            IGCM_debug_Exit "IGCM_sys_Put_Rest"
925        else
926            rm out_rsync
927        fi
928    else
929        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
930    fi
931    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
932}
933
934#D-#==================================================
935#D-function IGCM_sys_Put_Out
936#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
937#D-* Examples:
938#D-
939function IGCM_sys_Put_Out {
940    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
941    if ( $DEBUG_sys ) ; then
942        echo "IGCM_sys_Put_Out :" $@
943    fi
944    if [ $DRYRUN = 0 ]; then
945        if [ ! -f ${1} ] ; then
946            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
947            IGCM_debug_PopStack "IGCM_sys_Put_Out"
948            return 1
949        fi
950        #
951        IGCM_sys_MkdirArchive $( dirname $2 )
952        #
953        typeset RET exist skip
954
955        #=====================================================
956        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
957        #=====================================================
958
959        #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
960        #if [ $? -eq 0 ] ; then
961        #    typeset WORKPATH FILEPATH
962        #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
963        #    IGCM_sys_MkdirWork ${WORKPATH}
964        #    FILEPATH=${WORKPATH}/$( basename $2 )
965        #    #
966        #    IGCM_sys_Cp ${1} ${FILEPATH}
967        #fi
968
969        if [ X${JobType} = XRUN ] ; then
970            if [ X${3} = X ] ; then
971                IGCM_sys_Chmod 444 ${1}
972            fi
973        fi
974
975        exist=false
976        skip=false
977        if [ -f $2 ] ; then
978            IGCM_debug_Print 1 "$2 already exist"
979            dmget $2
980            exist=true
981            if [ "X$( diff $1 $2 )" = X ] ; then
982                IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
983                skip=true
984            else
985                IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
986                skip=false
987            fi
988        fi
989        #
990        if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
991            IGCM_sys_Chmod u+w $2
992        fi
993        # USUAL WAY
994        if [ X${skip} = Xfalse ] ; then
995            cp $1 $2 > out_rsync 2>&1
996            RET=$?
997            if [ ${RET} -gt 0 ] ; then
998                echo "IGCM_sys_Put_Out : error."
999                cat out_rsync
1000                IGCM_debug_Exit "IGCM_sys_Put_Out"
1001            else
1002                rm out_rsync
1003            fi
1004        fi
1005
1006#       #RSYNC WITH NETWORK RSH CALL
1007#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
1008#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
1009
1010#       #RSYNC WITH NFS USE
1011#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1012#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1013
1014#       RET=$?
1015#       IGCM_sys_Rsync_out $RET
1016
1017#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1018#       (( RET=RET+$? ))
1019
1020
1021    else
1022        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1023    fi
1024    IGCM_debug_PopStack "IGCM_sys_Put_Out"
1025    return 0
1026}
1027
1028#D-#==================================================
1029#D-function IGCM_sys_Get
1030#D-* Purpose: Get a file from ${ARCHIVE}
1031#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1032#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1033function IGCM_sys_Get {
1034    IGCM_debug_PushStack "IGCM_sys_Get" $@
1035
1036    typeset DEST RET dm_liste ifile target file_work
1037
1038    if ( $DEBUG_sys ) ; then
1039        echo "IGCM_sys_Get :" $@
1040    fi
1041    if [ $DRYRUN -le 2 ]; then
1042        if [ X${1} = X'/l' ] ; then
1043            # test if the first file is present in the old computation :
1044            eval set +A dm_liste \${${2}}
1045        else
1046            eval set +A dm_liste ${1}
1047        fi
1048        eval DEST=\${${#}}
1049
1050        #=====================================================
1051        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1052        #=====================================================
1053
1054        # Is it an R_OUT file (not R_IN) ?
1055        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1056        #if [ $? -eq 0 ] ; then
1057        #    # Yes  ? then we try to get it in SCRATCHDIR
1058        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
1059        #    if [ -f ${file_work[0]} ] ; then
1060        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
1061        #       IGCM_debug_PopStack "IGCM_sys_Get"
1062        #       return
1063        #    fi
1064        #fi
1065
1066        # test if the (first) file is present in the old computation :
1067        IGCM_sys_TestFileArchive ${dm_liste[0]}
1068        RET=$?
1069        if [ ${RET} -gt 0 ] ; then
1070            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1071            IGCM_debug_Exit "IGCM_sys_Get"
1072            #IGCM_debug_PopStack "IGCM_sys_Get"
1073            #return
1074        fi
1075
1076        dmget ${dm_liste[*]} > out_rsync 2>&1
1077        RET=$?
1078        if [ ${RET} -gt 0 ] ; then
1079            echo "WARNING IGCM_sys_Get : demigration error."
1080            cat out_rsync
1081            #IGCM_debug_Exit "IGCM_sys_Get"
1082            #IGCM_debug_PopStack "IGCM_sys_Get"
1083            #return
1084        fi
1085
1086        #USUAL WAY
1087        (( RET=0 ))
1088        if [ X${1} = X'/l' ] ; then
1089            (( RET=0 ))
1090            for target in ${dm_liste[*]} ; do
1091                local_file=$( basename ${target} )
1092                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1093                (( RET = RET + $? ))
1094            done
1095        else
1096            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1097            RET=$?
1098        fi
1099
1100#       #RSYNC WITH NETWORK SSH CALL
1101#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1102#       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1103
1104#       #RSYNC WITH NFS USE
1105#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1106#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1107
1108#       RET=$?
1109#       IGCM_sys_Rsync_out $RET
1110
1111#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1112#       (( RET=RET+$? ))
1113
1114        if [ ${RET} -gt 0 ] ; then
1115            echo "IGCM_sys_Get : copy error."
1116            cat out_rsync
1117            IGCM_debug_Exit "IGCM_sys_Get"
1118        else
1119            rm out_rsync
1120        fi
1121    else
1122        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1123    fi
1124    IGCM_debug_PopStack "IGCM_sys_Get"
1125}
1126
1127#D-#==================================================
1128#D-function IGCM_sys_Dods_Rm
1129#D-* Purpose: DO NOTHING ! Put $(ARCHIVE) files on DODS internet protocole.
1130#D-* Examples:
1131#D-
1132function IGCM_sys_Dods_Rm {
1133    if ( $DEBUG_sys ) ; then
1134        echo "IGCM_sys_Dods_Rm :" $@
1135    fi
1136    typeset RET
1137    RET=0
1138    if [ $DRYRUN = 0 ]; then
1139        if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
1140            echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
1141            echo "Nothing has been done."
1142            return
1143        fi
1144        dods_rm public/${LOGIN}/${R_DODS}/${1} > out_dods_rm 2>&1
1145        RET=$?
1146       
1147        if [ ${RET} -gt 0 ] ; then
1148            echo "IGCM_sys_Dods_Rm : error."
1149            cat out_dods_rm
1150            IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1151        else
1152            rm out_dods_rm
1153        fi
1154    else
1155        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1156    fi
1157    return $RET
1158}
1159
1160
1161#D-#==================================================
1162#D-function IGCM_sys_Dods_Cp
1163#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1164#D-* Examples:
1165#D-
1166function IGCM_sys_Dods_Cp {
1167    if ( $DEBUG_sys ) ; then
1168        echo "IGCM_sys_Dods_Cp :" $@
1169    fi
1170    typeset RET
1171    RET=0
1172    if [ $DRYRUN = 0 ]; then
1173        if [ ! -d ${R_SAVE}/${1} ] ; then
1174            echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1175            echo "Nothing has been done."
1176            return
1177        fi
1178        #
1179        dods_cp ${1} public/${LOGIN}/${R_DODS}
1180# > out_dods_cp 2>&1
1181        RET=$?
1182       
1183#       if [ ${RET} -gt 0 ] ; then
1184#           echo "IGCM_sys_Dods_Cp : error."
1185#           cat out_dods_cp
1186#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1187#       else
1188#           rm out_dods_cp
1189#       fi
1190    else
1191        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1192    fi
1193    return $RET
1194}
1195
1196#D-#==================================================
1197#D-function IGCM_sys_Put_Dods
1198#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1199#D-* Examples:
1200#D-
1201function IGCM_sys_Put_Dods {
1202    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1203    if ( $DEBUG_sys ) ; then
1204        echo "IGCM_sys_Put_Dods :" $@
1205    fi
1206    if [ $DRYRUN = 0 ]; then
1207        if [ ! -d ${R_SAVE}/${1} ] ; then
1208            echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
1209            IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1210            return
1211        fi
1212
1213        typeset RET
1214        #
1215        cd ${R_SAVE}
1216        IGCM_sys_Dods_Rm ${1}
1217        IGCM_sys_Dods_Cp ${1}
1218        RET=0
1219       
1220        if [ ${RET} -gt 0 ] ; then
1221            echo "IGCM_sys_Put_Dods : error."
1222            IGCM_debug_Exit "IGCM_sys_Put_Dods"
1223        fi
1224    else
1225        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1226    fi
1227    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1228}
1229
1230############################################################## A FINIR !!
1231
1232#D-#==================================================
1233#D-function IGCM_sys_GetDate_FichWork
1234#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1235#D-* Examples:
1236#D-
1237function IGCM_sys_GetDate_FichWork {
1238    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1239    if ( $DEBUG_sys ) ; then
1240        echo "IGCM_sys_GetDate_FichWork :" $@
1241    fi
1242    # donne la date filesys d'un fichier sur la machine work
1243    IGCM_debug_PopStack "IGCM_sys_FichWork"
1244}
1245
1246#D-#==================================================
1247#D-function IGCM_sys_GetDate_FichArchive
1248#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1249#D-* Examples:
1250#D-
1251function IGCM_sys_GetDate_FichArchive {
1252    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1253    if ( $DEBUG_sys ) ; then
1254        echo "IGCM_sys_GetDate_FichArchive :" $@
1255    fi
1256    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1257}
1258
1259##############################################################
1260# REBUILD OPERATOR
1261
1262function IGCM_sys_rebuild {
1263    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1264    if ( $DEBUG_sys ) ; then
1265        echo "IGCM_sys_rebuild :" $@
1266    fi
1267    /home/cont003/p86ipsl/CESIUM/bin/rebuild -f -o $@
1268    if [ $? -gt 0 ] ; then
1269       echo "IGCM_sys_rebuild : erreur ${@}."
1270       IGCM_debug_Exit "rebuild"
1271    fi
1272
1273    IGCM_debug_PopStack "IGCM_sys_rebuild"
1274}
1275
1276##############################################################
1277# NCO OPERATOR
1278
1279function IGCM_sys_ncap {
1280    IGCM_debug_PushStack "IGCM_sys_ncap" -- $@
1281    if ( $DEBUG_sys ) ; then
1282        echo "IGCM_sys_ncap :" $@
1283    fi
1284    ncap "$@"
1285    if [ $? -gt 0 ] ; then
1286       echo "IGCM_sys_ncap : erreur ${@}."
1287#       IGCM_debug_Exit "ncap"
1288    fi
1289
1290    IGCM_debug_PopStack "IGCM_sys_ncap"
1291}
1292
1293ncatted=ncatted
1294# Problem with ksh and string passed in this function to ncatted !
1295# function IGCM_sys_ncatted {
1296#     IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1297#     if ( $DEBUG_sys ) ; then
1298#       echo "IGCM_sys_ncatted :" $@
1299#     fi
1300#     ncatted $@
1301#     if [ $? -gt 0 ] ; then
1302#        echo "IGCM_sys_ncatted : erreur ${@}."
1303#        IGCM_debug_Exit "ncatted"
1304#     fi
1305
1306#     IGCM_debug_PopStack "IGCM_sys_ncatted"
1307# }
1308
1309function IGCM_sys_ncbo {
1310    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1311    if ( $DEBUG_sys ) ; then
1312        echo "IGCM_sys_ncbo :" $@
1313    fi
1314    ncbo $@
1315    if [ $? -gt 0 ] ; then
1316       echo "IGCM_sys_ncbo : erreur ${@}."
1317#       IGCM_debug_Exit "ncbo"
1318    fi
1319
1320    IGCM_debug_PopStack "IGCM_sys_ncbo"
1321}
1322
1323function IGCM_sys_ncdiff {
1324    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1325    if ( $DEBUG_sys ) ; then
1326        echo "IGCM_sys_ncdiff :" $@
1327    fi
1328    ncdiff $@
1329    if [ $? -gt 0 ] ; then
1330       echo "IGCM_sys_ncdiff : erreur ${@}."
1331#       IGCM_debug_Exit "ncdiff"
1332    fi
1333
1334    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1335}
1336
1337function IGCM_sys_ncea {
1338    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1339    if ( $DEBUG_sys ) ; then
1340        echo "IGCM_sys_ncea :" $@
1341    fi
1342    ncea $@
1343    if [ $? -gt 0 ] ; then
1344       echo "IGCM_sys_ncea : erreur ${@}."
1345#       IGCM_debug_Exit "ncea"
1346    fi
1347
1348    IGCM_debug_PopStack "IGCM_sys_ncea"
1349}
1350
1351function IGCM_sys_ncecat {
1352    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1353    if ( $DEBUG_sys ) ; then
1354        echo "IGCM_sys_ncecat :" $@
1355    fi
1356    ncecat $@
1357    if [ $? -gt 0 ] ; then
1358       echo "IGCM_sys_ncecat : erreur ${@}."
1359#       IGCM_debug_Exit "ncecat"
1360    fi
1361
1362    IGCM_debug_PopStack "IGCM_sys_ncecat"
1363}
1364
1365function IGCM_sys_ncflint {
1366    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1367    if ( $DEBUG_sys ) ; then
1368        echo "IGCM_sys_ncflint :" $@
1369    fi
1370    ncflint $@
1371    if [ $? -gt 0 ] ; then
1372       echo "IGCM_sys_ncflint : erreur ${@}."
1373#       IGCM_debug_Exit "ncflint"
1374    fi
1375
1376    IGCM_debug_PopStack "IGCM_sys_ncflint"
1377}
1378
1379function IGCM_sys_ncks {
1380    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1381    if ( $DEBUG_sys ) ; then
1382        echo "IGCM_sys_ncks :" $@
1383    fi
1384    ncks $@
1385    if [ $? -gt 0 ] ; then
1386       echo "IGCM_sys_ncks : erreur ${@}."
1387#       IGCM_debug_Exit "ncks"
1388    fi
1389
1390    IGCM_debug_PopStack "IGCM_sys_ncks"
1391}
1392
1393function IGCM_sys_ncpdq {
1394    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1395    if ( $DEBUG_sys ) ; then
1396        echo "IGCM_sys_ncpdq :" $@
1397    fi
1398    ncpdq $@
1399    if [ $? -gt 0 ] ; then
1400       echo "IGCM_sys_ncpdq : erreur ${@}."
1401#       IGCM_debug_Exit "ncpdq"
1402    fi
1403
1404    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1405}
1406
1407function IGCM_sys_ncra {
1408    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1409    if ( $DEBUG_sys ) ; then
1410        echo "IGCM_sys_ncra :" $@
1411    fi
1412    ncra $@
1413    if [ $? -gt 0 ] ; then
1414       echo "IGCM_sys_ncra : erreur ${@}."
1415#       IGCM_debug_Exit "ncra"
1416    fi
1417
1418    IGCM_debug_PopStack "IGCM_sys_ncra"
1419}
1420
1421function IGCM_sys_ncrcat {
1422    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1423    if ( $DEBUG_sys ) ; then
1424        echo "IGCM_sys_ncrcat :" $@
1425    fi
1426    ncrcat $@
1427    if [ $? -gt 0 ] ; then
1428       echo "IGCM_sys_ncrcat : erreur ${@}."
1429#       IGCM_debug_Exit "ncrcat"
1430    fi
1431
1432    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1433}
1434
1435function IGCM_sys_ncrename {
1436    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1437    if ( $DEBUG_sys ) ; then
1438        echo "IGCM_sys_ncrename :" $@
1439    fi
1440    ncrename $@
1441    if [ $? -gt 0 ] ; then
1442       echo "IGCM_sys_ncrename : erreur ${@}."
1443#       IGCM_debug_Exit "ncrename"
1444    fi
1445
1446    IGCM_debug_PopStack "IGCM_sys_ncrename"
1447}
1448
1449function IGCM_sys_ncwa {
1450    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1451    if ( $DEBUG_sys ) ; then
1452        echo "IGCM_sys_ncwa :" $@
1453    fi
1454    ncwa $@
1455    if [ $? -gt 0 ] ; then
1456       echo "IGCM_sys_ncwa : erreur ${@}."
1457#       IGCM_debug_Exit "ncwa"
1458    fi
1459
1460    IGCM_debug_PopStack "IGCM_sys_ncwa"
1461}
1462
1463##############################################################
1464# CDO OPERATOR
1465
1466function IGCM_sys_cdo {
1467    IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1468
1469    \cdo $@
1470    if [ $? -gt 0 ] ; then
1471       echo "IGCM_sys_cdo : erreur ${@}."
1472#       IGCM_debug_Exit "cdo"
1473    fi
1474
1475    IGCM_debug_PopStack "IGCM_sys_cdo"
1476}
1477
1478############################################################
1479# Activate Running Environnment Variables
1480
1481function IGCM_sys_activ_variables {
1482    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1483    if ( $DEBUG_sys ) ; then
1484        echo "IGCM_sys_activ_variables"
1485    fi
1486    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1487}
1488
1489############################################################
1490# Desactivate Running Environnment Variables
1491
1492function IGCM_sys_desactiv_variables {
1493    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1494    if ( $DEBUG_sys ) ; then
1495        echo "IGCM_sys_desactiv_variables"
1496    fi
1497    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1498}
1499
1500############################################################
1501# Build run file
1502
1503function IGCM_sys_build_run_file {
1504    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1505    if ( $DEBUG_sys ) ; then
1506        echo "IGCM_sys_build_run_file"
1507    fi
1508    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1509}
Note: See TracBrowser for help on using the repository browser.