source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_vargas.ksh @ 453

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