source: branches/SmoothFiles/libIGCM_sys/libIGCM_sys_mercure.ksh @ 8

Last change on this file since 8 was 8, checked in by mmaipsl, 16 years ago

MM: Add SmoothFiles? with last commit (r6) corrections.

  • 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: 27.8 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        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_Rest
591#D-* Purpose: Put computied restarts on $(ARCHIVE).
592#D-           File and target directory must exist.
593#D-* Examples:
594#D-
595function IGCM_sys_Put_Rest {
596    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
597    if ( $DEBUG_sys ) ; then
598        echo "IGCM_sys_Put_Rest :" $@
599    fi
600    if [ $DRYRUN = 0 ]; then
601        if [ ! -f ${1} ] ; then
602            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
603            IGCM_debug_Exit "IGCM_sys_Put_Rest"
604        fi
605
606        typeset RET
607        #
608        IGCM_sys_Chmod 444 ${1}
609        #
610        IGCM_sys_TestDirArchive $( dirname $2 )
611        #
612        # USUAL WAY
613        putfer $1 $2 > out_rsync 2>&1
614        RET=$?
615
616#       #RSYNC WITH NETWORK RSH CALL
617#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
618#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
619
620#       #RSYNC WITH NFS USE
621#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
622#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
623
624#       RET=$?
625#       IGCM_sys_Rsync_out $RET
626
627#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
628#       (( RET=RET+$? ))
629
630        if [ ${RET} -gt 0 ] ; then
631            echo "IGCM_sys_Put_Rest : error."
632            cat out_rsync
633            IGCM_debug_Exit "IGCM_sys_Put_Rest"
634        fi
635    else
636        echo "DRYRUN mode = " $DRYRUN >> stack
637    fi
638    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
639}
640
641#D-#==================================================
642#D-function IGCM_sys_Put_Out
643#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
644#D-* Examples:
645#D-
646function IGCM_sys_Put_Out {
647    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
648    if ( $DEBUG_sys ) ; then
649        echo "IGCM_sys_Put_Out :" $@
650    fi
651    if [ $DRYRUN = 0 ]; then
652        if [ ! -f ${1} ] ; then
653            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
654            IGCM_debug_PopStack "IGCM_sys_Put_Out"
655            return 1
656        fi
657        #
658        IGCM_sys_MkdirArchive $( dirname $2 )
659        #
660        typeset RET
661
662        #=====================================================
663        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
664        #=====================================================
665
666        #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
667        #if [ $? -eq 0 ] ; then
668        #    typeset WORKPATH FILEPATH
669        #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
670        #    IGCM_sys_MkdirWork ${WORKPATH}
671        #    FILEPATH=${WORKPATH}/$( basename $2 )
672        #    #
673        #    IGCM_sys_Cp ${1} ${FILEPATH}
674        #fi
675
676        IGCM_sys_Chmod 444 ${1}
677        #
678        # USUAL WAY
679        putfer $1 $2 > out_rsync 2>&1
680        RET=$?
681
682#       #RSYNC WITH NETWORK RSH CALL
683#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
684#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
685
686#       #RSYNC WITH NFS USE
687#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
688#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
689
690#       RET=$?
691#       IGCM_sys_Rsync_out $RET
692
693#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
694#       (( RET=RET+$? ))
695
696        if [ ${RET} -gt 0 ] ; then
697            echo "IGCM_sys_Put_Out : error."
698            cat out_rsync
699            IGCM_debug_Exit "IGCM_sys_Put_Out"
700        fi
701    else
702        echo "DRYRUN mode = " $DRYRUN >> stack
703    fi
704    IGCM_debug_PopStack "IGCM_sys_Put_Out"
705    return 0
706}
707
708#D-#==================================================
709#D-function IGCM_sys_Get
710#D-* Purpose: Get a file from ${ARCHIVE}
711#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
712#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
713function IGCM_sys_Get {
714    IGCM_debug_PushStack "IGCM_sys_Get" $@
715
716    typeset DEST RET dm_liste ifile target file_work
717
718    if ( $DEBUG_sys ) ; then
719        echo "IGCM_sys_Get :" $@
720    fi
721    if [ $DRYRUN -le 2 ]; then
722        if [ X${1} = X'/l' ] ; then
723            # test if the first file is present in the old computation :
724            eval set +A dm_liste \${${2}}
725        else
726            eval set +A dm_liste ${1}
727        fi
728        eval DEST=\${${#}}
729
730        #=====================================================
731        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
732        #=====================================================
733
734        # Is it an R_OUT file (not R_IN) ?
735        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
736        #if [ $? -eq 0 ] ; then
737        #    # Yes  ? then we try to get it in SCRATCHDIR
738        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
739        #    if [ -f ${file_work[0]} ] ; then
740        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
741        #       IGCM_debug_PopStack "IGCM_sys_Get"
742        #       return
743        #    fi
744        #fi
745
746        # test if the (first) file is present in the old computation :
747        IGCM_sys_TestFileArchive ${dm_liste[0]}
748        RET=$?
749        if [ ${RET} -gt 0 ] ; then
750            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
751            IGCM_debug_Exit "IGCM_sys_Get"
752            IGCM_debug_PopStack "IGCM_sys_Get"
753            return
754        fi
755
756        dmget ${dm_liste[*]} > out_rsync 2>&1
757        RET=$?
758        if [ ${RET} -gt 0 ] ; then
759            echo "IGCM_sys_Get : demigration error."
760            cat out_rsync
761            IGCM_debug_Exit "IGCM_sys_Get"
762        fi
763
764        #USUAL WAY
765        if [ X${1} = X'/l' ] ; then
766            (( RET=0 ))
767            for target in ${dm_liste[*]} ; do
768                local_file=$( basename ${target} )
769                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
770                (( RET = RET + $? ))
771            done
772        else
773            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
774            RET=$?
775        fi
776
777#       #RSYNC WITH NETWORK RSH CALL
778#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
779#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
780
781#       #RSYNC WITH NFS USE
782#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
783#       ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
784
785#       RET=$?
786#       IGCM_sys_Rsync_out $RET
787
788#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
789#       (( RET=RET+$? ))
790
791        if [ ${RET} -gt 0 ] ; then
792            echo "IGCM_sys_Get : copy error."
793            cat out_rsync
794            IGCM_debug_Exit "IGCM_sys_Get"
795        fi
796    else
797        echo "DRYRUN mode = " $DRYRUN >> stack
798    fi
799    IGCM_debug_PopStack "IGCM_sys_Get"
800}
801
802############################################################## A REVOIR !!
803
804#D-#==================================================
805#D-function IGCM_sys_Rapatrie
806#D-* Purpose: Rapatrie
807#D-* Examples:
808#D-
809function IGCM_sys_Rapatrie {
810    IGCM_debug_PushStack "IGCM_sys_Rapatrie" $@
811    if ( $DEBUG_sys ) ; then
812        echo "IGCM_sys_Rapatrie :" $@
813    fi
814
815    typeset RET=0
816
817    IGCM_sys_Get ${R_STOCKAGE}/$2 $1 ;
818    let $(( RET=RET+$? ))
819    IGCM_sys_Cd $1 ;
820    let $(( RET=RET+$? ))
821    IGCM_sys_UnTar $2 ;
822    let $(( RET=RET+$? ))
823
824    if [ ${RET} -gt 0 ] ; then
825        echo "IGCM_sys_Rapatrie : erreur."
826        IGCM_debug_Exit "IGCM_sys_Rapatrie"
827    fi
828    IGCM_debug_PopStack "IGCM_sys_Rapatrie"
829}
830
831############################################################## A FINIR !!
832
833#D-#==================================================
834#D-function IGCM_sys_GetDate_FichWork
835#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
836#D-* Examples:
837#D-
838function IGCM_sys_GetDate_FichWork {
839    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
840    if ( $DEBUG_sys ) ; then
841        echo "IGCM_sys_GetDate_FichWork :" $@
842    fi
843    # donne la date filesys d'un fichier sur la machine work
844    IGCM_debug_PopStack "IGCM_sys_FichWork"
845}
846
847#D-#==================================================
848#D-function IGCM_sys_GetDate_FichArchive
849#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
850#D-* Examples:
851#D-
852function IGCM_sys_GetDate_FichArchive {
853    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
854    if ( $DEBUG_sys ) ; then
855        echo "IGCM_sys_GetDate_FichArchive :" $@
856    fi
857    IGCM_debug_PopStack "IGCM_sys_FichArchive"
858}
859
860##############################################################
861# REBUILD OPERATOR
862
863function IGCM_sys_rebuild {
864    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
865    if ( $DEBUG_sys ) ; then
866        echo "IGCM_sys_rebuild :" $@
867    fi
868    /home/cont003/p86ipsl/SX/bin/rebuild -f -o $@
869    if [ $? -gt 0 ] ; then
870       echo "IGCM_sys_rebuild : erreur ${@}."
871       IGCM_debug_Exit "rebuild"
872    fi
873
874    IGCM_debug_PopStack "IGCM_sys_rebuild"
875}
876
877############################################################
878# Activate Running Environnment Variables
879
880function IGCM_sys_activ_variables {
881    IGCM_debug_PushStack "IGCM_sys_activ_variables"
882    if ( $DEBUG_sys ) ; then
883        echo "IGCM_sys_activ_variables"
884    fi
885
886# --------------------------------------------------------------------
887#D- MPI specifications
888# --------------------------------------------------------------------
889
890#D-- MPISUSPEND
891    export MPISUSPEND=ON
892#D-- MPIPROGINF
893    export MPIPROGINF=ALL
894#other choices : ALL_DETAIL2
895
896# --------------------------------------------------------------------
897#D- Other specifications
898# --------------------------------------------------------------------
899
900#D- max number of character/line in output job
901    export F_SYSLEN=5000
902#D- number of error that can be admitted on the NEC
903    export F_ERRCNT=0
904#D- global performance
905    export F_PROGINF=DETAIL
906#D- activate ftrace (with -ftrace)
907    export F_FTRACE=YES
908#D- communication information (with -ftrace)
909    export MPICOMMINF=NO
910#D- I/O performance (FORTRAN I/O only not netCDF)
911    export F_FILEINF=NO
912# netCDF I/O performance
913    export NC_FILEINF=NO   
914
915    IGCM_debug_PopStack "IGCM_sys_activ_variables"
916
917}
918
919############################################################
920# Desactivate Running Environnment Variables
921
922function IGCM_sys_desactiv_variables {
923    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
924    if ( $DEBUG_sys ) ; then
925        echo "IGCM_sys_desactiv_variables"
926    fi
927# --------------------------------------------------------------------
928#D- MPI specifications
929# --------------------------------------------------------------------
930
931#D-- MPIPROGINF
932    export MPIPROGINF=NO
933
934# --------------------------------------------------------------------
935#D- Other specifications
936# --------------------------------------------------------------------
937
938#D- global performance
939    export F_PROGINF=NO 
940
941    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
942 
943}
944
945############################################################
946# Build run file
947
948function IGCM_sys_build_run_file {
949    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
950    if ( $DEBUG_sys ) ; then
951        echo "IGCM_sys_build_run_file " $@
952    fi
953    (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 ))
954    (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
955    (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
956   
957    if [ $1 = MPI2 ]; then
958        cat <<EOF > run_file
959-p 1 -np 1 -e ./oasis
960EOF
961        (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 ))
962        config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"'
963
964    elif [ $1 = MPI1 ]; then
965        cat <<EOF > run_file
966-p $NUM_PROC_OASIS -e ./oasis
967-p $NUM_PROC_ATM -e ./lmdz.x
968-p $NUM_PROC_OCE -e ./opa.xx
969EOF
970 
971    fi
972
973    IGCM_debug_PopStack "IGCM_sys_build_run_file"
974 
975}
Note: See TracBrowser for help on using the repository browser.