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

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