source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex8.ksh @ 228

Last change on this file since 228 was 228, checked in by mmaipsl, 14 years ago

Supress buggy space after HOST and LOGIN variables.
Add an optionnal argument to all IGCM_sys_Put_Out functions :
if any 3thrd argument is there, file won't be protected. If
there is no argument (default in libIGCM), file will be set read-only.

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