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

Last change on this file since 37 was 37, checked in by sdipsl, 16 years ago

ACa/SD : Function IGCM_sys_RshArchive will be use to manage NEMO restart in the parallel case

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