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

Last change on this file since 373 was 373, checked in by sdipsl, 14 years ago

Remove libIGCM_sys_claude.ksh and libIGCM_sys_calculo.ksh
Update/homogenize all headers usgin the new fixed-length keyword syntax regarding properties keywords
$Rev:: 13 i $: Revision of last commit
$Author:: harry $: Author of last commit
$Date:: 2006-03-15 02:33:03 -0500 (Wed, 15 Mar 2006) $: Date of last commit
Add / update original author and contact when missing

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