source: tags/libIGCM_v1_3/libIGCM_sys/libIGCM_sys_brodie.ksh

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