source: tags/libIGCM_v1_7/libIGCM_sys/libIGCM_sys_brodie.ksh @ 302

Last change on this file since 302 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 licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Date Author Revision
File size: 31.6 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 Brodie SX8
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=brodie
73
74#D-
75#D-#==================================================
76#D-Program used in libIGCM
77#D-#==================================================
78
79# rsync with path
80typeset -r RSYNC=/home/rech/ces/rces452/RSYNC_SX8/bin/rsync
81# RSYNC_opt args to rsync
82typeset -r RSYNC_opt="-va"
83# ie storage filesystem
84typeset -r RHOST=gaya
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:=${PBS_O_WORKDIR}}
98
99#====================================================
100#- ARCHIVE
101typeset -r ARCHIVE=$( rsh gaya -n env | grep PWD | gawk "-F=" '{print $2}' )
102
103#====================================================
104#- Mirror libIGCM from brodie 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 libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM
111
112#====================================================
113#- IN
114typeset -r R_IN=${R_IN:=/u/rech/psl/rpsl035/IGCM}
115
116#====================================================
117#- OUT
118typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
119
120#====================================================
121#- OUT_POST
122typeset -r R_OUT_POST=$( rsh ulam -n echo $WORKDIR | gawk "-F=" "{print $2}" )/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:="mpirun"}
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_SendMailPost" $@
182    if ( $DEBUG_sys ) ; then
183        echo "IGCM_sys_SendMail :" $@
184    fi
185
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 [ X${config_UserChoices_MailName} != X ] ; 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    if ( $DEBUG_sys ) ; then
377        echo "IGCM_sys_TestFileArchive :" $@
378    fi
379    typeset ExistFlag
380    ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" )
381    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
382
383    return ${ExistFlag}
384}
385
386#D-#==================================================
387#D-function IGCM_sys_CountFileArchive
388#D-* Purpose: Count files on Archive filesystem
389#D-* Examples:
390#D-
391function IGCM_sys_CountFileArchive {
392    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
393    IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l"
394    if [ $? -gt 0 ] ; then
395        echo "IGCM_sys_CountFileArchive : erreur."
396    fi
397    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
398}
399
400#D-#==================================================
401#D-function IGCM_sys_Tree
402#D-* Purpose: Tree directories with files on ${ARCHIVE}
403#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
404#D-
405function IGCM_sys_Tree {
406    IGCM_debug_PushStack "IGCM_sys_Tree" $@
407    if ( $DEBUG_sys ) ; then
408        echo "IGCM_sys_Tree :" $@
409    fi
410
411    \mfls -r $@
412
413    IGCM_debug_PopStack "IGCM_sys_Tree"
414}
415
416#D-#==================================================
417#D-function IGCM_sys_Tar
418#D-* Purpose: master un-tar command
419#D-* Examples:
420#D-
421function IGCM_sys_Tar {
422    IGCM_debug_PushStack "IGCM_sys_Tar" $@
423    if ( $DEBUG_sys ) ; then
424        echo "IGCM_sys_Tar :" $@
425    fi
426    \tar xvf $1
427    if [ $? -gt 0 ] ; then
428        echo "IGCM_sys_Tar : erreur."
429        IGCM_debug_Exit "IGCM_sys_Tar"
430    fi
431    IGCM_debug_PopStack "IGCM_sys_Tar"
432}
433
434#D-#==================================================
435#D-function IGCM_sys_UnTar
436#D-* Purpose: master un-tar command
437#D-* Examples:
438#D-
439function IGCM_sys_UnTar {
440    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
441    if ( $DEBUG_sys ) ; then
442        echo "IGCM_sys_UnTar :" $@
443    fi
444    \tar xvf $1
445    if [ $? -gt 0 ] ; then
446        echo "IGCM_sys_UnTar : erreur."
447        IGCM_debug_Exit "IGCM_sys_UnTar"
448    fi
449    IGCM_debug_PopStack "IGCM_sys_UnTar"
450}
451
452#D-#==================================================
453#D-function IGCM_sys_Qsub
454#D-* Purpose: Qsub new job
455#D-* Examples:
456#D-
457function IGCM_sys_Qsub {
458    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
459    if ( $DEBUG_sys ) ; then
460        echo "IGCM_sys_Qsub :" $@
461    fi
462    /usr/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1
463    if [ $? -gt 0 ] ; then
464        echo "IGCM_sys_Qsub : erreur -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} $@."
465        IGCM_debug_Exit "IGCM_sys_Qsub"
466    fi
467    IGCM_debug_PopStack "IGCM_sys_Qsub"
468}
469
470#D-#==================================================
471#D-function IGCM_sys_QsubPost
472#D-* Purpose: Qsub new job on scalaire
473#D-* Examples:
474#D-
475function IGCM_sys_QsubPost {
476    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
477    if ( $DEBUG_sys ) ; then
478        echo "IGCM_sys_QsubPost :" $@
479    fi
480    cd ${POST_DIR}
481    /opt/ibmll/LoadL/full/bin/llsubmit ${libIGCM_POST}/$1.job
482    cd -
483    if [ $? -gt 0 ] ; then
484        echo "IGCM_sys_QsubPost : erreur " $@
485        IGCM_debug_Exit "IGCM_sys_QsubPost"
486    fi
487    IGCM_debug_PopStack "IGCM_sys_QsubPost"
488}
489
490#D-*************************
491#D- File transfer functions
492#D-*************************
493#D-
494
495#D-#==================================================
496#D-function IGCM_sys_Rsync_out
497#D-* Purpose: treat return val of rsync
498#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
499#D-  Error values and explanations can depend on your system version.
500function IGCM_sys_Rsync_out {
501    RET=$1
502    if [ ! $RET ] ; then
503        echo "rsync error !"
504    fi
505
506    if [ $MYLANG = "fr" ]; then
507        case $RET in
508            0)  return ;;
509            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
510                echo "Erreur de syntaxe ou d'utilisation."
511                return;;
512            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
513                echo "Incompatibilité de protocole."
514                return;;
515            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
516                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
517                echo "répertoires"
518                return;;
519            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
520                echo "Action demandée non supportée : une tentative de manipulation de"
521                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
522                echo "été faite ; ou une option qui est supportée par le  client  mais"
523                echo "pas par le serveur a été spécifiée."
524                return;;
525            10) echo "Erreur de rsync ; RERR_SOCKETIO"
526                echo "Erreur dans le socket d'entrée sortie"
527                return;;
528            11) echo "Erreur de rsync ; RERR_FILEIO"
529                echo "Erreur d'entrée sortie fichier"
530                return;;
531            12) echo "Erreur de rsync ; RERR_STREAMIO"
532                echo "Erreur dans flux de donnée du protocole rsync"
533                return;;
534            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
535                echo "Erreur avec les diagnostics du programme"
536                return;;
537            14) echo "Erreur de rsync ; RERR_IPC"
538                echo "Erreur dans le code IPC"
539                return;;
540            20) echo "Erreur de rsync ; RERR_SIGNAL"
541                echo "SIGUSR1 ou SIGINT reçu"
542                return;;
543            21) echo "Erreur de rsync ; RERR_WAITCHILD"
544                echo "Une erreur retournée par waitpid()"
545                return;;
546            22) echo "Erreur de rsync ; RERR_MALLOC"
547                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
548                return;;
549            23) echo ""
550                echo "Erreur fichier inexistant"
551                return;;
552            30) echo "Erreur de rsync ; RERR_TIMEOUT"
553                echo "Temps d'attente écoulé dans l'envoi/réception de données"
554                return;;
555            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
556                return;;
557        esac
558    elif [ $MYLANG = "en" ] ; then
559        case $RET in
560            0)  return;;               
561            1)  echo "rsync error : Syntax or usage error "
562                return;;
563            2)  echo "rsync error : Protocol incompatibility "
564                return;;
565            3)  echo "rsync error : Errors selecting input/output files, dirs"
566                return;;
567            4)  echo "rsync error : Requested action not supported: an attempt"
568                echo "was made to manipulate 64-bit files on a platform that cannot support"
569                echo "them; or an option was specified that is supported by the client and"
570                echo "not by the server."
571                return;;
572            5)  echo "rsync error : Error starting client-server protocol"
573                return;;
574            10) echo "rsync error : Error in socket I/O "
575                return;;
576            11) echo "rsync error : Error in file I/O "
577                return;;
578            12) echo "rsync error : Error in rsync protocol data stream "
579                return;;
580            13) echo "rsync error : Errors with program diagnostics "
581                return;;
582            14) echo "rsync error : Error in IPC code "
583                return;;
584            20) echo "rsync error : Received SIGUSR1 or SIGINT "
585                return;;
586            21) echo "rsync error : Some error returned by waitpid() "
587                return;;
588            22) echo "rsync error : Error allocating core memory buffers "
589                return;;
590            23) echo "rsync error : Partial transfer due to error"
591                return;;
592            24) echo "rsync error : Partial transfer due to vanished source files"
593                return;;
594            30) echo "rsync error : Timeout in data send/receive "
595                return;;
596            *)  echo "rsync error : return code of rsync unknown :" $RET
597                return;;
598        esac
599    else
600        echo "unknown language $MYLANG."
601        return
602    fi
603}
604   
605
606#D-#==================================================
607#D-function IGCM_sys_Miror_libIGCM
608#D-* Purpose: Mirror libIGCM PATH and lib to ulam
609#D-* Examples:
610#D-
611function IGCM_sys_Mirror_libIGCM {
612    IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
613    if ( $DEBUG_sys ) ; then
614        echo "IGCM_sys_Mirror_libIGCM"
615    fi
616
617    typeset RET DEST
618
619    IGCM_sys_RshPost <<-EOF
620    mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
621EOF
622    rsh ulam -n hostname > /dev/null 2>&1
623    RET=$?
624    if [ $RET -eq 0 ] ; then
625        echo ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
626        ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
627        RET=$?
628
629        if [ ${RET} -gt 0 ] ; then
630            echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on ulam."
631            cat out_rsync
632        fi
633    else
634        echo "No POST-TREATMENT avaible because ulam is down."
635    fi
636    IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
637}
638
639#====================================================
640#- Call IGCM_sys_Mirror_libIGCM now !
641if ( $MirrorlibIGCM ) ; then
642    IGCM_sys_Mirror_libIGCM
643fi
644
645#D-#==================================================
646#D-function IGCM_sys_Cp
647#D-* Purpose: generic cp
648#D-* Examples:
649#D-
650function IGCM_sys_Cp {
651    IGCM_debug_PushStack "IGCM_sys_Cp" $@
652    if ( $DEBUG_sys ) ; then
653        echo "IGCM_sys_Cp :" $@
654    fi
655
656    typeset RET
657
658    echo cp $@ > out_rsync 2>&1
659    \cp $@ >> out_rsync 2>&1
660    RET=$?
661
662    if [ ${RET} -gt 0 ] ; then
663        echo "IGCM_sys_Cp : error."
664        cat out_rsync
665        IGCM_debug_Exit "IGCM_sys_Cp"
666    fi
667    IGCM_debug_PopStack "IGCM_sys_Cp"
668}
669
670#D-#==================================================
671#D-function IGCM_sys_Rm
672#D-* Purpose: generic rm
673#D-* Examples:
674#D-
675function IGCM_sys_Rm {
676    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
677    if ( $DEBUG_sys ) ; then
678        echo "IGCM_sys_Rm :" $@
679    fi
680
681    typeset RET
682
683    echo rm $@ > out_rsync 2>&1
684    \rm $@ >> out_rsync 2>&1
685    RET=$?
686
687    if [ ${RET} -gt 0 ] ; then
688        echo "IGCM_sys_Rm : error."
689        cat out_rsync
690        IGCM_debug_Exit "IGCM_sys_Rm"
691    fi
692    IGCM_debug_PopStack "IGCM_sys_Rm"
693}
694
695#D-#==================================================
696#D-function IGCM_sys_Mv
697#D-* Purpose: generic move
698#D-* Examples:
699#D-
700function IGCM_sys_Mv {
701    IGCM_debug_PushStack "IGCM_sys_Mv" $@
702    if ( $DEBUG_sys ) ; then
703        echo "IGCM_sys_Mv :" $@
704    fi
705
706    if [ $DRYRUN = 0 ]; then
707
708        typeset RET
709           
710        echo mv $@ > out_rsync 2>&1
711        \mv $@ >> out_rsync 2>&1
712        RET=$?
713   
714        if [ ${RET} -gt 0 ] ; then
715            echo "IGCM_sys_Mv : error in mv."
716            cat out_rsync
717            IGCM_debug_Exit "IGCM_sys_Mv"
718        fi
719    else
720        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
721    fi
722
723    IGCM_debug_PopStack "IGCM_sys_Mv"
724}
725
726#D-#==================================================
727#D-function IGCM_sys_Put_Dir
728#D-* Purpose: Copy a complete directory on $(ARCHIVE)
729#D-* Examples:
730#D-
731function IGCM_sys_Put_Dir {
732    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
733    if ( $DEBUG_sys ) ; then
734        echo "IGCM_sys_Put_Dir :" $@
735    fi
736    if [ $DRYRUN = 0 ]; then
737        if [ ! -d ${1} ] ; then
738            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
739            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
740            return
741        fi
742
743        typeset RET
744
745        # Only if we use rsync
746        #IGCM_sys_TestDirArchive $( dirname $2 )
747        #
748        #USUAL WAY
749        rcp -r $1 gaya:$2 > out_rsync 2>&1
750        RET=$?
751
752        if [ ${RET} -gt 0 ] ; then
753            echo "IGCM_sys_Put_Dir : error."
754            cat out_rsync
755            IGCM_debug_Exit "IGCM_sys_Put_Dir"
756        fi
757    else
758        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
759    fi
760    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
761}
762
763#D-#==================================================
764#D-function IGCM_sys_Get_Dir
765#D-* Purpose: Copy a complete directory from $(ARCHIVE)
766#D-* Examples:
767#D-
768function IGCM_sys_Get_Dir {
769    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
770    if ( $DEBUG_sys ) ; then
771        echo "IGCM_sys_Get_Dir :" $@
772    fi
773    if [ $DRYRUN = 0 ]; then
774        if [ ! -d ${1} ] ; then
775            echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
776            IGCM_debug_PopStack "IGCM_sys_Get_Dir"
777            return
778        fi
779
780        typeset RET
781
782        #USUAL WAY
783        rcp -rp gaya:$1 $2 > out_rsync 2>&1
784        RET=$?
785
786        if [ ${RET} -gt 0 ] ; then
787            echo "IGCM_sys_Get_Dir : error."
788            cat out_rsync
789            IGCM_debug_Exit "IGCM_sys_Get_Dir"
790        fi
791    else
792        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
793    fi
794    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
795}
796
797#D-#==================================================
798#D-function IGCM_sys_Put_Rest
799#D-* Purpose: Put computied restarts on $(ARCHIVE).
800#D-           File and target directory must exist.
801#D-* Examples:
802#D-
803function IGCM_sys_Put_Rest {
804    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
805    if ( $DEBUG_sys ) ; then
806        echo "IGCM_sys_Put_Rest :" $@
807    fi
808    if [ $DRYRUN = 0 ]; then
809        if [ ! -f ${1} ] ; then
810            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
811            IGCM_debug_Exit "IGCM_sys_Put_Rest"
812        fi
813
814        typeset RET
815        #
816        if [ X${JobType} = XRUN ] ; then
817            IGCM_sys_Chmod 444 ${1}
818        fi
819        #
820        #USUAL WAY
821        mfput $1 $2 > out_rsync 2>&1
822        RET=$?
823
824#       #RSYNC WITH NETWORK RSH CALL
825#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
826#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
827
828#       #RSYNC WITH NFS USE
829#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
830#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
831
832#       RET=$?
833#       IGCM_sys_Rsync_out $RET
834
835#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
836#       (( RET=RET+$? ))
837
838        if [ ${RET} -gt 0 ] ; then
839            echo "IGCM_sys_Put_Rest : error."
840            cat out_rsync
841            IGCM_debug_Exit "IGCM_sys_Put_Rest"
842        fi
843    else
844        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
845    fi
846    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
847}
848
849#D-#==================================================
850#D-function IGCM_sys_Put_Out
851#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
852#D-* Examples:
853#D-
854function IGCM_sys_Put_Out {
855    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
856    if ( $DEBUG_sys ) ; then
857        echo "IGCM_sys_Put_Out :" $@
858    fi
859    if [ $DRYRUN = 0 ]; then
860        if [ ! -f ${1} ] ; then
861            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
862            IGCM_debug_PopStack "IGCM_sys_Put_Out"
863            return 1
864        fi
865
866        typeset RET
867        #
868        if [ X${JobType} = XRUN ] ; then
869            if [ X${3} = X ] ; then
870                IGCM_sys_Chmod 444 ${1}
871            fi
872        fi
873        #
874        #USUAL WAY
875        mfput $1 $2 > out_rsync 2>&1
876        RET=$?
877
878#       #RSYNC WITH NETWORK RSH CALL
879#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
880#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
881
882#       #RSYNC WITH NFS USE
883#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
884#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
885
886#       RET=$?
887#       IGCM_sys_Rsync_out $RET
888
889#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
890#       (( RET=RET+$? ))
891
892        if [ ${RET} -gt 0 ] ; then
893            echo "IGCM_sys_Put_Out : error."
894            cat out_rsync
895            IGCM_debug_Exit "IGCM_sys_Put_Out"
896        fi
897    else
898        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
899    fi
900    IGCM_debug_PopStack "IGCM_sys_Put_Out"
901    return 0
902}
903
904#D-#==================================================
905#D-function IGCM_sys_Get
906#D-* Purpose: Get a file from ${ARCHIVE}
907#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
908#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
909function IGCM_sys_Get {
910    IGCM_debug_PushStack "IGCM_sys_Get" $@
911
912    typeset DEST RET dm_liste ifile target
913
914    if ( $DEBUG_sys ) ; then
915        echo "IGCM_sys_Get :" $@
916    fi
917    if [ $DRYRUN -le 2 ]; then
918        if [ X${1} = X'/l' ] ; then
919            # test if the first file is present in the old computation :
920            eval set +A dm_liste \${${2}}
921        else
922            dm_liste=${1}
923        fi
924        eval DEST=\${${#}}
925
926        # test if the (first) file is present in the old computation :
927        IGCM_sys_TestFileArchive ${dm_liste[0]}
928        RET=$?
929        if [ ${RET} -gt 0 ] ; then
930            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
931            IGCM_debug_Exit "IGCM_sys_Get"
932            IGCM_debug_PopStack "IGCM_sys_Get"
933            return
934        fi
935
936        # SD : dm_liste is not suited for computing job
937        #      because we change filename during transfert
938        #      dm_liste is better suited for post-treatment
939        #dm_liste=" "
940        #(( ifile=1 ))
941        #while [ $ifile -lt $# ] ; do
942        #    dm_liste=$( eval echo ${dm_liste} " "\${${ifile}} )
943        #    (( ifile = ifile + 1 ))
944        #done
945        #DEST=$( eval echo \${${#}} )
946
947        #USUAL WAY
948        mfget ${dm_liste[*]} ${DEST} > out_rsync 2>&1
949        RET=$?
950
951#       #RSYNC WITH NETWORK RSH CALL
952#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
953#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
954
955#       #RSYNC WITH NFS USE
956#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
957#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
958
959#       RET=$?
960#       IGCM_sys_Rsync_out $RET
961
962#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
963#       (( RET=RET+$? ))
964
965        if [ ${RET} -gt 0 ] ; then
966            echo "IGCM_sys_Get : copy error."
967            cat out_rsync
968            IGCM_debug_Exit "IGCM_sys_Get"
969        fi
970    else
971        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
972    fi
973    IGCM_debug_PopStack "IGCM_sys_Get"
974}
975
976############################################################## A FINIR !!
977
978#D-#==================================================
979#D-function IGCM_sys_GetDate_FichWork
980#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
981#D-* Examples:
982#D-
983function IGCM_sys_GetDate_FichWork {
984    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
985    if ( $DEBUG_sys ) ; then
986        echo "IGCM_sys_GetDate_FichWork :" $@
987    fi
988    # donne la date filesys d'un fichier sur la machine work
989    IGCM_debug_PopStack "IGCM_sys_FichWork"
990}
991
992#D-#==================================================
993#D-function IGCM_sys_GetDate_FichArchive
994#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
995#D-* Examples:
996#D-
997function IGCM_sys_GetDate_FichArchive {
998    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
999    if ( $DEBUG_sys ) ; then
1000        echo "IGCM_sys_GetDate_FichArchive :" $@
1001    fi
1002    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1003}
1004
1005##############################################################
1006# REBUILD OPERATOR
1007
1008function IGCM_sys_rebuild {
1009    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1010    if ( $DEBUG_sys ) ; then
1011        echo "IGCM_sys_rebuild :" $@
1012    fi
1013    /home/rech/psl/rpsl035/SX/bin/rebuild -f -o $@
1014    if [ $? -gt 0 ] ; then
1015       echo "IGCM_sys_rebuild : erreur ${@}."
1016       IGCM_debug_Exit "rebuild"
1017    fi
1018
1019    IGCM_debug_PopStack "IGCM_sys_rebuild"
1020}
1021
1022############################################################
1023# Activate Running Environnment Variables
1024
1025function IGCM_sys_activ_variables {
1026    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1027    if ( $DEBUG_sys ) ; then
1028        echo "IGCM_sys_activ_variables"
1029    fi
1030
1031# --------------------------------------------------------------------
1032#D- MPI specifications
1033# --------------------------------------------------------------------
1034
1035#D-- MPISUSPEND
1036    export MPISUSPEND=${MPISUSPEND:=OFF}
1037
1038#D-- MPIPROGINF #other choices : ALL_DETAIL2
1039    export MPIPROGINF=ALL
1040#D- activate ftrace (with -ftrace)
1041    export F_FTRACE=YES
1042#D- communication information (with -ftrace)
1043    export MPICOMMINF=DETAIL
1044
1045# --------------------------------------------------------------------
1046#D- Other specifications
1047# --------------------------------------------------------------------
1048
1049#D- max number of character/line in output job
1050    export F_SYSLEN=5000
1051#D- number of error that can be admitted on the NEC
1052    export F_ERRCNT=0
1053#D- global performance
1054    export F_PROGINF=DETAIL
1055
1056#D- I/O performance (FORTRAN I/O only not netCDF)
1057    export F_FILEINF=${F_FILEINF:=NO}
1058#D- netCDF I/O performance
1059    export NC_FILEINF=${NC_FILEINF:=NO}
1060
1061    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1062}
1063
1064############################################################
1065# Desactivate Running Environnment Variables
1066
1067function IGCM_sys_desactiv_variables {
1068    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1069    if ( $DEBUG_sys ) ; then
1070        echo "IGCM_sys_desactiv_variables"
1071    fi
1072# --------------------------------------------------------------------
1073#D- MPI specifications
1074# --------------------------------------------------------------------
1075
1076#D-- MPIPROGINF
1077    export MPIPROGINF=NO
1078
1079# --------------------------------------------------------------------
1080#D- Other specifications
1081# --------------------------------------------------------------------
1082
1083#D- global performance
1084    export F_PROGINF=NO 
1085
1086    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1087 
1088}
1089
1090############################################################
1091# Build run file
1092
1093function IGCM_sys_build_run_file {
1094    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1095    if ( $DEBUG_sys ) ; then
1096        echo "IGCM_sys_build_run_file " $@
1097    fi
1098    (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 ))
1099    (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1100    (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1101   
1102    if [ $1 = MPI2 ]; then
1103        cat <<EOF > run_file
1104-p 1 -np 1 -e ./oasis
1105EOF
1106        (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 ))
1107        config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"'
1108
1109    elif [ $1 = MPI1 ]; then
1110        cat <<EOF > run_file
1111-p $NUM_PROC_OASIS -e ./oasis
1112-p $NUM_PROC_ATM -e ./lmdz.x
1113-p $NUM_PROC_OCE -e ./opa.xx
1114EOF
1115 
1116    fi
1117
1118    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1119 
1120}
Note: See TracBrowser for help on using the repository browser.