source: tags/libIGCM_v1_3/libIGCM_sys/libIGCM_sys_mercurex9.ksh

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