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

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

Explicit all MASTER name.
for exemple you can not rcp vargas92, but vargas you can

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