source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh @ 538

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

Correct IGCM_sys_GetDate_FichWork and some IGCM_sys_Tar. Suppress DODS for obelix. Add IGCM_sys_RshMaster to connect to frontend.

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