source: tags/libIGCM_v1_12/libIGCM_sys/libIGCM_sys_titane.ksh @ 527

Last change on this file since 527 was 520, checked in by sdipsl, 13 years ago

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

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