source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh @ 265

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