source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_brodie.ksh @ 452

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