source: tags/libIGCM_v1_1/libIGCM_sys/libIGCM_sys_brodie.ksh @ 1137

Last change on this file since 1137 was 17, checked in by mmaipsl, 16 years ago

MM: Correct platine lib.

Update trunk from tag libIGCM_v1.

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