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

Last change on this file since 467 was 467, checked in by mafoipsl, 13 years ago

On titane :

  • add RUN_DIR to keep TMPDIR files like in the same directory
  • keep orginal request name in ccc_msub for rebuild job
  • delete temporary files
  • add IGCM_sys_RMRunDir function to support rebuild job on titane itself
  • Property svn:keywords set to Revision Author Date
File size: 40.5 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/tmp$$}
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        \cp -r $1 $2 > out_rsync 2>&1
940        RET=$?
941
942        if [ ${RET} -gt 0 ] ; then
943            echo "IGCM_sys_Get_Dir : error."
944            cat out_rsync
945            IGCM_debug_Exit "IGCM_sys_Get_Dir"
946        else
947            \rm out_rsync
948        fi
949    else
950        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
951    fi
952    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
953}
954
955#D-#==================================================
956#D-function IGCM_sys_Get_Master
957#D-* Purpose: Copy a complete directory from MASTER filesystem
958#D-* Examples:
959#D-
960function IGCM_sys_Get_Master {
961    IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
962    if ( $DEBUG_sys ) ; then
963        echo "IGCM_sys_Get_Master :" $@
964    fi
965    if [ $DRYRUN = 0 ]; then
966        if [ ! -d ${1} ] ; then
967            echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
968            IGCM_debug_PopStack "IGCM_sys_Get_Master"
969            return
970        fi
971
972        typeset RET
973
974        #USUAL WAY
975        \cp -r $1 $2 > out_rsync 2>&1
976        RET=$?
977
978        if [ ${RET} -gt 0 ] ; then
979            echo "IGCM_sys_Get_Master : error."
980            cat out_rsync
981            IGCM_debug_Exit "IGCM_sys_Get_Master"
982        fi
983    else
984        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
985    fi
986    IGCM_debug_PopStack "IGCM_sys_Get_Master"
987}
988
989#D-#==================================================
990#D-function IGCM_sys_Put_Rest
991#D-* Purpose: Put computied restarts on $(ARCHIVE).
992#D-           File and target directory must exist.
993#D-* Examples:
994#D-
995function IGCM_sys_Put_Rest {
996    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
997    if ( $DEBUG_sys ) ; then
998        echo "IGCM_sys_Put_Rest :" $@
999    fi
1000    if [ $DRYRUN = 0 ]; then
1001        if [ ! -f ${1} ] ; then
1002            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
1003            IGCM_debug_Exit "IGCM_sys_Put_Rest"
1004        fi
1005
1006        typeset RET
1007        #
1008        if [ X${JobType} = XRUN ] ; then
1009            IGCM_sys_Chmod 444 ${1}
1010        fi
1011        #
1012        IGCM_sys_TestDirArchive $( dirname $2 )
1013        #
1014        # USUAL WAY
1015        \cp $1 $2 > out_rsync 2>&1
1016        RET=$?
1017
1018#       #RSYNC WITH NETWORK SSH CALL
1019#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
1020#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
1021
1022#       #RSYNC WITH NFS USE
1023#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1024#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1025
1026#       RET=$?
1027#       IGCM_sys_Rsync_out $RET
1028
1029#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1030#       (( RET=RET+$? ))
1031
1032        if [ ${RET} -gt 0 ] ; then
1033            echo "IGCM_sys_Put_Rest : error."
1034            cat out_rsync
1035            IGCM_debug_Exit "IGCM_sys_Put_Rest"
1036        else
1037            \rm out_rsync
1038        fi
1039    else
1040        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1041    fi
1042    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
1043}
1044
1045#D-#==================================================
1046#D-function IGCM_sys_Put_Out
1047#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
1048#D-* Examples:
1049#D-
1050function IGCM_sys_Put_Out {
1051    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
1052    if ( $DEBUG_sys ) ; then
1053        echo "IGCM_sys_Put_Out :" $@
1054    fi
1055    if [ $DRYRUN = 0 ]; then
1056        if [ ! -f ${1} ] ; then
1057            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
1058            IGCM_debug_PopStack "IGCM_sys_Put_Out"
1059            return 1
1060        fi
1061        #
1062        IGCM_sys_MkdirArchive $( dirname $2 )
1063        #
1064        typeset RET
1065
1066        #=====================================================
1067        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1068        #=====================================================
1069
1070        #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
1071        #if [ $? -eq 0 ] ; then
1072        #    typeset WORKPATH FILEPATH
1073        #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
1074        #    IGCM_sys_MkdirWork ${WORKPATH}
1075        #    FILEPATH=${WORKPATH}/$( basename $2 )
1076        #    #
1077        #    IGCM_sys_Cp ${1} ${FILEPATH}
1078        #fi
1079
1080        if [ X${JobType} = XRUN ] ; then
1081            if [ X${3} = X ] ; then
1082                IGCM_sys_Chmod 444 ${1}
1083            fi
1084        fi
1085        #
1086        # USUAL WAY
1087        \cp $1 $2 > out_rsync 2>&1
1088        RET=$?
1089
1090#       #RSYNC WITH NETWORK SSH CALL
1091#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
1092#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
1093
1094#       #RSYNC WITH NFS USE
1095#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1096#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1097
1098#       RET=$?
1099#       IGCM_sys_Rsync_out $RET
1100
1101#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1102#       (( RET=RET+$? ))
1103
1104        if [ ${RET} -gt 0 ] ; then
1105            echo "IGCM_sys_Put_Out : error."
1106            cat out_rsync
1107            IGCM_debug_Exit "IGCM_sys_Put_Out"
1108        else
1109            \rm out_rsync
1110        fi
1111    else
1112        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1113    fi
1114    IGCM_debug_PopStack "IGCM_sys_Put_Out"
1115    return 0
1116}
1117
1118#D-#==================================================
1119#D-function IGCM_sys_Get
1120#D-* Purpose: Get a file from ${ARCHIVE}
1121#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1122#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1123function IGCM_sys_Get {
1124    IGCM_debug_PushStack "IGCM_sys_Get" $@
1125
1126    typeset DEST RET dm_liste ifile target file_work
1127
1128    if ( $DEBUG_sys ) ; then
1129        echo "IGCM_sys_Get :" $@
1130    fi
1131    if [ $DRYRUN -le 2 ]; then
1132        if [ X${1} = X'/l' ] ; then
1133            # test if the first file is present in the old computation :
1134            eval set +A dm_liste \${${2}}
1135        else
1136            eval set +A dm_liste ${1}
1137        fi
1138        eval DEST=\${${#}}
1139
1140        #=====================================================
1141        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1142        #=====================================================
1143
1144        # Is it an R_OUT file (not R_IN) ?
1145        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1146        #if [ $? -eq 0 ] ; then
1147        #    # Yes  ? then we try to get it in SCRATCHDIR
1148        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
1149        #    if [ -f ${file_work[0]} ] ; then
1150        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
1151        #       IGCM_debug_PopStack "IGCM_sys_Get"
1152        #       return
1153        #    fi
1154        #fi
1155
1156        # test if the (first) file is present in the old computation :
1157        IGCM_sys_TestFileArchive ${dm_liste[0]}
1158        RET=$?
1159        if [ ${RET} -gt 0 ] ; then
1160            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1161            IGCM_debug_Exit "IGCM_sys_Get"
1162            IGCM_debug_PopStack "IGCM_sys_Get"
1163            return
1164        fi
1165
1166#       dmget ${dm_liste[*]} > out_rsync 2>&1
1167#       RET=$?
1168#       if [ ${RET} -gt 0 ] ; then
1169#           echo "IGCM_sys_Get : demigration error."
1170#           cat out_rsync
1171#           IGCM_debug_Exit "IGCM_sys_Get"
1172#       fi
1173
1174        #USUAL WAY
1175        if [ X${1} = X'/l' ] ; then
1176            (( RET=0 ))
1177            for target in ${dm_liste[*]} ; do
1178                local_file=$( basename ${target} )
1179                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1180                (( RET = RET + $? ))
1181            done
1182        else
1183            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1184            RET=$?
1185        fi
1186
1187#       #RSYNC WITH NETWORK SSH CALL
1188#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1189#       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1190
1191#       #RSYNC WITH NFS USE
1192#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1193#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1194
1195#       RET=$?
1196#       IGCM_sys_Rsync_out $RET
1197
1198#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1199#       (( RET=RET+$? ))
1200
1201        if [ ${RET} -gt 0 ] ; then
1202            echo "IGCM_sys_Get : copy error."
1203            cat out_rsync
1204            IGCM_debug_Exit "IGCM_sys_Get"
1205        else
1206            \rm out_rsync
1207        fi
1208    else
1209        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1210    fi
1211    IGCM_debug_PopStack "IGCM_sys_Get"
1212}
1213
1214############################################################## A FINIR !!
1215
1216#D-#==================================================
1217#D-function IGCM_sys_GetDate_FichWork
1218#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1219#D-* Examples:
1220#D-
1221function IGCM_sys_GetDate_FichWork {
1222    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1223    if ( $DEBUG_sys ) ; then
1224        echo "IGCM_sys_GetDate_FichWork :" $@
1225    fi
1226    # donne la date filesys d'un fichier sur la machine work
1227    IGCM_debug_PopStack "IGCM_sys_FichWork"
1228}
1229
1230#D-#==================================================
1231#D-function IGCM_sys_GetDate_FichArchive
1232#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1233#D-* Examples:
1234#D-
1235function IGCM_sys_GetDate_FichArchive {
1236    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1237    if ( $DEBUG_sys ) ; then
1238        echo "IGCM_sys_GetDate_FichArchive :" $@
1239    fi
1240    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1241}
1242
1243##############################################################
1244# REBUILD OPERATOR
1245
1246function IGCM_sys_rebuild {
1247    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1248    if ( $DEBUG_sys ) ; then
1249        echo "IGCM_sys_rebuild :" $@
1250    fi
1251    /home/cont003/p86ipsl/X64/bin/rebuild -f -o $@
1252    if [ $? -gt 0 ] ; then
1253       echo "IGCM_sys_rebuild : erreur ${@}."
1254       IGCM_debug_Exit "rebuild"
1255    fi
1256
1257    IGCM_debug_PopStack "IGCM_sys_rebuild"
1258}
1259
1260############################################################
1261# Activate Running Environnment Variables
1262
1263function IGCM_sys_activ_variables {
1264    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1265    if ( $DEBUG_sys ) ; then
1266        echo "IGCM_sys_activ_variables"
1267    fi
1268    ulimit -s 2097152
1269    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1270}
1271
1272############################################################
1273# Desactivate Running Environnment Variables
1274
1275function IGCM_sys_desactiv_variables {
1276    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1277    if ( $DEBUG_sys ) ; then
1278        echo "IGCM_sys_desactiv_variables"
1279    fi
1280    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1281}
1282
1283############################################################
1284# Build run file
1285
1286function IGCM_sys_build_run_file {
1287    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1288    if ( $DEBUG_sys ) ; then
1289        echo "IGCM_sys_build_run_file " $@
1290    fi
1291
1292    # set Number of processors for OCE here
1293    NUM_PROC_OCE=5
1294
1295    (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE - 1))
1296    (( nb_tot_m1    = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE ))
1297    if [ $1 = MPI1 ]; then
1298        cat <<EOF > run_file
1299-np 1 ./oasis
1300-np ${NUM_PROC_ATM} ./lmdz.x
1301-np ${NUM_PROC_OCE} ./opa.xx
1302EOF
1303        config_UserChoices_JobRunOptions='"--app"'
1304        IGCM_sys_Chmod u+x run_file
1305    fi
1306    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1307 
1308}
1309
1310##############################################################
1311# NCO OPERATOR
1312
1313function IGCM_sys_ncatted {
1314    IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1315    if ( $DEBUG_sys ) ; then
1316        echo "IGCM_sys_ncatted :" $@
1317    fi
1318    ncatted "$@"
1319    if [ $? -gt 0 ] ; then
1320       echo "IGCM_sys_ncatted : erreur ${@}."
1321       IGCM_debug_Exit "ncatted"
1322    fi
1323
1324    IGCM_debug_PopStack "IGCM_sys_ncatted"
1325}
1326
1327function IGCM_sys_ncbo {
1328    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1329    if ( $DEBUG_sys ) ; then
1330        echo "IGCM_sys_ncbo :" $@
1331    fi
1332    ncbo $@
1333    if [ $? -gt 0 ] ; then
1334       echo "IGCM_sys_ncbo : erreur ${@}."
1335       IGCM_debug_Exit "ncbo"
1336    fi
1337
1338    IGCM_debug_PopStack "IGCM_sys_ncbo"
1339}
1340
1341function IGCM_sys_ncdiff {
1342    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1343    if ( $DEBUG_sys ) ; then
1344        echo "IGCM_sys_ncdiff :" $@
1345    fi
1346    ncdiff $@
1347    if [ $? -gt 0 ] ; then
1348       echo "IGCM_sys_ncdiff : erreur ${@}."
1349       IGCM_debug_Exit "ncdiff"
1350    fi
1351
1352    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1353}
1354
1355function IGCM_sys_ncea {
1356    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1357    if ( $DEBUG_sys ) ; then
1358        echo "IGCM_sys_ncea :" $@
1359    fi
1360    ncea $@
1361    if [ $? -gt 0 ] ; then
1362       echo "IGCM_sys_ncea : erreur ${@}."
1363       IGCM_debug_Exit "ncea"
1364    fi
1365
1366    IGCM_debug_PopStack "IGCM_sys_ncea"
1367}
1368
1369function IGCM_sys_ncecat {
1370    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1371    if ( $DEBUG_sys ) ; then
1372        echo "IGCM_sys_ncecat :" $@
1373    fi
1374    ncecat $@
1375    if [ $? -gt 0 ] ; then
1376       echo "IGCM_sys_ncecat : erreur ${@}."
1377       IGCM_debug_Exit "ncecat"
1378    fi
1379
1380    IGCM_debug_PopStack "IGCM_sys_ncecat"
1381}
1382
1383function IGCM_sys_ncflint {
1384    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1385    if ( $DEBUG_sys ) ; then
1386        echo "IGCM_sys_ncflint :" $@
1387    fi
1388    ncflint $@
1389    if [ $? -gt 0 ] ; then
1390       echo "IGCM_sys_ncflint : erreur ${@}."
1391       IGCM_debug_Exit "ncflint"
1392    fi
1393
1394    IGCM_debug_PopStack "IGCM_sys_ncflint"
1395}
1396
1397function IGCM_sys_ncks {
1398    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1399    if ( $DEBUG_sys ) ; then
1400        echo "IGCM_sys_ncks :" $@
1401    fi
1402    ncks $@
1403    if [ $? -gt 0 ] ; then
1404       echo "IGCM_sys_ncks : erreur ${@}."
1405       IGCM_debug_Exit "ncks"
1406    fi
1407
1408    IGCM_debug_PopStack "IGCM_sys_ncks"
1409}
1410
1411function IGCM_sys_ncpdq {
1412    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1413    if ( $DEBUG_sys ) ; then
1414        echo "IGCM_sys_ncpdq :" $@
1415    fi
1416    ncpdq $@
1417    if [ $? -gt 0 ] ; then
1418       echo "IGCM_sys_ncpdq : erreur ${@}."
1419       IGCM_debug_Exit "ncpdq"
1420    fi
1421
1422    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1423}
1424
1425function IGCM_sys_ncra {
1426    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1427    if ( $DEBUG_sys ) ; then
1428        echo "IGCM_sys_ncra :" $@
1429    fi
1430    ncra $@
1431    if [ $? -gt 0 ] ; then
1432       echo "IGCM_sys_ncra : erreur ${@}."
1433       IGCM_debug_Exit "ncra"
1434    fi
1435
1436    IGCM_debug_PopStack "IGCM_sys_ncra"
1437}
1438
1439function IGCM_sys_ncrcat {
1440    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1441    if ( $DEBUG_sys ) ; then
1442        echo "IGCM_sys_ncrcat :" $@
1443    fi
1444    ncrcat $@
1445    if [ $? -gt 0 ] ; then
1446       echo "IGCM_sys_ncrcat : erreur ${@}."
1447#       IGCM_debug_Exit "ncrcat"
1448    fi
1449
1450    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1451}
1452
1453function IGCM_sys_ncrename {
1454    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1455    if ( $DEBUG_sys ) ; then
1456        echo "IGCM_sys_ncrename :" $@
1457    fi
1458    ncrename $@
1459    if [ $? -gt 0 ] ; then
1460       echo "IGCM_sys_ncrename : erreur ${@}."
1461       IGCM_debug_Exit "ncrename"
1462    fi
1463
1464    IGCM_debug_PopStack "IGCM_sys_ncrename"
1465}
1466
1467function IGCM_sys_ncwa {
1468    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1469    if ( $DEBUG_sys ) ; then
1470        echo "IGCM_sys_ncwa :" $@
1471    fi
1472    ncwa $@
1473    if [ $? -gt 0 ] ; then
1474       echo "IGCM_sys_ncwa : erreur ${@}."
1475       IGCM_debug_Exit "ncwa"
1476    fi
1477
1478    IGCM_debug_PopStack "IGCM_sys_ncwa"
1479}
Note: See TracBrowser for help on using the repository browser.