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

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