source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_vargas.ksh @ 157

Last change on this file since 157 was 156, checked in by sdipsl, 15 years ago
  • Define BIG_DIR : where files will be store waiting for patch or rebuild if rebuildFromArchive=false

-- > typically somewhere on the scratch or on the work

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