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

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