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

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