source: branches/libIGCM_MPI_OpenMP/libIGCM_sys/libIGCM_sys_brodie.ksh @ 559

Last change on this file since 559 was 481, checked in by mafoipsl, 13 years ago

Modification for brodie (copied from vargas and not tested yet) :

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