source: tags/libIGCM_v1_8-old/libIGCM_sys/libIGCM_sys_vargas.ksh

Last change on this file was 288, checked in by mafoipsl, 14 years ago

Add SUBLIT_DIR in messgae snt at the end of each simulation. Complete messages in clean_month.

  • Property svn:keywords set to Date Author Revision
File size: 31.5 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sébastien Denvil
5# Contact: sebastien.denvil.@ipsl.jussieu.fr
6# $Date$
7# $Author$
8# $Revision$
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11# History:
12# Modification:
13#
14#**************************************************************
15
16#=========================================================
17# The documentation of this file can be automatically generated
18# if you use the prefix #D- for comments to be extracted.
19# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
20#=========================================================
21
22#D-#==================================================
23#D-LibIGCM_sys for Vargas
24#D-#==================================================
25#D-
26#D- This ksh library if a layer under some usefull
27#D-environment variables and shell commands.
28#D-All those definitions depend on host particularities.
29#D-It manages a stack mechanism and test validity of operations.
30#D-All function described bellow must be prefixed by IGCM_sys.
31
32#====================================================
33# libIGCM_sys PARAMETERS
34#====================================================
35
36#====================================================
37# set DEBUG_sys to true to output calls of function
38typeset -r DEBUG_sys=${DEBUG_sys:=true}
39
40#====================================================
41# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
42typeset -r DRYRUN=${DRYRUN:=0}
43
44# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
45# -------------------------------------------------------------------------------------
46# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
47# |          |  Cp/Exe param files |            |  Chmod  |                           |
48# |          |      Qsub           |            |         |                           |
49# -------------------------------------------------------------------------------------
50# |    0     |       yes           |    yes     |  yes    |      yes                  |
51# -------------------------------------------------------------------------------------
52# |    1     |       yes           |    yes     |  yes    |      no                   |
53# -------------------------------------------------------------------------------------
54# |    2     |       yes           |    yes     |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56# |    3     |       yes           |    no      |  no     |      no                   |
57# -------------------------------------------------------------------------------------
58
59#=====================================================
60# Global Variables :
61#=====================================================
62# Language : "fr" or "en"
63typeset -r MYLANG="fr"
64
65#=====================================================
66# Host and user names
67# $hostname ou hostname
68typeset  HOST=${HOST:=$( hostname )}
69# $username ou whoami
70typeset  LOGIN=${LOGIN:=$( whoami )}
71# $hostname of the MASTER job
72typeset -r MASTER=vargas
73
74#D-
75#D-#==================================================
76#D-Program used in libIGCM
77#D-#==================================================
78
79# rsync with path
80typeset -r RSYNC=/usr/local/bin/rsync
81# RSYNC_opt args to rsync
82typeset -r RSYNC_opt="-va"
83# ie storage filesystem
84typeset -r RHOST=gaya.idris.fr
85typeset -r REMOTE_RSYNC=/u/rech/ces/rces452/RSYNC/bin/rsync
86
87#====================================================
88# Host specific DIRECTORIES
89#====================================================
90
91#====================================================
92#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
93typeset -r R_EXE="${MODIPSL}/bin"
94
95#====================================================
96#- SUBMIT_DIR : submission dir
97typeset SUBMIT_DIR=${SUBMIT_DIR:=${LOADL_STEP_INITDIR}}
98
99#====================================================
100#- ARCHIVE
101typeset -r ARCHIVE=$( echo ${HOME} | sed -e "s/homegpfs/u/" )
102
103#====================================================
104#- Mirror libIGCM from vargas to ulam
105typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true}
106
107#====================================================
108#- libIGCM_POST
109PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" )
110typeset -r HOME_POST=$( echo ${HOME} | sed -e "s/homegpfs/home/" )
111typeset -r libIGCM_POST=${HOME_POST}/MIRROR/${PATHlibIGCM}/libIGCM
112
113#====================================================
114#- IN
115typeset -r R_IN=${R_IN:=/u/rech/psl/rpsl035/IGCM}
116
117#====================================================
118#- OUT
119typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
120
121#====================================================
122#- OUT_POST
123typeset -r R_OUT_POST=$( echo ${HOME} | sed -e "s/homegpfs/workdir/" )/IGCM_OUT
124
125#====================================================
126#- RUN_DIR_PATH : Temporary working directory (=> TMP)
127typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${TMPDIR}}
128
129#====================================================
130#- BIG_DIR : BIG_DIR to store files waiting for rebuild
131typeset -r BIG_DIR=${BIG_DIR:=${WORKDIR}}
132
133#====================================================
134#- HOST_MPIRUN_COMMAND
135typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time poe"}
136
137#====================================================
138#- Max number of arguments passed to nco operator or demigration command
139UNIX_MAX_LIMIT=360
140
141#D-#==================================================
142#D-function IGCM_sys_RshArchive
143#D-* Purpose: Archive rsh command
144#D-* Examples:
145#D-
146function IGCM_sys_RshArchive {
147    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
148    rsh gaya exec /bin/ksh <<-EOF
149    ${@}
150EOF
151    if [ $? -gt 0 ] ; then
152        echo "IGCM_sys_RshArchive : erreur."
153        IGCM_debug_Exit "IGCM_sys_RshArchive"
154    fi
155    IGCM_debug_PopStack "IGCM_sys_RshArchive"
156}
157
158#D-#==================================================
159#D-function IGCM_sys_RshPost
160#D-* Purpose: Post-process rsh command
161#D-* Examples:
162#D-
163function IGCM_sys_RshPost {
164    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
165    if ( $DEBUG_sys ) ; then
166        echo "IGCM_sys_RshPost :" $@
167    fi
168    rsh ulam exec /bin/ksh ${@}
169    if [ $? -gt 0 ] ; then
170        echo "IGCM_sys_RshPost : erreur."
171        IGCM_debug_Exit "IGCM_sys_RshPost"
172    fi
173    IGCM_debug_PopStack "IGCM_sys_RshPost"
174}
175
176#D-#==================================================
177#D-function IGCM_sys_SendMail
178#D-* Purpose: Send mail when simulation is over
179#D-* Examples:
180#D-
181function IGCM_sys_SendMail {
182    IGCM_debug_PushStack "IGCM_sys_SendMailPost" $@
183    if ( $DEBUG_sys ) ; then
184        echo "IGCM_sys_SendMail :" $@
185    fi
186    cat  << END_MAIL > job_end.mail
187Dear ${LOGIN},
188
189  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
190  Job started : ${DateBegin}
191  Job ended   : ${DateEnd}
192  Ouput files are available in ${R_SAVE}
193  Script files and Script Outputs are available in ${SUBMIT_DIR}
194END_MAIL
195
196    if [ ! -z ${config_UserChoices_MailName} ] ; then
197        mailx -s "${config_UserChoices_JobName} completed" ${config_UserChoices_MailName} <  job_end.mail
198    elif [ -f ~/.forward ] ; then
199        mailx -s "${config_UserChoices_JobName} completed" $( cat ~/.forward ) < job_end.mail
200    else
201        mailx -s "${config_UserChoices_JobName} completed" ${USER} < job_end.mail
202    fi
203
204    if [ $? -gt 0 ] ; then
205        echo "IGCM_sys_SendMail : erreur."
206        IGCM_debug_Exit "IGCM_sys_SendMail"
207    fi
208    IGCM_debug_PopStack "IGCM_sys_SendMail"
209}
210
211#D-#==================================================
212#D-function IGCM_sys_Mkdir
213#D-* Purpose: Master locale mkdir command
214#D-* Examples:
215#D-
216function IGCM_sys_Mkdir {
217    IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
218    if ( $DEBUG_sys ) ; then
219        echo "IGCM_sys_Mkdir :" $@
220    fi
221    if [ ! -d ${1} ]; then
222        \mkdir -p $1
223        if [ $? -gt 0 ] ; then
224            echo "IGCM_sys_Mkdir : erreur."
225            IGCM_debug_Exit "IGCM_sys_Mkdir"
226        fi
227    fi
228    # vérification :
229    if [ ! -d ${1} ] ; then
230        echo "IGCM_sys_Mkdir : erreur."
231        IGCM_debug_Exit "IGCM_sys_Mkdir"
232    fi
233    IGCM_debug_PopStack "IGCM_sys_Mkdir"
234}
235
236#D-#==================================================
237#D-function IGCM_sys_MkdirArchive
238#D-* Purpose: Mkdir on Archive
239#D-* Examples:
240#D-
241function IGCM_sys_MkdirArchive {
242    IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
243    if ( $DEBUG_sys ) ; then
244        echo "IGCM_sys_MkdirArchive :" $@
245    fi
246    #- creation de repertoire sur le serveur fichier
247    rsh gaya -n mkdir -p $1
248
249    if [ $? -gt 0 ] ; then
250        echo "IGCM_sys_MkdirArchive : erreur."
251        IGCM_debug_Exit "IGCM_sys_MkdirArchive"
252    fi
253    IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
254}
255
256#D-#==================================================
257#D-function IGCM_sys_MkdirWork
258#D-* Purpose: Mkdir on Work
259#D-* Examples:
260#D-
261function IGCM_sys_MkdirWork {
262    IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
263    if ( $DEBUG_sys ) ; then
264        echo "IGCM_sys_MkdirWork :" $@
265    fi
266    #- creation de repertoire sur le serveur fichier
267    if [ ! -d ${1} ]; then 
268        \mkdir -p $1
269        if [ $? -gt 0 ] ; then
270            echo "IGCM_sys_MkdirWork : erreur."
271            IGCM_debug_Exit "IGCM_sys_MkdirWork"
272        fi
273    fi
274    IGCM_debug_PopStack "IGCM_sys_MkdirWork"
275}
276
277#D-#==================================================
278#D-function IGCM_sys_Cd
279#D-* Purpose: master cd command
280#D-* Examples:
281#D-
282function IGCM_sys_Cd {
283    IGCM_debug_PushStack "IGCM_sys_Cd" $@
284    if ( $DEBUG_sys ) ; then
285        echo "IGCM_sys_Cd :" $@
286    fi
287    \cd $1
288    if [ $? -gt 0 ] ; then
289        echo "IGCM_sys_Cd : erreur."
290        IGCM_debug_Exit "IGCM_sys_Cd"
291    fi
292    IGCM_debug_PopStack "IGCM_sys_Cd"
293}
294
295#D-#==================================================
296#D-function IGCM_sys_Chmod
297#D-* Purpose: Chmod
298#D-* Examples:
299#D-
300function IGCM_sys_Chmod {
301    IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
302    if ( $DEBUG_sys ) ; then
303        echo "IGCM_sys_Chmod :" $@
304    fi
305    if [ $DRYRUN -le 1 ]; then
306        \chmod $@
307        if [ $? -gt 0 ] ; then
308            echo "IGCM_sys_Chmod : erreur."
309            IGCM_debug_Exit "IGCM_sys_Chmod"
310        fi
311    else
312        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
313    fi
314    IGCM_debug_PopStack "IGCM_sys_Chmod"
315}
316
317#D-#==================================================
318#D-function IGCM_sys_FileSize
319#D-* Purpose: Filesize
320#D-* Examples:
321#D-
322function IGCM_sys_FileSize {
323    IGCM_debug_PushStack "IGCM_sys_FileSize" $@
324
325    typeset sizeF
326    set +A sizeF -- $( ls -la ${1} )
327    if [ $? -gt 0 ] ; then
328        IGCM_debug_Exit "IGCM_sys_FileSize"
329    fi
330    eval ${2}=${sizeF[4]}
331
332    IGCM_debug_PopStack "IGCM_sys_FileSize"
333}
334
335#D-#==================================================
336#D-function IGCM_sys_TestDir
337#D-* Purpose: Test Directory that must exists
338#D-* Examples:
339#D-
340function IGCM_sys_TestDir {
341    IGCM_debug_PushStack "IGCM_sys_TestDir" $@
342    if ( $DEBUG_sys ) ; then
343        echo "IGCM_sys_TestDir :" $@
344    fi
345    typeset ExistFlag
346    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
347    IGCM_debug_PopStack "IGCM_sys_TestDir"
348
349    return ${ExistFlag}
350}
351
352#D-#==================================================
353#D-function IGCM_sys_TestDirArchive
354#D-* Purpose: Test Directory that must exists on Archive
355#D-* Examples:
356#D-
357function IGCM_sys_TestDirArchive {
358    IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
359    if ( $DEBUG_sys ) ; then
360        echo "IGCM_sys_TestDirArchive :" $@
361    fi
362    typeset ExistFlag
363    ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" )
364    IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
365
366    return ${ExistFlag}
367}
368
369#D-#==================================================
370#D-function IGCM_sys_TestFileArchive
371#D-* Purpose: Test file that must NOT EXISTS on Archive
372#D-* Examples:
373#D-
374function IGCM_sys_TestFileArchive {
375    IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
376    typeset ExistFlag
377    ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" )
378    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
379
380    return ${ExistFlag}
381}
382
383#D-#==================================================
384#D-function IGCM_sys_CountFileArchive
385#D-* Purpose: Count files on Archive filesystem
386#D-* Examples:
387#D-
388function IGCM_sys_CountFileArchive {
389    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
390    IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l"
391    if [ $? -gt 0 ] ; then
392        echo "IGCM_sys_CountFileArchive : erreur."
393    fi
394    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
395}
396
397#D-#==================================================
398#D-function IGCM_sys_Tree
399#D-* Purpose: Tree directories with files on ${ARCHIVE}
400#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
401#D-
402function IGCM_sys_Tree {
403    IGCM_debug_PushStack "IGCM_sys_Tree" $@
404    if ( $DEBUG_sys ) ; then
405        echo "IGCM_sys_Tree :" $@
406    fi
407
408    \mfls -r $@
409
410    IGCM_debug_PopStack "IGCM_sys_Tree"
411}
412
413#D-#==================================================
414#D-function IGCM_sys_Tar
415#D-* Purpose: master un-tar command
416#D-* Examples:
417#D-
418function IGCM_sys_Tar {
419    IGCM_debug_PushStack "IGCM_sys_Tar" $@
420    if ( $DEBUG_sys ) ; then
421        echo "IGCM_sys_Tar :" $@
422    fi
423    \tar cvf $@
424    if [ $? -gt 0 ] ; then
425        echo "IGCM_sys_Tar : erreur."
426        IGCM_debug_Exit "IGCM_sys_Tar"
427    fi
428    \tar tvf $1
429
430    IGCM_debug_PopStack "IGCM_sys_Tar"
431}
432
433#D-#==================================================
434#D-function IGCM_sys_UnTar
435#D-* Purpose: master un-tar command
436#D-* Examples:
437#D-
438function IGCM_sys_UnTar {
439    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
440    if ( $DEBUG_sys ) ; then
441        echo "IGCM_sys_UnTar :" $@
442    fi
443    \tar xvf $1
444    if [ $? -gt 0 ] ; then
445        echo "IGCM_sys_UnTar : erreur."
446        IGCM_debug_Exit "IGCM_sys_UnTar"
447    fi
448    IGCM_debug_PopStack "IGCM_sys_UnTar"
449}
450
451#D-#==================================================
452#D-function IGCM_sys_Qsub
453#D-* Purpose: Qsub new job
454#D-* Examples:
455#D-
456function IGCM_sys_Qsub {
457    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
458    if ( $DEBUG_sys ) ; then
459        echo "IGCM_sys_Qsub :" $@
460    fi
461    {
462      [ ${#@} = 1 ] &&  { cd $LOADL_STEP_INITDIR ; /usr/local/bin/llsubmit $1 ; ERROR=$? ; cd - ; }
463      [ ${#@} = 2 ] &&  { cd $2 ; /usr/local/bin/llsubmit $1 ; ERROR=$? ; cd - ; }
464    }
465    if [ ${ERROR} -gt 0 ] ; then
466        echo "IGCM_sys_Qsub : erreur $@."
467        IGCM_debug_Exit "IGCM_sys_Qsub"
468    fi
469    IGCM_debug_PopStack "IGCM_sys_Qsub"
470}
471
472#D-#==================================================
473#D-function IGCM_sys_QsubPost
474#D-* Purpose: Qsub new job on scalaire
475#D-* Examples:
476#D-
477function IGCM_sys_QsubPost {
478    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
479    if ( $DEBUG_sys ) ; then
480        echo "IGCM_sys_QsubPost :" $@
481    fi
482    cd ${POST_DIR}
483    /opt/ibmll/LoadL/full/bin/llsubmit ${libIGCM_POST}/$1.job
484    cd -
485    if [ $? -gt 0 ] ; then
486        echo "IGCM_sys_QsubPost : erreur " $@
487        IGCM_debug_Exit "IGCM_sys_QsubPost"
488    fi
489    IGCM_debug_PopStack "IGCM_sys_QsubPost"
490}
491
492#D-*************************
493#D- File transfer functions
494#D-*************************
495#D-
496
497#D-#==================================================
498#D-function IGCM_sys_Rsync_out
499#D-* Purpose: treat return val of rsync
500#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
501#D-  Error values and explanations can depend on your system version.
502function IGCM_sys_Rsync_out {
503    RET=$1
504    if [ ! $RET ] ; then
505        echo "rsync error !"
506    fi
507
508    if [ $MYLANG = "fr" ]; then
509        case $RET in
510            0)  return ;;
511            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
512                echo "Erreur de syntaxe ou d'utilisation."
513                return;;
514            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
515                echo "Incompatibilité de protocole."
516                return;;
517            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
518                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
519                echo "répertoires"
520                return;;
521            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
522                echo "Action demandée non supportée : une tentative de manipulation de"
523                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
524                echo "été faite ; ou une option qui est supportée par le  client  mais"
525                echo "pas par le serveur a été spécifiée."
526                return;;
527            10) echo "Erreur de rsync ; RERR_SOCKETIO"
528                echo "Erreur dans le socket d'entrée sortie"
529                return;;
530            11) echo "Erreur de rsync ; RERR_FILEIO"
531                echo "Erreur d'entrée sortie fichier"
532                return;;
533            12) echo "Erreur de rsync ; RERR_STREAMIO"
534                echo "Erreur dans flux de donnée du protocole rsync"
535                return;;
536            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
537                echo "Erreur avec les diagnostics du programme"
538                return;;
539            14) echo "Erreur de rsync ; RERR_IPC"
540                echo "Erreur dans le code IPC"
541                return;;
542            20) echo "Erreur de rsync ; RERR_SIGNAL"
543                echo "SIGUSR1 ou SIGINT reçu"
544                return;;
545            21) echo "Erreur de rsync ; RERR_WAITCHILD"
546                echo "Une erreur retournée par waitpid()"
547                return;;
548            22) echo "Erreur de rsync ; RERR_MALLOC"
549                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
550                return;;
551            23) echo ""
552                echo "Erreur fichier inexistant"
553                return;;
554            30) echo "Erreur de rsync ; RERR_TIMEOUT"
555                echo "Temps d'attente écoulé dans l'envoi/réception de données"
556                return;;
557            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
558                return;;
559        esac
560    elif [ $MYLANG = "en" ] ; then
561        case $RET in
562            0)  return;;               
563            1)  echo "rsync error : Syntax or usage error "
564                return;;
565            2)  echo "rsync error : Protocol incompatibility "
566                return;;
567            3)  echo "rsync error : Errors selecting input/output files, dirs"
568                return;;
569            4)  echo "rsync error : Requested action not supported: an attempt"
570                echo "was made to manipulate 64-bit files on a platform that cannot support"
571                echo "them; or an option was specified that is supported by the client and"
572                echo "not by the server."
573                return;;
574            5)  echo "rsync error : Error starting client-server protocol"
575                return;;
576            10) echo "rsync error : Error in socket I/O "
577                return;;
578            11) echo "rsync error : Error in file I/O "
579                return;;
580            12) echo "rsync error : Error in rsync protocol data stream "
581                return;;
582            13) echo "rsync error : Errors with program diagnostics "
583                return;;
584            14) echo "rsync error : Error in IPC code "
585                return;;
586            20) echo "rsync error : Received SIGUSR1 or SIGINT "
587                return;;
588            21) echo "rsync error : Some error returned by waitpid() "
589                return;;
590            22) echo "rsync error : Error allocating core memory buffers "
591                return;;
592            23) echo "rsync error : Partial transfer due to error"
593                return;;
594            24) echo "rsync error : Partial transfer due to vanished source files"
595                return;;
596            30) echo "rsync error : Timeout in data send/receive "
597                return;;
598            *)  echo "rsync error : return code of rsync unknown :" $RET
599                return;;
600        esac
601    else
602        echo "unknown language $MYLANG."
603        return
604    fi
605}
606   
607
608#D-#==================================================
609#D-function IGCM_sys_Miror_libIGCM
610#D-* Purpose: Mirror libIGCM PATH and lib to ulam
611#D-* Examples:
612#D-
613function IGCM_sys_Mirror_libIGCM {
614    IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
615    if ( $DEBUG_sys ) ; then
616        echo "IGCM_sys_Mirror_libIGCM"
617    fi
618
619    typeset RET
620
621    IGCM_sys_RshPost <<-EOF
622    mkdir -p ${HOME_POST}/MIRROR/${PATHlibIGCM}
623EOF
624    rsh ulam -n hostname > /dev/null 2>&1
625    RET=$?
626    if [ $RET -eq 0 ] ; then
627        echo ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME_POST}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
628        ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME_POST}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
629        RET=$?
630
631        if [ ${RET} -gt 0 ] ; then
632            echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on ulam."
633            cat out_rsync
634        fi
635    else
636        echo "No POST-TREATMENT avaible because ulam is down."
637    fi
638    IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
639}
640
641#====================================================
642#- Call IGCM_sys_Mirror_libIGCM now !
643if ( $MirrorlibIGCM ) ; then
644    IGCM_sys_Mirror_libIGCM
645fi
646
647#D-#==================================================
648#D-function IGCM_sys_Cp
649#D-* Purpose: generic cp
650#D-* Examples:
651#D-
652function IGCM_sys_Cp {
653    IGCM_debug_PushStack "IGCM_sys_Cp" $@
654    if ( $DEBUG_sys ) ; then
655        echo "IGCM_sys_Cp :" $@
656    fi
657
658    typeset RET
659
660    echo cp $@ > out_rsync 2>&1
661    \cp $@ >> out_rsync 2>&1
662    RET=$?
663
664    if [ ${RET} -gt 0 ] ; then
665        echo "IGCM_sys_Cp : error."
666        cat out_rsync
667        IGCM_debug_Exit "IGCM_sys_Cp"
668    fi
669    IGCM_debug_PopStack "IGCM_sys_Cp"
670}
671
672#D-#==================================================
673#D-function IGCM_sys_Rm
674#D-* Purpose: generic rm
675#D-* Examples:
676#D-
677function IGCM_sys_Rm {
678    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
679    if ( $DEBUG_sys ) ; then
680        echo "IGCM_sys_Rm :" $@
681    fi
682
683    typeset RET
684
685    echo rm $@ > out_rsync 2>&1
686    \rm $@ >> out_rsync 2>&1
687    RET=$?
688
689    if [ ${RET} -gt 0 ] ; then
690        echo "IGCM_sys_Rm : error."
691        cat out_rsync
692        IGCM_debug_Exit "IGCM_sys_Rm"
693    fi
694    IGCM_debug_PopStack "IGCM_sys_Rm"
695}
696
697#D-#==================================================
698#D-function IGCM_sys_RmRunDir
699#D-* Purpose: rm tmpdir (dummy function most of the time batch
700#D-                      scheduler will do the job)
701#D-* Examples:
702#D-
703function IGCM_sys_RmRunDir {
704    IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
705    if ( $DEBUG_sys ) ; then
706        echo "IGCM_sys_RmRunDir :" $@
707        echo "Dummy call, let the scheduler do that."
708    fi
709    IGCM_debug_PopStack "IGCM_sys_RmRunDir"
710}
711
712#D-#==================================================
713#D-function IGCM_sys_Mv
714#D-* Purpose: generic move
715#D-* Examples:
716#D-
717function IGCM_sys_Mv {
718    IGCM_debug_PushStack "IGCM_sys_Mv" $@
719    if ( $DEBUG_sys ) ; then
720        echo "IGCM_sys_Mv :" $@
721    fi
722
723    if [ $DRYRUN = 0 ]; then
724
725        typeset RET
726           
727        echo mv $@ > out_rsync 2>&1
728        \mv $@ >> out_rsync 2>&1
729        RET=$?
730   
731        if [ ${RET} -gt 0 ] ; then
732            echo "IGCM_sys_Mv : error in mv."
733            cat out_rsync
734            IGCM_debug_Exit "IGCM_sys_Mv"
735        fi
736    else
737        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
738    fi
739
740    IGCM_debug_PopStack "IGCM_sys_Mv"
741}
742
743#D-#==================================================
744#D-function IGCM_sys_Put_Dir
745#D-* Purpose: Copy a complete directory on $(ARCHIVE)
746#D-* Examples:
747#D-
748function IGCM_sys_Put_Dir {
749    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
750    if ( $DEBUG_sys ) ; then
751        echo "IGCM_sys_Put_Dir :" $@
752    fi
753    if [ $DRYRUN = 0 ]; then
754        if [ ! -d ${1} ] ; then
755            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
756            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
757            return
758        fi
759
760        typeset RET
761
762        # Only if we use rsync
763        #IGCM_sys_TestDirArchive $( dirname $2 )
764        #
765        #USUAL WAY
766        rcp -r $1 gaya:$2 > out_rsync 2>&1
767        RET=$?
768
769        if [ ${RET} -gt 0 ] ; then
770            echo "IGCM_sys_Put_Dir : error."
771            cat out_rsync
772            IGCM_debug_Exit "IGCM_sys_Put_Dir"
773        fi
774    else
775        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
776    fi
777    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
778}
779
780#D-#==================================================
781#D-function IGCM_sys_Get_Dir
782#D-* Purpose: Copy a complete directory from $(ARCHIVE)
783#D-* Examples:
784#D-
785function IGCM_sys_Get_Dir {
786    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
787    if ( $DEBUG_sys ) ; then
788        echo "IGCM_sys_Get_Dir :" $@
789    fi
790    if [ $DRYRUN = 0 ]; then
791        if [ ! -d ${1} ] ; then
792            echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
793            IGCM_debug_PopStack "IGCM_sys_Get_Dir"
794            return
795        fi
796
797        typeset RET
798
799        #USUAL WAY
800        rcp -rp gaya:$1 $2 > out_rsync 2>&1
801        RET=$?
802
803        if [ ${RET} -gt 0 ] ; then
804            echo "IGCM_sys_Get_Dir : error."
805            cat out_rsync
806            IGCM_debug_Exit "IGCM_sys_Get_Dir"
807        fi
808    else
809        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
810    fi
811    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
812}
813
814#D-#==================================================
815#D-function IGCM_sys_Put_Rest
816#D-* Purpose: Put computied restarts on $(ARCHIVE).
817#D-           File and target directory must exist.
818#D-* Examples:
819#D-
820function IGCM_sys_Put_Rest {
821    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
822    if ( $DEBUG_sys ) ; then
823        echo "IGCM_sys_Put_Rest :" $@
824    fi
825    if [ $DRYRUN = 0 ]; then
826        if [ ! -f ${1} ] ; then
827            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
828            IGCM_debug_Exit "IGCM_sys_Put_Rest"
829        fi
830
831        typeset RET
832        #
833        if [ X${JobType} = XRUN ] ; then
834            IGCM_sys_Chmod 444 ${1}
835        fi
836        #
837        # Only if we use rsync
838        #IGCM_sys_MkdirArchive $( dirname $2 )
839        #
840        #USUAL WAY
841        mfput $1 $2 > out_rsync 2>&1
842        RET=$?
843
844#       #RSYNC WITH NETWORK RSH CALL
845#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
846#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
847
848#       #RSYNC WITH NFS USE
849#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
850#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
851       
852#       RET=$?
853#       IGCM_sys_Rsync_out $RET
854
855#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
856#       (( RET=RET+$? ))
857
858        if [ ${RET} -gt 0 ] ; then
859            echo "IGCM_sys_Put_Rest : error."
860            cat out_rsync
861            IGCM_debug_Exit "IGCM_sys_Put_Rest"
862        fi
863    else
864        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
865    fi
866    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
867}
868
869#D-#==================================================
870#D-function IGCM_sys_Put_Out
871#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
872#D-* Examples:
873#D-
874function IGCM_sys_Put_Out {
875    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
876    if ( $DEBUG_sys ) ; then
877        echo "IGCM_sys_Put_Out :" $@
878    fi
879    if [ $DRYRUN = 0 ]; then
880        if [ ! -f ${1} ] ; then
881            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
882            IGCM_debug_PopStack "IGCM_sys_Put_Out"
883            return 1
884        fi
885
886        typeset RET
887        #
888        if [ X${JobType} = XRUN ] ; then
889            if [ X${3} = X ] ; then
890                IGCM_sys_Chmod 444 ${1}
891            fi
892        fi
893        #
894        # Only if we use rsync
895        #IGCM_sys_MkdirArchive $( dirname $2 )
896        #
897        #USUAL WAY
898        mfput $1 $2 > out_rsync 2>&1
899        RET=$?
900
901#       #RSYNC WITH NETWORK RSH CALL
902#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
903#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
904
905#       #RSYNC WITH NFS USE
906#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
907#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
908
909#       RET=$?
910#       IGCM_sys_Rsync_out $RET
911
912#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
913#       (( RET=RET+$? ))
914
915        if [ ${RET} -gt 0 ] ; then
916            echo "IGCM_sys_Put_Out : error."
917            cat out_rsync
918            IGCM_debug_Exit "IGCM_sys_Put_Out"
919        fi
920    else
921        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
922    fi
923    IGCM_debug_PopStack "IGCM_sys_Put_Out"
924    return 0
925}
926
927#D-#==================================================
928#D-function IGCM_sys_Get
929#D-* Purpose: Get a file from ${ARCHIVE}
930#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
931#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
932function IGCM_sys_Get {
933    IGCM_debug_PushStack "IGCM_sys_Get" $@
934
935    typeset DEST RET dm_liste ifile target
936
937    if ( $DEBUG_sys ) ; then
938        echo "IGCM_sys_Get :" $@
939    fi
940    if [ $DRYRUN -le 2 ]; then
941        if [ X${1} = X'/l' ] ; then
942            # test if the first file is present in the old computation :
943            eval set +A dm_liste \${${2}}
944        else
945            dm_liste=${1}
946        fi
947        eval DEST=\${${#}}
948
949        # test if the (first) file is present in the old computation :
950        IGCM_sys_TestFileArchive ${dm_liste[0]}
951        RET=$?
952        if [ ${RET} -gt 0 ] ; then
953            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
954            IGCM_debug_Exit "IGCM_sys_Get"
955            return
956        fi
957
958        # SD : dm_liste is not suited for computing job
959        #      because we change filename during transfert
960        #      dm_liste is better suited for post-treatment
961        #dm_liste=" "
962        #(( ifile=1 ))
963        #while [ $ifile -lt $# ] ; do
964        #    dm_liste=$( eval echo ${dm_liste} " "\${${ifile}} )
965        #    (( ifile = ifile + 1 ))
966        #done
967        #DEST=$( eval echo \${${#}} )
968
969        #USUAL WAY
970        mfget ${dm_liste[*]} ${DEST} > out_rsync 2>&1
971        #mfget $1 $2 > out_rsync 2>&1
972        RET=$?
973
974#       #RSYNC WITH NETWORK RSH CALL
975#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
976#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
977
978#       #RSYNC WITH NFS USE
979#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
980#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
981
982#       RET=$?
983#       IGCM_sys_Rsync_out $RET
984
985#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
986#       (( RET=RET+$? ))
987
988        if [ ${RET} -gt 0 ] ; then
989            echo "IGCM_sys_Get : copy error."
990            cat out_rsync
991            IGCM_debug_Exit "IGCM_sys_Get"
992        fi
993    else
994        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
995    fi
996    IGCM_debug_PopStack "IGCM_sys_Get"
997}
998
999############################################################## A FINIR !!
1000
1001#D-#==================================================
1002#D-function IGCM_sys_GetDate_FichWork
1003#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1004#D-* Examples:
1005#D-
1006function IGCM_sys_GetDate_FichWork {
1007    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1008    if ( $DEBUG_sys ) ; then
1009        echo "IGCM_sys_GetDate_FichWork :" $@
1010    fi
1011    # donne la date filesys d'un fichier sur la machine work
1012    IGCM_debug_PopStack "IGCM_sys_FichWork"
1013}
1014
1015#D-#==================================================
1016#D-function IGCM_sys_GetDate_FichArchive
1017#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1018#D-* Examples:
1019#D-
1020function IGCM_sys_GetDate_FichArchive {
1021    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1022    if ( $DEBUG_sys ) ; then
1023        echo "IGCM_sys_GetDate_FichArchive :" $@
1024    fi
1025    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1026}
1027
1028##############################################################
1029# REBUILD OPERATOR
1030
1031function IGCM_sys_rebuild {
1032    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1033    if ( $DEBUG_sys ) ; then
1034        echo "IGCM_sys_rebuild :" $@
1035    fi
1036    /homegpfs/rech/psl/rpsl035/bin/rebuild -f -o $@
1037    if [ $? -gt 0 ] ; then
1038       echo "IGCM_sys_rebuild : erreur ${@}."
1039       IGCM_debug_Exit "rebuild"
1040    fi
1041
1042    IGCM_debug_PopStack "IGCM_sys_rebuild"
1043}
1044
1045############################################################
1046# Activate Running Environnment Variables
1047
1048function IGCM_sys_activ_variables {
1049    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1050    if ( $DEBUG_sys ) ; then
1051        echo "IGCM_sys_activ_variables "
1052    fi
1053
1054# --------------------------------------------------------------------
1055#D- MPI specifications
1056# --------------------------------------------------------------------
1057
1058# --------------------------------------------------------------------
1059#D- Other specifications
1060# --------------------------------------------------------------------
1061
1062    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1063
1064}
1065
1066############################################################
1067# Desactivate Running Environnment Variables
1068
1069function IGCM_sys_desactiv_variables {
1070    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1071    if ( $DEBUG_sys ) ; then
1072        echo "IGCM_sys_desactiv_variables "
1073    fi
1074# --------------------------------------------------------------------
1075#D- MPI specifications
1076# --------------------------------------------------------------------
1077
1078# --------------------------------------------------------------------
1079#D- Other specifications
1080# --------------------------------------------------------------------
1081
1082    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1083 
1084}
1085
1086############################################################
1087# Build run file
1088
1089function IGCM_sys_build_run_file {
1090    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1091set -x
1092    if ( $DEBUG_sys ) ; then
1093        echo "IGCM_sys_build_run_file " $@
1094    fi
1095    (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 2 ))
1096    NUM_PROC_OASIS=1
1097    NUM_PROC_OCE=1
1098   
1099    if [ $1 = MPI2 ]; then
1100       echo "IGCM_sys_build_run_file : error - MPI2 not available on vargas. "
1101       IGCM_debug_Exit "IGCM_sys_build_run_file"
1102    elif [ $1 = MPI1 ]; then
1103        cat <<EOF > run_file
1104./oasis
1105EOF
1106
1107        (( i = 0 ))
1108        while [ ${i} -lt ${NUM_PROC_ATM} ] ; do
1109            (( i = i + 1 ))
1110            cat <<EOF >> run_file
1111./lmdz.x
1112EOF
1113        done
1114
1115        cat <<EOF >> run_file
1116./opa.xx
1117EOF
1118        wc -l run_file
1119    fi
1120set +x
1121    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1122}
Note: See TracBrowser for help on using the repository browser.