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

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

SD : - 2 options for asynchronous rebuild

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