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

Last change on this file since 434 was 434, checked in by mmaipsl, 13 years ago

correct a typo in Message send by mail.

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