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

Last change on this file since 1456 was 552, checked in by mafoipsl, 12 years ago

titae : delete useless lines to send Mail.

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