source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_zahir.ksh @ 40

Last change on this file since 40 was 37, checked in by sdipsl, 16 years ago

ACa/SD : Function IGCM_sys_RshArchive will be use to manage NEMO restart in the parallel case

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