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

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

MM: loop over 10 tries for ccc_msub to cesium call inside QsubPost? function.

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