source: tags/libIGCM_v1_4/libIGCM_sys/libIGCM_sys_brodie.ksh

Last change on this file was 188, checked in by sdipsl, 15 years ago

Coherence in filename used by mail function.

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