source: tags/libIGCM_v1_2/libIGCM_sys/libIGCM_sys_mercure.ksh @ 293

Last change on this file since 293 was 44, checked in by sdipsl, 15 years ago

SD : - correct bug with post-processing in case of asynchronous rebuild.

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