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

Last change on this file since 415 was 415, checked in by sdipsl, 13 years ago

Add R_IN_ECMWF in libIGCM_sys layer.

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