source: tags/libIGCM_v1_4/libIGCM_sys/libIGCM_sys_mercure.ksh

Last change on this file was 173, checked in by mafoipsl, 15 years ago

Add DRYRUN capability in Sys_Mv for all systems supported.

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