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

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