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

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

titane : use titane's mail.

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