source: tags/libIGCM_v1_2/libIGCM_sys/libIGCM_sys_zahir.ksh @ 234

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

SD : - correct bug with post-processing in case of asynchronous rebuild.

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