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

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

SD : - Tweak IGCM_sys_RshArchive function for non IDRIS machine

  • Comment out parallel restart case / work only in parallel not in sequential
  • 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.0 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_RshArchive
129#D-* Purpose: Archive rsh command
130#D-* Examples:
131#D-
132function IGCM_sys_RshArchive {
133    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
134    /bin/ksh <<-EOF
135${@}
136EOF
137    if [ $? -gt 0 ] ; then
138        echo "IGCM_sys_RshArchive : erreur."
139        IGCM_debug_Exit "IGCM_sys_RshArchive"
140    fi
141    IGCM_debug_PopStack "IGCM_sys_RshArchive"
142}
143
144#D-#==================================================
145#D-function IGCM_sys_RshPost
146#D-* Purpose: Post-process rsh command
147#D-* Examples:
148#D-
149function IGCM_sys_RshPost {
150    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
151    if ( $DEBUG_sys ) ; then
152        echo "IGCM_sys_RshPost :" $@
153    fi
154    /bin/ksh ${@}
155    if [ $? -gt 0 ] ; then
156        echo "IGCM_sys_RshPost : erreur."
157        IGCM_debug_Exit "IGCM_sys_RshPost"
158    fi
159    IGCM_debug_PopStack "IGCM_sys_RshPost"
160}
161
162#D-#==================================================
163#D-function IGCM_sys_Mkdir
164#D-* Purpose: Master locale mkdir command
165#D-* Examples:
166#D-
167function IGCM_sys_Mkdir {
168    IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
169    if ( $DEBUG_sys ) ; then
170        echo "IGCM_sys_Mkdir :" $@
171    fi
172    if [ ! -d ${1} ]; then
173        \mkdir -p $1
174        if [ $? -gt 0 ] ; then
175            echo "IGCM_sys_Mkdir : erreur."
176            IGCM_debug_Exit "IGCM_sys_Mkdir"
177        fi
178    fi
179    # vérification :
180    if [ ! -d ${1} ] ; then
181        echo "IGCM_sys_Mkdir : erreur."
182        IGCM_debug_Exit "IGCM_sys_Mkdir"
183    fi
184    IGCM_debug_PopStack "IGCM_sys_Mkdir"
185}
186
187#D-#==================================================
188#D-function IGCM_sys_MkdirArchive
189#D-* Purpose: Mkdir on Archive
190#D-* Examples:
191#D-
192function IGCM_sys_MkdirArchive {
193    IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
194    if ( $DEBUG_sys ) ; then
195        echo "IGCM_sys_MkdirArchive :" $@
196    fi
197    #- creation de repertoire sur le serveur fichier
198    if [ ! -d ${1} ]; then 
199        \mkdir -p $1
200        if [ $? -gt 0 ] ; then
201            echo "IGCM_sys_MkdirArchive : erreur."
202            IGCM_debug_Exit "IGCM_sys_MkdirArchive"
203        fi
204    fi
205#    vérification ?? :
206#    if [ ! -d ${1} ] ; then
207#       echo "IGCM_sys_MkdirArchive : erreur."
208#       IGCM_debug_Exit "IGCM_sys_MkdirArchive"
209#    fi
210    IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
211}
212
213#D-#==================================================
214#D-function IGCM_sys_MkdirWork
215#D-* Purpose: Mkdir on Work
216#D-* Examples:
217#D-
218function IGCM_sys_MkdirWork {
219    IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
220    if ( $DEBUG_sys ) ; then
221        echo "IGCM_sys_MkdirWork :" $@
222    fi
223    #- creation de repertoire sur le serveur fichier
224    if [ ! -d ${1} ]; then 
225        \mkdir -p $1
226        if [ $? -gt 0 ] ; then
227            echo "IGCM_sys_MkdirWork : erreur."
228            IGCM_debug_Exit "IGCM_sys_MkdirWork"
229        fi
230    fi
231    # vérification ?? :
232    if [ ! -d ${1} ] ; then
233        echo "IGCM_sys_MkdirWork : erreur."
234        IGCM_debug_Exit "IGCM_sys_MkdirWork"
235    fi
236    IGCM_debug_PopStack "IGCM_sys_MkdirWork"
237}
238#IGCM_sys_MkdirWork ${RUN_DIR_PATH}
239#echo "RUN_DIR_PATH ${RUN_DIR_PATH} ok."
240
241#D-#==================================================
242#D-function IGCM_sys_Cd
243#D-* Purpose: master cd command
244#D-* Examples:
245#D-
246function IGCM_sys_Cd {
247    IGCM_debug_PushStack "IGCM_sys_Cd" $@
248    if ( $DEBUG_sys ) ; then
249        echo "IGCM_sys_Cd :" $@
250    fi
251    \cd $1
252    if [ $? -gt 0 ] ; then
253        echo "IGCM_sys_Cd : erreur."
254        IGCM_debug_Exit "IGCM_sys_Cd"
255    fi
256    IGCM_debug_PopStack "IGCM_sys_Cd"
257}
258
259#D-#==================================================
260#D-function IGCM_sys_Chmod
261#D-* Purpose: Chmod
262#D-* Examples:
263#D-
264function IGCM_sys_Chmod {
265    IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
266    if ( $DEBUG_sys ) ; then
267        echo "IGCM_sys_Chmod :" $@
268    fi
269    if [ $DRYRUN -le 1 ]; then
270        \chmod $@
271        if [ $? -gt 0 ] ; then
272            echo "IGCM_sys_Chmod : erreur."
273            IGCM_debug_Exit "IGCM_sys_Chmod"
274        fi
275    else
276        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
277    fi
278    IGCM_debug_PopStack "IGCM_sys_Chmod"
279}
280
281#D-#==================================================
282#D-function IGCM_sys_FileSize
283#D-* Purpose: Filesize
284#D-* Examples:
285#D-
286function IGCM_sys_FileSize {
287    IGCM_debug_PushStack "IGCM_sys_FileSize" $@
288
289    typeset sizeF
290    set +A sizeF -- $( ls -la ${1} )
291    if [ $? -gt 0 ] ; then
292        IGCM_debug_Exit "IGCM_sys_FileSize"
293    fi
294    eval ${2}=${sizeF[4]}
295
296    IGCM_debug_PopStack "IGCM_sys_FileSize"
297}
298
299#D-#==================================================
300#D-function IGCM_sys_TestDir
301#D-* Purpose: Test Directory that must exists
302#D-* Examples:
303#D-
304function IGCM_sys_TestDir {
305    IGCM_debug_PushStack "IGCM_sys_TestDir" $@
306    if ( $DEBUG_sys ) ; then
307        echo "IGCM_sys_TestDir :" $@
308    fi
309    if [ ! -d ${1} ]; then
310        echo "IGCM_sys_TestDir : Directory $1 does not exist."
311        IGCM_debug_Exit "IGCM_sys_TestDir"
312    fi
313    IGCM_debug_PopStack "IGCM_sys_TestDir"
314}
315
316#D-#==================================================
317#D-function IGCM_sys_TestDirArchive
318#D-* Purpose: Test Directory that must exists on Archive
319#D-* Examples:
320#D-
321function IGCM_sys_TestDirArchive {
322    IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
323    if ( $DEBUG_sys ) ; then
324        echo "IGCM_sys_TestDirArchive :" $@
325    fi
326    if [ ! -d ${1} ]; then
327        echo "IGCM_sys_TestDirArchive : Directory $1 does not exist on ${ARCHIVE}."
328        IGCM_debug_Exit "IGCM_sys_TestDirArchive"
329    fi
330    IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
331}
332
333#D-#==================================================
334#D-function IGCM_sys_TestFileArchive
335#D-* Purpose: Test file that must NOT EXISTS on Archive
336#D-* Examples:
337#D-
338function IGCM_sys_TestFileArchive {
339    IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
340    if ( $DEBUG_sys ) ; then
341        echo "IGCM_sys_TestFileArchive :" $@
342    fi
343    if [ ! -f ${1} ]; 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    \ls -lR ${@}
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#D-#==================================================
556#D-function IGCM_sys_Cp
557#D-* Purpose: generic cp
558#D-* Examples:
559#D-
560function IGCM_sys_Cp {
561    IGCM_debug_PushStack "IGCM_sys_Cp" $@
562    if ( $DEBUG_sys ) ; then
563        echo "IGCM_sys_Cp :" $@
564    fi
565
566    typeset RET
567
568    echo cp $@ > out_rsync 2>&1
569    \cp $@ >> out_rsync 2>&1
570    RET=$?
571
572    if [ ${RET} -gt 0 ] ; then
573        echo "IGCM_sys_Cp : error."
574        cat out_rsync
575        IGCM_debug_Exit "IGCM_sys_Cp"
576    fi
577    IGCM_debug_PopStack "IGCM_sys_Cp"
578}
579
580#D-#==================================================
581#D-function IGCM_sys_Mv
582#D-* Purpose: generic move
583#D-* Examples:
584#D-
585function IGCM_sys_Mv {
586    IGCM_debug_PushStack "IGCM_sys_Mv" $@
587    if ( $DEBUG_sys ) ; then
588        echo "IGCM_sys_Mv :" $@
589    fi
590
591    typeset RET
592
593    echo mv $@ > out_rsync 2>&1
594    \mv $@ >> out_rsync 2>&1
595    RET=$?
596
597    if [ ${RET} -gt 0 ] ; then
598        echo "IGCM_sys_Mv : error in mv."
599        cat out_rsync
600        IGCM_debug_Exit "IGCM_sys_Mv"
601    fi
602
603    IGCM_debug_PopStack "IGCM_sys_Mv"
604}
605
606#D-#==================================================
607#D-function IGCM_sys_Put_Dir
608#D-* Purpose: Copy a complete directory on $(ARCHIVE)
609#D-* Examples:
610#D-
611function IGCM_sys_Put_Dir {
612    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
613    if ( $DEBUG_sys ) ; then
614        echo "IGCM_sys_Put_Dir :" $@
615    fi
616    if [ $DRYRUN = 0 ]; then
617        if [ ! -d ${1} ] ; then
618            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
619            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
620            return
621        fi
622
623        typeset RET
624
625        # Only if we use rsync
626        #IGCM_sys_TestDirArchive $( dirname $2 )
627        #
628        #USUAL WAY
629        \cp -r $1 $2 > out_rsync 2>&1
630        RET=$?
631
632        if [ ${RET} -gt 0 ] ; then
633            echo "IGCM_sys_Put_Dir : error."
634            cat out_rsync
635            IGCM_debug_Exit "IGCM_sys_Put_Dir"
636        fi
637    else
638        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
639    fi
640    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
641}
642
643#D-#==================================================
644#D-function IGCM_sys_Get_Dir
645#D-* Purpose: Copy a complete directory from $(ARCHIVE)
646#D-* Examples:
647#D-
648function IGCM_sys_Get_Dir {
649    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
650    if ( $DEBUG_sys ) ; then
651        echo "IGCM_sys_Get_Dir :" $@
652    fi
653    if [ $DRYRUN = 0 ]; then
654        if [ ! -d ${1} ] ; then
655            echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
656            IGCM_debug_PopStack "IGCM_sys_Get_Dir"
657            return
658        fi
659
660        typeset RET
661
662        # Only if we use rsync
663        #IGCM_sys_TestDirArchive $( dirname $2 )
664        #
665        #USUAL WAY
666        \cp -r $1 $2 > out_rsync 2>&1
667        RET=$?
668
669        if [ ${RET} -gt 0 ] ; then
670            echo "IGCM_sys_Get_Dir : error."
671            cat out_rsync
672            IGCM_debug_Exit "IGCM_sys_Get_Dir"
673        fi
674    else
675        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
676    fi
677    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
678}
679
680#D-#==================================================
681#D-function IGCM_sys_Put_Rest
682#D-* Purpose: Put computied restarts on $(ARCHIVE).
683#D-           File and target directory must exist.
684#D-* Examples:
685#D-
686function IGCM_sys_Put_Rest {
687    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
688    if ( $DEBUG_sys ) ; then
689        echo "IGCM_sys_Put_Rest :" $@
690    fi
691    if [ $DRYRUN = 0 ]; then
692        if [ ! -f ${1} ] ; then
693            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
694            IGCM_debug_Exit "IGCM_sys_Put_Rest"
695        fi
696
697        typeset RET
698        #
699        IGCM_sys_Chmod 444 ${1}
700        #
701        IGCM_sys_TestDirArchive $( dirname $2 )
702        #
703        # USUAL WAY
704        putfer $1 $2 > out_rsync 2>&1
705        RET=$?
706
707#       #RSYNC WITH NETWORK RSH CALL
708#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
709#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
710
711#       #RSYNC WITH NFS USE
712#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
713#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
714
715#       RET=$?
716#       IGCM_sys_Rsync_out $RET
717
718#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
719#       (( RET=RET+$? ))
720
721        if [ ${RET} -gt 0 ] ; then
722            echo "IGCM_sys_Put_Rest : error."
723            cat out_rsync
724            IGCM_debug_Exit "IGCM_sys_Put_Rest"
725        fi
726    else
727        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
728    fi
729    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
730}
731
732#D-#==================================================
733#D-function IGCM_sys_Put_Out
734#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
735#D-* Examples:
736#D-
737function IGCM_sys_Put_Out {
738    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
739    if ( $DEBUG_sys ) ; then
740        echo "IGCM_sys_Put_Out :" $@
741    fi
742    if [ $DRYRUN = 0 ]; then
743        if [ ! -f ${1} ] ; then
744            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
745            IGCM_debug_PopStack "IGCM_sys_Put_Out"
746            return 1
747        fi
748        #
749        IGCM_sys_MkdirArchive $( dirname $2 )
750        #
751        typeset RET
752
753        #=====================================================
754        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
755        #=====================================================
756
757        #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
758        #if [ $? -eq 0 ] ; then
759        #    typeset WORKPATH FILEPATH
760        #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
761        #    IGCM_sys_MkdirWork ${WORKPATH}
762        #    FILEPATH=${WORKPATH}/$( basename $2 )
763        #    #
764        #    IGCM_sys_Cp ${1} ${FILEPATH}
765        #fi
766
767        IGCM_sys_Chmod 444 ${1}
768        #
769        # USUAL WAY
770        putfer $1 $2 > out_rsync 2>&1
771        RET=$?
772
773#       #RSYNC WITH NETWORK RSH CALL
774#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
775#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
776
777#       #RSYNC WITH NFS USE
778#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
779#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
780
781#       RET=$?
782#       IGCM_sys_Rsync_out $RET
783
784#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
785#       (( RET=RET+$? ))
786
787        if [ ${RET} -gt 0 ] ; then
788            echo "IGCM_sys_Put_Out : error."
789            cat out_rsync
790            IGCM_debug_Exit "IGCM_sys_Put_Out"
791        fi
792    else
793        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
794    fi
795    IGCM_debug_PopStack "IGCM_sys_Put_Out"
796    return 0
797}
798
799#D-#==================================================
800#D-function IGCM_sys_Get
801#D-* Purpose: Get a file from ${ARCHIVE}
802#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
803#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
804function IGCM_sys_Get {
805    IGCM_debug_PushStack "IGCM_sys_Get" $@
806
807    typeset DEST RET dm_liste ifile target file_work
808
809    if ( $DEBUG_sys ) ; then
810        echo "IGCM_sys_Get :" $@
811    fi
812    if [ $DRYRUN -le 2 ]; then
813        if [ X${1} = X'/l' ] ; then
814            # test if the first file is present in the old computation :
815            eval set +A dm_liste \${${2}}
816        else
817            eval set +A dm_liste ${1}
818        fi
819        eval DEST=\${${#}}
820
821        #=====================================================
822        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
823        #=====================================================
824
825        # Is it an R_OUT file (not R_IN) ?
826        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
827        #if [ $? -eq 0 ] ; then
828        #    # Yes  ? then we try to get it in SCRATCHDIR
829        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
830        #    if [ -f ${file_work[0]} ] ; then
831        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
832        #       IGCM_debug_PopStack "IGCM_sys_Get"
833        #       return
834        #    fi
835        #fi
836
837        # test if the (first) file is present in the old computation :
838        IGCM_sys_TestFileArchive ${dm_liste[0]}
839        RET=$?
840        if [ ${RET} -gt 0 ] ; then
841            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
842            IGCM_debug_Exit "IGCM_sys_Get"
843            IGCM_debug_PopStack "IGCM_sys_Get"
844            return
845        fi
846
847        dmget ${dm_liste[*]} > out_rsync 2>&1
848        RET=$?
849        if [ ${RET} -gt 0 ] ; then
850            echo "IGCM_sys_Get : demigration error."
851            cat out_rsync
852            IGCM_debug_Exit "IGCM_sys_Get"
853        fi
854
855        #USUAL WAY
856        if [ X${1} = X'/l' ] ; then
857            (( RET=0 ))
858            for target in ${dm_liste[*]} ; do
859                local_file=$( basename ${target} )
860                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
861                (( RET = RET + $? ))
862            done
863        else
864            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
865            RET=$?
866        fi
867
868#       #RSYNC WITH NETWORK RSH CALL
869#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
870#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
871
872#       #RSYNC WITH NFS USE
873#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
874#       ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
875
876#       RET=$?
877#       IGCM_sys_Rsync_out $RET
878
879#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
880#       (( RET=RET+$? ))
881
882        if [ ${RET} -gt 0 ] ; then
883            echo "IGCM_sys_Get : copy error."
884            cat out_rsync
885            IGCM_debug_Exit "IGCM_sys_Get"
886        fi
887    else
888        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
889    fi
890    IGCM_debug_PopStack "IGCM_sys_Get"
891}
892
893############################################################## A REVOIR !!
894
895#D-#==================================================
896#D-function IGCM_sys_Rapatrie
897#D-* Purpose: Rapatrie
898#D-* Examples:
899#D-
900function IGCM_sys_Rapatrie {
901    IGCM_debug_PushStack "IGCM_sys_Rapatrie" $@
902    if ( $DEBUG_sys ) ; then
903        echo "IGCM_sys_Rapatrie :" $@
904    fi
905
906    typeset RET=0
907
908    IGCM_sys_Get ${R_STOCKAGE}/$2 $1 ;
909    let $(( RET=RET+$? ))
910    IGCM_sys_Cd $1 ;
911    let $(( RET=RET+$? ))
912    IGCM_sys_UnTar $2 ;
913    let $(( RET=RET+$? ))
914
915    if [ ${RET} -gt 0 ] ; then
916        echo "IGCM_sys_Rapatrie : erreur."
917        IGCM_debug_Exit "IGCM_sys_Rapatrie"
918    fi
919    IGCM_debug_PopStack "IGCM_sys_Rapatrie"
920}
921
922############################################################## A FINIR !!
923
924#D-#==================================================
925#D-function IGCM_sys_GetDate_FichWork
926#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
927#D-* Examples:
928#D-
929function IGCM_sys_GetDate_FichWork {
930    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
931    if ( $DEBUG_sys ) ; then
932        echo "IGCM_sys_GetDate_FichWork :" $@
933    fi
934    # donne la date filesys d'un fichier sur la machine work
935    IGCM_debug_PopStack "IGCM_sys_FichWork"
936}
937
938#D-#==================================================
939#D-function IGCM_sys_GetDate_FichArchive
940#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
941#D-* Examples:
942#D-
943function IGCM_sys_GetDate_FichArchive {
944    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
945    if ( $DEBUG_sys ) ; then
946        echo "IGCM_sys_GetDate_FichArchive :" $@
947    fi
948    IGCM_debug_PopStack "IGCM_sys_FichArchive"
949}
950
951##############################################################
952# REBUILD OPERATOR
953
954function IGCM_sys_rebuild {
955    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
956    if ( $DEBUG_sys ) ; then
957        echo "IGCM_sys_rebuild :" $@
958    fi
959    /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@
960    if [ $? -gt 0 ] ; then
961       echo "IGCM_sys_rebuild : erreur ${@}."
962       IGCM_debug_Exit "rebuild"
963    fi
964
965    IGCM_debug_PopStack "IGCM_sys_rebuild"
966}
967
968############################################################
969# Activate Running Environnment Variables
970
971function IGCM_sys_activ_variables {
972    IGCM_debug_PushStack "IGCM_sys_activ_variables"
973    if ( $DEBUG_sys ) ; then
974        echo "IGCM_sys_activ_variables"
975    fi
976
977# --------------------------------------------------------------------
978#D- MPI specifications
979# --------------------------------------------------------------------
980
981#D-- MPISUSPEND
982    export MPISUSPEND=ON
983#D-- MPIPROGINF
984    export MPIPROGINF=ALL
985#other choices : ALL_DETAIL2
986
987# --------------------------------------------------------------------
988#D- Other specifications
989# --------------------------------------------------------------------
990
991#D- max number of character/line in output job
992    export F_SYSLEN=5000
993#D- number of error that can be admitted on the NEC
994    export F_ERRCNT=0
995#D- global performance
996    export F_PROGINF=DETAIL
997#D- activate ftrace (with -ftrace)
998    export F_FTRACE=YES
999#D- communication information (with -ftrace)
1000    export MPICOMMINF=NO
1001#D- I/O performance (FORTRAN I/O only not netCDF)
1002    export F_FILEINF=NO
1003# netCDF I/O performance
1004    export NC_FILEINF=NO   
1005
1006    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1007
1008}
1009
1010############################################################
1011# Desactivate Running Environnment Variables
1012
1013function IGCM_sys_desactiv_variables {
1014    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1015    if ( $DEBUG_sys ) ; then
1016        echo "IGCM_sys_desactiv_variables"
1017    fi
1018# --------------------------------------------------------------------
1019#D- MPI specifications
1020# --------------------------------------------------------------------
1021
1022#D-- MPIPROGINF
1023    export MPIPROGINF=NO
1024
1025# --------------------------------------------------------------------
1026#D- Other specifications
1027# --------------------------------------------------------------------
1028
1029#D- global performance
1030    export F_PROGINF=NO 
1031
1032    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1033 
1034}
1035
1036############################################################
1037# Build run file
1038
1039function IGCM_sys_build_run_file {
1040    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1041    if ( $DEBUG_sys ) ; then
1042        echo "IGCM_sys_build_run_file " $@
1043    fi
1044    (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 ))
1045    (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1046    (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1047   
1048    if [ $1 = MPI2 ]; then
1049        cat <<EOF > run_file
1050-p 1 -np 1 -e ./oasis
1051EOF
1052        (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 ))
1053        config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"'
1054
1055    elif [ $1 = MPI1 ]; then
1056        cat <<EOF > run_file
1057-p $NUM_PROC_OASIS -e ./oasis
1058-p $NUM_PROC_ATM -e ./lmdz.x
1059-p $NUM_PROC_OCE -e ./opa.xx
1060EOF
1061 
1062    fi
1063
1064    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1065 
1066}
Note: See TracBrowser for help on using the repository browser.