source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_brodie.ksh @ 59

Last change on this file since 59 was 59, checked in by sdipsl, 15 years ago
  • change headers to force ksh in the shell
  • adapt rsync to ulam
  • full path for llsubmit
  • reflect the fact that ulam does not see gaya file system
  • Asynchronous rebuild OK, classic post-treatment not
  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Date Author Revision
File size: 30.6 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 Brodie
24#D-#=================================================
25#D-
26#D- This ksh library if a layer under some usefull
27#D-environment variables and shell commands.
28#D-All those definitions depend on host particularities.
29#D-It manages a stack mechanism and test validity of operations.
30#D-All function described bellow must be prefixed by IGCM_sys.
31
32#====================================================
33# libIGCM_sys PARAMETERS
34#====================================================
35
36#====================================================
37# set DEBUG_sys to true to output calls of function
38typeset -r DEBUG_sys=${DEBUG_sys:=true}
39
40#====================================================
41# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
42typeset -r DRYRUN=${DRYRUN:=0}
43
44# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
45# -------------------------------------------------------------------------------------
46# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
47# |          |  Cp/Exe param files |            |  Chmod  |                           |
48# |          |      Qsub           |            |         |                           |
49# -------------------------------------------------------------------------------------
50# |    0     |       yes           |    yes     |  yes    |      yes                  |
51# -------------------------------------------------------------------------------------
52# |    1     |       yes           |    yes     |  yes    |      no                   |
53# -------------------------------------------------------------------------------------
54# |    2     |       yes           |    yes     |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56# |    3     |       yes           |    no      |  no     |      no                   |
57# -------------------------------------------------------------------------------------
58
59#=====================================================
60# Global Variables :
61#=====================================================
62# Language : "fr" or "en"
63typeset -r MYLANG="fr"
64
65#=====================================================
66# Host and user names
67# $hostname ou hostname
68typeset -r HOST=$( hostname )
69# $username ou whoami
70typeset -r LOGIN=$( whoami )
71
72#D-
73#D-#==================================================
74#D-Program used in libIGCM
75#D-#==================================================
76
77# rsync with path
78typeset -r RSYNC=/home/rech/ces/rces452/RSYNC_SX8/bin/rsync
79# RSYNC_opt args to "local rsync"
80typeset -r RSYNC_FRONT="rsh ulam /usr/bin/rsync "
81# RSYNC_opt args to rsync
82typeset -r RSYNC_opt="-va"
83# RSYNC_opt args to "remote rsync"
84# ie storage filesystem
85typeset -r RHOST=gaya.idris.fr
86typeset -r REMOTE_RSYNC=/u/rech/ces/rces452/RSYNC/bin/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:=${PBS_O_WORKDIR}}
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 ulam
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 ulam -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   rsh gaya -n 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: Post-process 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 ulam 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/bin/nqsII/qsub -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $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    /opt/ibmll/LoadL/full/bin/llsubmit ${libIGCM_POST}/$1.job
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 ulam
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
581    IGCM_sys_RshPost <<-EOF
582    mkdir -p ${PATHlibIGCM}
583EOF
584    rsh ulam -n hostname > /dev/null 2>&1
585    RET=$?
586    if [ $RET -eq 0 ] ; then
587#       echo rcp -r ${libIGCM} ulam:${HOME}/${PATHlibIGCM} > out_rsync 2>&1
588#       rcp -r ${libIGCM} ulam:${HOME}/${PATHlibIGCM} >> out_rsync 2>&1
589        echo ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME}/${PATHlibIGCM} > out_rsync 2>&1
590        ${RSYNC} ${RSYNC_opt} -e "rsh " ${libIGCM} ulam:${HOME}/${PATHlibIGCM} >> out_rsync 2>&1
591        RET=$?
592
593        if [ ${RET} -gt 0 ] ; then
594            echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on ulam."
595            cat out_rsync
596        fi
597    else
598        echo "No POST-TREATMENT avaible because ulam is down."
599    fi
600    IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
601}
602
603#====================================================
604#- Call IGCM_sys_Mirror_libIGCM now !
605PATHlibIGCM=$( echo ${libIGCM} | awk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" )
606if ( $MirrorlibIGCM ) ; then
607    IGCM_sys_Mirror_libIGCM
608fi
609
610#====================================================
611#- libIGCM_POST
612typeset -r libIGCM_POST=${HOME}/${PATHlibIGCM}/libIGCM
613
614#D-#==================================================
615#D-function IGCM_sys_Cp
616#D-* Purpose: generic cp
617#D-* Examples:
618#D-
619function IGCM_sys_Cp {
620    IGCM_debug_PushStack "IGCM_sys_Cp" $@
621    if ( $DEBUG_sys ) ; then
622        echo "IGCM_sys_Cp :" $@
623    fi
624
625    typeset RET
626
627    echo cp $@ > out_rsync 2>&1
628    \cp $@ >> out_rsync 2>&1
629    RET=$?
630
631    if [ ${RET} -gt 0 ] ; then
632        echo "IGCM_sys_Cp : error."
633        cat out_rsync
634        IGCM_debug_Exit "IGCM_sys_Cp"
635    fi
636    IGCM_debug_PopStack "IGCM_sys_Cp"
637}
638
639#D-#==================================================
640#D-function IGCM_sys_Mv
641#D-* Purpose: generic move
642#D-* Examples:
643#D-
644function IGCM_sys_Mv {
645    IGCM_debug_PushStack "IGCM_sys_Mv" $@
646    if ( $DEBUG_sys ) ; then
647        echo "IGCM_sys_Mv :" $@
648    fi
649
650    typeset RET
651
652    echo mv $@ > out_rsync 2>&1
653    \mv $@ >> out_rsync 2>&1
654    RET=$?
655
656    if [ ${RET} -gt 0 ] ; then
657        echo "IGCM_sys_Mv : error in mv."
658        cat out_rsync
659        IGCM_debug_Exit "IGCM_sys_Mv"
660    fi
661
662    IGCM_debug_PopStack "IGCM_sys_Mv"
663}
664
665#D-#==================================================
666#D-function IGCM_sys_Put_Dir
667#D-* Purpose: Copy a complete directory on $(ARCHIVE)
668#D-* Examples:
669#D-
670function IGCM_sys_Put_Dir {
671    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
672    if ( $DEBUG_sys ) ; then
673        echo "IGCM_sys_Put_Dir :" $@
674    fi
675    if [ $DRYRUN = 0 ]; then
676        if [ ! -d ${1} ] ; then
677            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
678            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
679            return
680        fi
681
682        typeset RET
683
684        # Only if we use rsync
685        #IGCM_sys_TestDirArchive $( dirname $2 )
686        #
687        #USUAL WAY
688        rcp -r $1 gaya:$2 > out_rsync 2>&1
689        RET=$?
690
691        if [ ${RET} -gt 0 ] ; then
692            echo "IGCM_sys_Put_Dir : error."
693            cat out_rsync
694            IGCM_debug_Exit "IGCM_sys_Put_Dir"
695        fi
696    else
697        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
698    fi
699    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
700}
701
702#D-#==================================================
703#D-function IGCM_sys_Get_Dir
704#D-* Purpose: Copy a complete directory from $(ARCHIVE)
705#D-* Examples:
706#D-
707function IGCM_sys_Get_Dir {
708    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
709    if ( $DEBUG_sys ) ; then
710        echo "IGCM_sys_Get_Dir :" $@
711    fi
712    if [ $DRYRUN = 0 ]; then
713        if [ ! -d ${1} ] ; then
714            echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
715            IGCM_debug_PopStack "IGCM_sys_Get_Dir"
716            return
717        fi
718
719        typeset RET
720
721        #USUAL WAY
722        rcp -rp gaya:$1 $2 > out_rsync 2>&1
723        RET=$?
724
725        if [ ${RET} -gt 0 ] ; then
726            echo "IGCM_sys_Get_Dir : error."
727            cat out_rsync
728            IGCM_debug_Exit "IGCM_sys_Get_Dir"
729        fi
730    else
731        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
732    fi
733    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
734}
735
736#D-#==================================================
737#D-function IGCM_sys_Put_Rest
738#D-* Purpose: Put computied restarts on $(ARCHIVE).
739#D-           File and target directory must exist.
740#D-* Examples:
741#D-
742function IGCM_sys_Put_Rest {
743    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
744    if ( $DEBUG_sys ) ; then
745        echo "IGCM_sys_Put_Rest :" $@
746    fi
747    if [ $DRYRUN = 0 ]; then
748        if [ ! -f ${1} ] ; then
749            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
750            IGCM_debug_Exit "IGCM_sys_Put_Rest"
751        fi
752
753        typeset RET
754        #
755        IGCM_sys_Chmod 444 ${1}
756        #
757        # Only if we use rsync
758        #IGCM_sys_MkdirArchive $( dirname $2 )
759        #
760        #USUAL WAY
761        mfput $1 $2 > out_rsync 2>&1
762        RET=$?
763
764#       #RSYNC WITH NETWORK RSH CALL
765#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
766#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
767
768#       #RSYNC WITH NFS USE
769#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
770#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
771       
772#       RET=$?
773#       IGCM_sys_Rsync_out $RET
774
775#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
776#       (( RET=RET+$? ))
777
778        if [ ${RET} -gt 0 ] ; then
779            echo "IGCM_sys_Put_Rest : error."
780            cat out_rsync
781            IGCM_debug_Exit "IGCM_sys_Put_Rest"
782        fi
783    else
784        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
785    fi
786    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
787}
788
789#D-#==================================================
790#D-function IGCM_sys_Put_Out
791#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
792#D-* Examples:
793#D-
794function IGCM_sys_Put_Out {
795    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
796    if ( $DEBUG_sys ) ; then
797        echo "IGCM_sys_Put_Out :" $@
798    fi
799    if [ $DRYRUN = 0 ]; then
800        if [ ! -f ${1} ] ; then
801            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
802            IGCM_debug_PopStack "IGCM_sys_Put_Out"
803            return 1
804        fi
805
806        typeset RET
807        #
808        IGCM_sys_Chmod 444 ${1}
809        #
810        # Only if we use rsync
811        #IGCM_sys_MkdirArchive $( dirname $2 )
812        #
813        #USUAL WAY
814        mfput $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 ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
819#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
820
821#       #RSYNC WITH NFS USE
822#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
823#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> 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_Put_Out : error."
833            cat out_rsync
834            IGCM_debug_Exit "IGCM_sys_Put_Out"
835        fi
836    else
837        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
838    fi
839    IGCM_debug_PopStack "IGCM_sys_Put_Out"
840    return 0
841}
842
843#D-#==================================================
844#D-function IGCM_sys_Get
845#D-* Purpose: Get a file from ${ARCHIVE}
846#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
847#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
848function IGCM_sys_Get {
849    IGCM_debug_PushStack "IGCM_sys_Get" $@
850
851    typeset DEST RET dm_liste ifile target
852
853    if ( $DEBUG_sys ) ; then
854        echo "IGCM_sys_Get :" $@
855    fi
856    if [ $DRYRUN -le 2 ]; then
857        if [ X${1} = X'/l' ] ; then
858            # test if the first file is present in the old computation :
859            eval set +A dm_liste \${${2}}
860        else
861            dm_liste=${1}
862        fi
863        eval DEST=\${${#}}
864
865        # test if the (first) file is present in the old computation :
866        IGCM_sys_TestFileArchive ${dm_liste[0]}
867        RET=$?
868        if [ ${RET} -gt 0 ] ; then
869            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
870            IGCM_debug_Exit "IGCM_sys_Get"
871            return
872        fi
873
874        # SD : dm_liste is not suited for computing job
875        #      because we change filename during transfert
876        #      dm_liste is better suited for post-treatment
877        #dm_liste=" "
878        #(( ifile=1 ))
879        #while [ $ifile -lt $# ] ; do
880        #    dm_liste=$( eval echo ${dm_liste} " "\${${ifile}} )
881        #    (( ifile = ifile + 1 ))
882        #done
883        #DEST=$( eval echo \${${#}} )
884
885        #USUAL WAY
886        mfget ${dm_liste[*]} ${DEST} > out_rsync 2>&1
887        #mfget $1 $2 > out_rsync 2>&1
888        RET=$?
889
890#       #RSYNC WITH NETWORK RSH CALL
891#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
892#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
893
894#       #RSYNC WITH NFS USE
895#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
896#       ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
897
898#       RET=$?
899#       IGCM_sys_Rsync_out $RET
900
901#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
902#       (( RET=RET+$? ))
903
904        if [ ${RET} -gt 0 ] ; then
905            echo "IGCM_sys_Get : copy error."
906            cat out_rsync
907            IGCM_debug_Exit "IGCM_sys_Get"
908        fi
909    else
910        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
911    fi
912    IGCM_debug_PopStack "IGCM_sys_Get"
913}
914
915############################################################## A REVOIR !!
916
917#D-#==================================================
918#D-function IGCM_sys_Rapatrie
919#D-* Purpose: Rapatrie
920#D-* Examples:
921#D-
922function IGCM_sys_Rapatrie {
923    IGCM_debug_PushStack "IGCM_sys_Rapatrie" $@
924    if ( $DEBUG_sys ) ; then
925        echo "IGCM_sys_Rapatrie :" $@
926    fi
927
928    typeset RET=0
929
930    IGCM_sys_Get ${R_STOCKAGE}/$2 $1 ;
931    let $(( RET=RET+$? ))
932    IGCM_sys_Cd $1 ;
933    let $(( RET=RET+$? ))
934    IGCM_sys_UnTar $2 ;
935    let $(( RET=RET+$? ))
936
937    if [ ${RET} -gt 0 ] ; then
938        echo "IGCM_sys_Rapatrie : erreur."
939        IGCM_debug_Exit "IGCM_sys_Rapatrie"
940    fi
941    IGCM_debug_PopStack "IGCM_sys_Rapatrie"
942}
943
944############################################################## A FINIR !!
945
946#D-#==================================================
947#D-function IGCM_sys_GetDate_FichWork
948#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
949#D-* Examples:
950#D-
951function IGCM_sys_GetDate_FichWork {
952    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
953    if ( $DEBUG_sys ) ; then
954        echo "IGCM_sys_GetDate_FichWork :" $@
955    fi
956    # donne la date filesys d'un fichier sur la machine work
957    IGCM_debug_PopStack "IGCM_sys_FichWork"
958}
959
960#D-#==================================================
961#D-function IGCM_sys_GetDate_FichArchive
962#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
963#D-* Examples:
964#D-
965function IGCM_sys_GetDate_FichArchive {
966    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
967    if ( $DEBUG_sys ) ; then
968        echo "IGCM_sys_GetDate_FichArchive :" $@
969    fi
970    IGCM_debug_PopStack "IGCM_sys_FichArchive"
971}
972
973##############################################################
974# REBUILD OPERATOR
975
976function IGCM_sys_rebuild {
977    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
978    if ( $DEBUG_sys ) ; then
979        echo "IGCM_sys_rebuild :" $@
980    fi
981    /home/rech/psl/rpsl035/SX/bin/rebuild -f -o $@
982    if [ $? -gt 0 ] ; then
983       echo "IGCM_sys_rebuild : erreur ${@}."
984       IGCM_debug_Exit "rebuild"
985    fi
986
987    IGCM_debug_PopStack "IGCM_sys_rebuild"
988}
989
990############################################################
991# Activate Running Environnment Variables
992
993function IGCM_sys_activ_variables {
994    IGCM_debug_PushStack "IGCM_sys_activ_variables"
995    if ( $DEBUG_sys ) ; then
996        echo "IGCM_sys_activ_variables "
997    fi
998
999# --------------------------------------------------------------------
1000#D- MPI specifications
1001# --------------------------------------------------------------------
1002
1003#D-- MPISUSPEND
1004    export MPISUSPEND=ON
1005#D-- MPIPROGINF
1006    export MPIPROGINF=ALL
1007
1008# --------------------------------------------------------------------
1009#D- Other specifications
1010# --------------------------------------------------------------------
1011
1012#D- max number of character/line in output job
1013    export F_SYSLEN=5000
1014#D- number of error that can be admitted on the NEC
1015    export F_ERRCNT=0
1016#D- global performance
1017    export F_PROGINF=DETAIL
1018#D- activate ftrace (with -ftrace)
1019    export F_FTRACE=YES
1020#D- communication information (with -ftrace)
1021    export MPICOMMINF=ALL
1022#D- I/O performance (FORTRAN I/O only not netCDF)
1023    export F_FILEINF=NO
1024# netCDF I/O performance
1025    export NC_FILEINF=NO   
1026
1027    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1028
1029}
1030
1031############################################################
1032# Desactivate Running Environnment Variables
1033
1034function IGCM_sys_desactiv_variables {
1035    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1036    if ( $DEBUG_sys ) ; then
1037        echo "IGCM_sys_desactiv_variables "
1038    fi
1039# --------------------------------------------------------------------
1040#D- MPI specifications
1041# --------------------------------------------------------------------
1042
1043#D-- MPIPROGINF
1044    export MPIPROGINF=NO
1045
1046# --------------------------------------------------------------------
1047#D- Other specifications
1048# --------------------------------------------------------------------
1049
1050#D- global performance
1051    export F_PROGINF=NO 
1052
1053    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1054 
1055}
1056
1057############################################################
1058# Build run file
1059
1060function IGCM_sys_build_run_file {
1061    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1062    if ( $DEBUG_sys ) ; then
1063        echo "IGCM_sys_build_run_file " $@
1064    fi
1065    (( NUM_PROC_ATM = BATCH_NUM_PROC_TOT - 1 ))
1066    (( NUM_PROC_OASIS = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1067    (( NUM_PROC_OCE = BATCH_NUM_PROC_TOT - NUM_PROC_ATM ))
1068   
1069    if [ $1 = MPI2 ]; then
1070        cat <<EOF > run_file
1071-p 1 -np 1 -e ./oasis
1072EOF
1073        (( NUM_PROCESS = BATCH_NUM_PROC_TOT + 1 ))
1074        config_UserChoices_JobRunOptions='"-max_np ${NUM_PROCESS} -f"'
1075
1076    elif [ $1 = MPI1 ]; then
1077        cat <<EOF > run_file
1078-p $NUM_PROC_OASIS -e ./oasis
1079-p $NUM_PROC_ATM -e ./lmdz.x
1080-p $NUM_PROC_OCE -e ./opa.xx
1081EOF
1082 
1083    fi
1084
1085    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1086 
1087}
Note: See TracBrowser for help on using the repository browser.