source: tags/libIGCM_v2.0_beta2/libIGCM_sys/libIGCM_sys_brodie.ksh @ 1456

Last change on this file since 1456 was 651, checked in by aclsce, 12 years ago

Added check to be sure there is enough space on temporary filesystems (only on vargas, titane and mercure sx9).
If there is not enough space, we stop.

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