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

Last change on this file since 160 was 160, checked in by sdipsl, 15 years ago
  • Remove testing related text
  • 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.5 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_atlas.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    typeset RET
716
717    echo mv $@ > out_rsync 2>&1
718    \mv $@ >> out_rsync 2>&1
719    RET=$?
720
721    if [ ${RET} -gt 0 ] ; then
722        echo "IGCM_sys_Mv : error in mv."
723        cat out_rsync
724        IGCM_debug_Exit "IGCM_sys_Mv"
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        # Only if we use rsync
825        #IGCM_sys_MkdirArchive $( dirname $2 )
826        #
827        #USUAL WAY
828        mfput $1 $2 > out_rsync 2>&1
829        RET=$?
830
831#       #RSYNC WITH NETWORK RSH CALL
832#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
833#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
834
835#       #RSYNC WITH NFS USE
836#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
837#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
838       
839#       RET=$?
840#       IGCM_sys_Rsync_out $RET
841
842#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
843#       (( RET=RET+$? ))
844
845        if [ ${RET} -gt 0 ] ; then
846            echo "IGCM_sys_Put_Rest : error."
847            cat out_rsync
848            IGCM_debug_Exit "IGCM_sys_Put_Rest"
849        fi
850    else
851        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
852    fi
853    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
854}
855
856#D-#==================================================
857#D-function IGCM_sys_Put_Out
858#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
859#D-* Examples:
860#D-
861function IGCM_sys_Put_Out {
862    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
863    if ( $DEBUG_sys ) ; then
864        echo "IGCM_sys_Put_Out :" $@
865    fi
866    if [ $DRYRUN = 0 ]; then
867        if [ ! -f ${1} ] ; then
868            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
869            IGCM_debug_PopStack "IGCM_sys_Put_Out"
870            return 1
871        fi
872
873        typeset RET
874        #
875        if [ X${JobType} = XRUN ] ; then
876            IGCM_sys_Chmod 444 ${1}
877        fi
878        #
879        # Only if we use rsync
880        #IGCM_sys_MkdirArchive $( dirname $2 )
881        #
882        #USUAL WAY
883        mfput $1 $2 > out_rsync 2>&1
884        RET=$?
885
886#       #RSYNC WITH NETWORK RSH CALL
887#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
888#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
889
890#       #RSYNC WITH NFS USE
891#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
892#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
893
894#       RET=$?
895#       IGCM_sys_Rsync_out $RET
896
897#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
898#       (( RET=RET+$? ))
899
900        if [ ${RET} -gt 0 ] ; then
901            echo "IGCM_sys_Put_Out : error."
902            cat out_rsync
903            IGCM_debug_Exit "IGCM_sys_Put_Out"
904        fi
905    else
906        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
907    fi
908    IGCM_debug_PopStack "IGCM_sys_Put_Out"
909    return 0
910}
911
912#D-#==================================================
913#D-function IGCM_sys_Get
914#D-* Purpose: Get a file from ${ARCHIVE}
915#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
916#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
917function IGCM_sys_Get {
918    IGCM_debug_PushStack "IGCM_sys_Get" $@
919
920    typeset DEST RET dm_liste ifile target
921
922    if ( $DEBUG_sys ) ; then
923        echo "IGCM_sys_Get :" $@
924    fi
925    if [ $DRYRUN -le 2 ]; then
926        if [ X${1} = X'/l' ] ; then
927            # test if the first file is present in the old computation :
928            eval set +A dm_liste \${${2}}
929        else
930            dm_liste=${1}
931        fi
932        eval DEST=\${${#}}
933
934        # test if the (first) file is present in the old computation :
935        IGCM_sys_TestFileArchive ${dm_liste[0]}
936        RET=$?
937        if [ ${RET} -gt 0 ] ; then
938            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
939            IGCM_debug_Exit "IGCM_sys_Get"
940            return
941        fi
942
943        # SD : dm_liste is not suited for computing job
944        #      because we change filename during transfert
945        #      dm_liste is better suited for post-treatment
946        #dm_liste=" "
947        #(( ifile=1 ))
948        #while [ $ifile -lt $# ] ; do
949        #    dm_liste=$( eval echo ${dm_liste} " "\${${ifile}} )
950        #    (( ifile = ifile + 1 ))
951        #done
952        #DEST=$( eval echo \${${#}} )
953
954        #USUAL WAY
955        mfget ${dm_liste[*]} ${DEST} > out_rsync 2>&1
956        #mfget $1 $2 > out_rsync 2>&1
957        RET=$?
958
959#       #RSYNC WITH NETWORK RSH CALL
960#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
961#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
962
963#       #RSYNC WITH NFS USE
964#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
965#       ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
966
967#       RET=$?
968#       IGCM_sys_Rsync_out $RET
969
970#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
971#       (( RET=RET+$? ))
972
973        if [ ${RET} -gt 0 ] ; then
974            echo "IGCM_sys_Get : copy error."
975            cat out_rsync
976            IGCM_debug_Exit "IGCM_sys_Get"
977        fi
978    else
979        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
980    fi
981    IGCM_debug_PopStack "IGCM_sys_Get"
982}
983
984############################################################## A REVOIR !!
985
986#D-#==================================================
987#D-function IGCM_sys_Rapatrie
988#D-* Purpose: Rapatrie
989#D-* Examples:
990#D-
991function IGCM_sys_Rapatrie {
992    IGCM_debug_PushStack "IGCM_sys_Rapatrie" $@
993    if ( $DEBUG_sys ) ; then
994        echo "IGCM_sys_Rapatrie :" $@
995    fi
996
997    typeset RET=0
998
999    IGCM_sys_Get ${R_STOCKAGE}/$2 $1 ;
1000    let $(( RET=RET+$? ))
1001    IGCM_sys_Cd $1 ;
1002    let $(( RET=RET+$? ))
1003    IGCM_sys_UnTar $2 ;
1004    let $(( RET=RET+$? ))
1005
1006    if [ ${RET} -gt 0 ] ; then
1007        echo "IGCM_sys_Rapatrie : erreur."
1008        IGCM_debug_Exit "IGCM_sys_Rapatrie"
1009    fi
1010    IGCM_debug_PopStack "IGCM_sys_Rapatrie"
1011}
1012
1013############################################################## A FINIR !!
1014
1015#D-#==================================================
1016#D-function IGCM_sys_GetDate_FichWork
1017#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1018#D-* Examples:
1019#D-
1020function IGCM_sys_GetDate_FichWork {
1021    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1022    if ( $DEBUG_sys ) ; then
1023        echo "IGCM_sys_GetDate_FichWork :" $@
1024    fi
1025    # donne la date filesys d'un fichier sur la machine work
1026    IGCM_debug_PopStack "IGCM_sys_FichWork"
1027}
1028
1029#D-#==================================================
1030#D-function IGCM_sys_GetDate_FichArchive
1031#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1032#D-* Examples:
1033#D-
1034function IGCM_sys_GetDate_FichArchive {
1035    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1036    if ( $DEBUG_sys ) ; then
1037        echo "IGCM_sys_GetDate_FichArchive :" $@
1038    fi
1039    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1040}
1041
1042##############################################################
1043# REBUILD OPERATOR
1044
1045function IGCM_sys_rebuild {
1046    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1047    if ( $DEBUG_sys ) ; then
1048        echo "IGCM_sys_rebuild :" $@
1049    fi
1050    /home/rech/psl/rpsl035/SX/bin/rebuild -f -o $@
1051    if [ $? -gt 0 ] ; then
1052       echo "IGCM_sys_rebuild : erreur ${@}."
1053       IGCM_debug_Exit "rebuild"
1054    fi
1055
1056    IGCM_debug_PopStack "IGCM_sys_rebuild"
1057}
1058
1059############################################################
1060# Activate Running Environnment Variables
1061
1062function IGCM_sys_activ_variables {
1063    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1064    if ( $DEBUG_sys ) ; then
1065        echo "IGCM_sys_activ_variables "
1066    fi
1067
1068# --------------------------------------------------------------------
1069#D- MPI specifications
1070# --------------------------------------------------------------------
1071
1072#D-- MPISUSPEND
1073    export MPISUSPEND=${MPISUSPEND:=OFF}
1074
1075#D-- MPIPROGINF #other choices : ALL_DETAIL2
1076    export MPIPROGINF=ALL
1077#D- activate ftrace (with -ftrace)
1078    export F_FTRACE=YES
1079#D- communication information (with -ftrace)
1080    export MPICOMMINF=DETAIL
1081
1082# --------------------------------------------------------------------
1083#D- Other specifications
1084# --------------------------------------------------------------------
1085
1086#D- max number of character/line in output job
1087    export F_SYSLEN=5000
1088#D- number of error that can be admitted on the NEC
1089    export F_ERRCNT=0
1090#D- global performance
1091    export F_PROGINF=DETAIL
1092
1093#D- I/O performance (FORTRAN I/O only not netCDF)
1094    export F_FILEINF=${F_FILEINF:=NO}
1095#D- netCDF I/O performance
1096    export NC_FILEINF=${NC_FILEINF:=NO}
1097
1098    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1099}
1100
1101############################################################
1102# Desactivate Running Environnment Variables
1103
1104function IGCM_sys_desactiv_variables {
1105    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1106    if ( $DEBUG_sys ) ; then
1107        echo "IGCM_sys_desactiv_variables "
1108    fi
1109# --------------------------------------------------------------------
1110#D- MPI specifications
1111# --------------------------------------------------------------------
1112
1113#D-- MPIPROGINF
1114    export MPIPROGINF=NO
1115
1116# --------------------------------------------------------------------
1117#D- Other specifications
1118# --------------------------------------------------------------------
1119
1120#D- global performance
1121    export F_PROGINF=NO 
1122
1123    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1124 
1125}
1126
1127############################################################
1128# Build run file
1129
1130function IGCM_sys_build_run_file {
1131    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1132    if ( $DEBUG_sys ) ; then
1133        echo "IGCM_sys_build_run_file " $@
1134    fi
1135    (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 ))
1136    (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1137    (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1138   
1139    if [ $1 = MPI2 ]; then
1140        cat <<EOF > run_file
1141-p 1 -np 1 -e ./oasis
1142EOF
1143        (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 ))
1144        config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"'
1145
1146    elif [ $1 = MPI1 ]; then
1147        cat <<EOF > run_file
1148-p $NUM_PROC_OASIS -e ./oasis
1149-p $NUM_PROC_ATM -e ./lmdz.x
1150-p $NUM_PROC_OCE -e ./opa.xx
1151EOF
1152 
1153    fi
1154
1155    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1156 
1157}
Note: See TracBrowser for help on using the repository browser.