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

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