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

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

MAF :
On the way to finalyze vargas

  • adjustment to support large numbers of cpus (and files)
  • prepare another policy for rebuild : from workdir

Some cleanup

  • 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: 31.0 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip
5# Contact: Martial.Mancip_ipsl.jussieu.fr
6# $Date$
7# $Author$
8# $Revision$
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11# History:
12# Modification:
13#
14#**************************************************************
15
16#=========================================================
17# The documentation of this file can be automatically generated
18# if you use the prefix #D- for comments to be extracted.
19# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
20#=========================================================
21
22#D-#==================================================
23#D-LibIGCM_sys for Mercure
24#D-#==================================================
25#D-
26#D- This ksh library if a layer under some usefull
27#D-environment variables and shell commands.
28#D-All those definitions depend on host particularities.
29#D-It manages a stack mechanism and test validity of operations.
30#D-All function described bellow must be prefixed by IGCM_sys.
31
32#====================================================
33# libIGCM_sys PARAMETERS
34#====================================================
35
36#====================================================
37# set DEBUG_sys to true to output calls of function
38typeset -r DEBUG_sys=${DEBUG_sys:=true}
39
40#====================================================
41# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
42typeset -r DRYRUN=${DRYRUN:=0}
43
44# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
45# -------------------------------------------------------------------------------------
46# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
47# |          |  Cp/Exe param files |            |  Chmod  |                           |
48# |          |      Qsub           |            |         |                           |
49# -------------------------------------------------------------------------------------
50# |    0     |       yes           |    yes     |  yes    |      yes                  |
51# -------------------------------------------------------------------------------------
52# |    1     |       yes           |    yes     |  yes    |      no                   |
53# -------------------------------------------------------------------------------------
54# |    2     |       yes           |    yes     |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56# |    3     |       yes           |    no      |  no     |      no                   |
57# -------------------------------------------------------------------------------------
58
59#=====================================================
60# Global Variables :
61#=====================================================
62# Language : "fr" or "en"
63typeset -r MYLANG="fr"
64
65#=====================================================
66# Host and user names
67# $hostname ou hostname
68typeset -r HOST=$( hostname )
69# $username ou whoami
70typeset -r LOGIN=$( whoami )
71# $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_Rm
600#D-* Purpose: generic rm
601#D-* Examples:
602#D-
603function IGCM_sys_Rm {
604    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
605    if ( $DEBUG_sys ) ; then
606        echo "IGCM_sys_Rm :" $@
607    fi
608
609    typeset RET
610
611    echo rm $@ > out_rsync 2>&1
612    \rm $@ >> out_rsync 2>&1
613    RET=$?
614
615    if [ ${RET} -gt 0 ] ; then
616        echo "IGCM_sys_Rm : error."
617        cat out_rsync
618        IGCM_debug_Exit "IGCM_sys_Rm"
619    fi
620    IGCM_debug_PopStack "IGCM_sys_Rm"
621}
622
623#D-#==================================================
624#D-function IGCM_sys_Mv
625#D-* Purpose: generic move
626#D-* Examples:
627#D-
628function IGCM_sys_Mv {
629    IGCM_debug_PushStack "IGCM_sys_Mv" $@
630    if ( $DEBUG_sys ) ; then
631        echo "IGCM_sys_Mv :" $@
632    fi
633
634    typeset RET
635
636    echo mv $@ > out_rsync 2>&1
637    \mv $@ >> out_rsync 2>&1
638    RET=$?
639
640    if [ ${RET} -gt 0 ] ; then
641        echo "IGCM_sys_Mv : error in mv."
642        cat out_rsync
643        IGCM_debug_Exit "IGCM_sys_Mv"
644    fi
645
646    IGCM_debug_PopStack "IGCM_sys_Mv"
647}
648
649#D-#==================================================
650#D-function IGCM_sys_Put_Dir
651#D-* Purpose: Copy a complete directory on $(ARCHIVE)
652#D-* Examples:
653#D-
654function IGCM_sys_Put_Dir {
655    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
656    if ( $DEBUG_sys ) ; then
657        echo "IGCM_sys_Put_Dir :" $@
658    fi
659    if [ $DRYRUN = 0 ]; then
660        if [ ! -d ${1} ] ; then
661            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
662            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
663            return
664        fi
665
666        typeset RET
667
668        # Only if we use rsync
669        #IGCM_sys_TestDirArchive $( dirname $2 )
670        #
671        #USUAL WAY
672        \cp -r $1 $2 > out_rsync 2>&1
673        RET=$?
674
675        if [ ${RET} -gt 0 ] ; then
676            echo "IGCM_sys_Put_Dir : error."
677            cat out_rsync
678            IGCM_debug_Exit "IGCM_sys_Put_Dir"
679        fi
680    else
681        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
682    fi
683    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
684}
685
686#D-#==================================================
687#D-function IGCM_sys_Get_Dir
688#D-* Purpose: Copy a complete directory from $(ARCHIVE)
689#D-* Examples:
690#D-
691function IGCM_sys_Get_Dir {
692    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
693    if ( $DEBUG_sys ) ; then
694        echo "IGCM_sys_Get_Dir :" $@
695    fi
696    if [ $DRYRUN = 0 ]; then
697        if [ ! -d ${1} ] ; then
698            echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
699            IGCM_debug_PopStack "IGCM_sys_Get_Dir"
700            return
701        fi
702
703        typeset RET
704
705        # Only if we use rsync
706        #IGCM_sys_TestDirArchive $( dirname $2 )
707        #
708        #USUAL WAY
709        \cp -r $1 $2 > out_rsync 2>&1
710        RET=$?
711
712        if [ ${RET} -gt 0 ] ; then
713            echo "IGCM_sys_Get_Dir : error."
714            cat out_rsync
715            IGCM_debug_Exit "IGCM_sys_Get_Dir"
716        fi
717    else
718        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
719    fi
720    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
721}
722
723#D-#==================================================
724#D-function IGCM_sys_Put_Rest
725#D-* Purpose: Put computied restarts on $(ARCHIVE).
726#D-           File and target directory must exist.
727#D-* Examples:
728#D-
729function IGCM_sys_Put_Rest {
730    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
731    if ( $DEBUG_sys ) ; then
732        echo "IGCM_sys_Put_Rest :" $@
733    fi
734    if [ $DRYRUN = 0 ]; then
735        if [ ! -f ${1} ] ; then
736            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
737            IGCM_debug_Exit "IGCM_sys_Put_Rest"
738        fi
739
740        typeset RET
741        #
742        IGCM_sys_Chmod 444 ${1}
743        #
744        IGCM_sys_TestDirArchive $( dirname $2 )
745        #
746        # USUAL WAY
747        putfer $1 $2 > out_rsync 2>&1
748        RET=$?
749
750#       #RSYNC WITH NETWORK RSH CALL
751#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
752#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
753
754#       #RSYNC WITH NFS USE
755#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
756#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
757
758#       RET=$?
759#       IGCM_sys_Rsync_out $RET
760
761#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
762#       (( RET=RET+$? ))
763
764        if [ ${RET} -gt 0 ] ; then
765            echo "IGCM_sys_Put_Rest : error."
766            cat out_rsync
767            IGCM_debug_Exit "IGCM_sys_Put_Rest"
768        fi
769    else
770        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
771    fi
772    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
773}
774
775#D-#==================================================
776#D-function IGCM_sys_Put_Out
777#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
778#D-* Examples:
779#D-
780function IGCM_sys_Put_Out {
781    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
782    if ( $DEBUG_sys ) ; then
783        echo "IGCM_sys_Put_Out :" $@
784    fi
785    if [ $DRYRUN = 0 ]; then
786        if [ ! -f ${1} ] ; then
787            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
788            IGCM_debug_PopStack "IGCM_sys_Put_Out"
789            return 1
790        fi
791        #
792        IGCM_sys_MkdirArchive $( dirname $2 )
793        #
794        typeset RET
795
796        #=====================================================
797        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
798        #=====================================================
799
800        #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
801        #if [ $? -eq 0 ] ; then
802        #    typeset WORKPATH FILEPATH
803        #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
804        #    IGCM_sys_MkdirWork ${WORKPATH}
805        #    FILEPATH=${WORKPATH}/$( basename $2 )
806        #    #
807        #    IGCM_sys_Cp ${1} ${FILEPATH}
808        #fi
809
810        IGCM_sys_Chmod 444 ${1}
811        #
812        # USUAL WAY
813        putfer $1 $2 > out_rsync 2>&1
814        RET=$?
815
816#       #RSYNC WITH NETWORK RSH CALL
817#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
818#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
819
820#       #RSYNC WITH NFS USE
821#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
822#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
823
824#       RET=$?
825#       IGCM_sys_Rsync_out $RET
826
827#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
828#       (( RET=RET+$? ))
829
830        if [ ${RET} -gt 0 ] ; then
831            echo "IGCM_sys_Put_Out : error."
832            cat out_rsync
833            IGCM_debug_Exit "IGCM_sys_Put_Out"
834        fi
835    else
836        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
837    fi
838    IGCM_debug_PopStack "IGCM_sys_Put_Out"
839    return 0
840}
841
842#D-#==================================================
843#D-function IGCM_sys_Get
844#D-* Purpose: Get a file from ${ARCHIVE}
845#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
846#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
847function IGCM_sys_Get {
848    IGCM_debug_PushStack "IGCM_sys_Get" $@
849
850    typeset DEST RET dm_liste ifile target file_work
851
852    if ( $DEBUG_sys ) ; then
853        echo "IGCM_sys_Get :" $@
854    fi
855    if [ $DRYRUN -le 2 ]; then
856        if [ X${1} = X'/l' ] ; then
857            # test if the first file is present in the old computation :
858            eval set +A dm_liste \${${2}}
859        else
860            eval set +A dm_liste ${1}
861        fi
862        eval DEST=\${${#}}
863
864        #=====================================================
865        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
866        #=====================================================
867
868        # Is it an R_OUT file (not R_IN) ?
869        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
870        #if [ $? -eq 0 ] ; then
871        #    # Yes  ? then we try to get it in SCRATCHDIR
872        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|" )
873        #    if [ -f ${file_work[0]} ] ; then
874        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
875        #       IGCM_debug_PopStack "IGCM_sys_Get"
876        #       return
877        #    fi
878        #fi
879
880        # test if the (first) file is present in the old computation :
881        IGCM_sys_TestFileArchive ${dm_liste[0]}
882        RET=$?
883        if [ ${RET} -gt 0 ] ; then
884            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
885            IGCM_debug_Exit "IGCM_sys_Get"
886            IGCM_debug_PopStack "IGCM_sys_Get"
887            return
888        fi
889
890        dmget ${dm_liste[*]} > out_rsync 2>&1
891        RET=$?
892        if [ ${RET} -gt 0 ] ; then
893            echo "IGCM_sys_Get : demigration error."
894            cat out_rsync
895            IGCM_debug_Exit "IGCM_sys_Get"
896        fi
897
898        #USUAL WAY
899        if [ X${1} = X'/l' ] ; then
900            (( RET=0 ))
901            for target in ${dm_liste[*]} ; do
902                local_file=$( basename ${target} )
903                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
904                (( RET = RET + $? ))
905            done
906        else
907            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
908            RET=$?
909        fi
910
911#       #RSYNC WITH NETWORK RSH CALL
912#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
913#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
914
915#       #RSYNC WITH NFS USE
916#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
917#       ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
918
919#       RET=$?
920#       IGCM_sys_Rsync_out $RET
921
922#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
923#       (( RET=RET+$? ))
924
925        if [ ${RET} -gt 0 ] ; then
926            echo "IGCM_sys_Get : copy error."
927            cat out_rsync
928            IGCM_debug_Exit "IGCM_sys_Get"
929        fi
930    else
931        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
932    fi
933    IGCM_debug_PopStack "IGCM_sys_Get"
934}
935
936############################################################## A REVOIR !!
937
938#D-#==================================================
939#D-function IGCM_sys_Rapatrie
940#D-* Purpose: Rapatrie
941#D-* Examples:
942#D-
943function IGCM_sys_Rapatrie {
944    IGCM_debug_PushStack "IGCM_sys_Rapatrie" $@
945    if ( $DEBUG_sys ) ; then
946        echo "IGCM_sys_Rapatrie :" $@
947    fi
948
949    typeset RET=0
950
951    IGCM_sys_Get ${R_STOCKAGE}/$2 $1 ;
952    let $(( RET=RET+$? ))
953    IGCM_sys_Cd $1 ;
954    let $(( RET=RET+$? ))
955    IGCM_sys_UnTar $2 ;
956    let $(( RET=RET+$? ))
957
958    if [ ${RET} -gt 0 ] ; then
959        echo "IGCM_sys_Rapatrie : erreur."
960        IGCM_debug_Exit "IGCM_sys_Rapatrie"
961    fi
962    IGCM_debug_PopStack "IGCM_sys_Rapatrie"
963}
964
965############################################################## A FINIR !!
966
967#D-#==================================================
968#D-function IGCM_sys_GetDate_FichWork
969#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
970#D-* Examples:
971#D-
972function IGCM_sys_GetDate_FichWork {
973    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
974    if ( $DEBUG_sys ) ; then
975        echo "IGCM_sys_GetDate_FichWork :" $@
976    fi
977    # donne la date filesys d'un fichier sur la machine work
978    IGCM_debug_PopStack "IGCM_sys_FichWork"
979}
980
981#D-#==================================================
982#D-function IGCM_sys_GetDate_FichArchive
983#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
984#D-* Examples:
985#D-
986function IGCM_sys_GetDate_FichArchive {
987    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
988    if ( $DEBUG_sys ) ; then
989        echo "IGCM_sys_GetDate_FichArchive :" $@
990    fi
991    IGCM_debug_PopStack "IGCM_sys_FichArchive"
992}
993
994##############################################################
995# REBUILD OPERATOR
996
997function IGCM_sys_rebuild {
998    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
999    if ( $DEBUG_sys ) ; then
1000        echo "IGCM_sys_rebuild :" $@
1001    fi
1002    /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@
1003    if [ $? -gt 0 ] ; then
1004       echo "IGCM_sys_rebuild : erreur ${@}."
1005       IGCM_debug_Exit "rebuild"
1006    fi
1007
1008    IGCM_debug_PopStack "IGCM_sys_rebuild"
1009}
1010
1011############################################################
1012# Activate Running Environnment Variables
1013
1014function IGCM_sys_activ_variables {
1015    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1016    if ( $DEBUG_sys ) ; then
1017        echo "IGCM_sys_activ_variables"
1018    fi
1019
1020# --------------------------------------------------------------------
1021#D- MPI specifications
1022# --------------------------------------------------------------------
1023
1024#D-- MPISUSPEND
1025    export MPISUSPEND=ON
1026#D-- MPIPROGINF
1027    export MPIPROGINF=ALL
1028#other choices : ALL_DETAIL2
1029
1030# --------------------------------------------------------------------
1031#D- Other specifications
1032# --------------------------------------------------------------------
1033
1034#D- max number of character/line in output job
1035    export F_SYSLEN=5000
1036#D- number of error that can be admitted on the NEC
1037    export F_ERRCNT=0
1038#D- global performance
1039    export F_PROGINF=DETAIL
1040#D- activate ftrace (with -ftrace)
1041    export F_FTRACE=YES
1042#D- communication information (with -ftrace)
1043    export MPICOMMINF=NO
1044#D- I/O performance (FORTRAN I/O only not netCDF)
1045    export F_FILEINF=NO
1046# netCDF I/O performance
1047    export NC_FILEINF=NO   
1048
1049    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1050
1051}
1052
1053############################################################
1054# Desactivate Running Environnment Variables
1055
1056function IGCM_sys_desactiv_variables {
1057    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1058    if ( $DEBUG_sys ) ; then
1059        echo "IGCM_sys_desactiv_variables"
1060    fi
1061# --------------------------------------------------------------------
1062#D- MPI specifications
1063# --------------------------------------------------------------------
1064
1065#D-- MPIPROGINF
1066    export MPIPROGINF=NO
1067
1068# --------------------------------------------------------------------
1069#D- Other specifications
1070# --------------------------------------------------------------------
1071
1072#D- global performance
1073    export F_PROGINF=NO 
1074
1075    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1076 
1077}
1078
1079############################################################
1080# Build run file
1081
1082function IGCM_sys_build_run_file {
1083    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1084    if ( $DEBUG_sys ) ; then
1085        echo "IGCM_sys_build_run_file " $@
1086    fi
1087    (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 ))
1088    (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1089    (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1090   
1091    if [ $1 = MPI2 ]; then
1092        cat <<EOF > run_file
1093-p 1 -np 1 -e ./oasis
1094EOF
1095        (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 ))
1096        config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"'
1097
1098    elif [ $1 = MPI1 ]; then
1099        cat <<EOF > run_file
1100-p $NUM_PROC_OASIS -e ./oasis
1101-p $NUM_PROC_ATM -e ./lmdz.x
1102-p $NUM_PROC_OCE -e ./opa.xx
1103EOF
1104 
1105    fi
1106
1107    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1108 
1109}
Note: See TracBrowser for help on using the repository browser.