source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh @ 158

Last change on this file since 158 was 156, checked in by sdipsl, 15 years ago
  • Define BIG_DIR : where files will be store waiting for patch or rebuild if rebuildFromArchive=false

-- > typically somewhere on the scratch or on the work

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