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

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