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

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