source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh @ 36

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

SD : - no more stack files everywhere when you have

DEBUG_debug=false in AA_job (default)

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