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

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

gawk specific path on SX9 and SX8-R

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