source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_platine.ksh @ 437

Last change on this file since 437 was 437, checked in by sdipsl, 13 years ago

Send mail notification when computing job stops
It could be that we send a notification if a post-processing job stops in PROD mode ---> need some refactoring and caution...

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Revision Author Date
File size: 40.0 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip
5# Contact: Martial.Mancip__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 Platine
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 MASTER=platine
71
72#D-
73#D-#==================================================
74#D-Program used in libIGCM
75#D-#==================================================
76
77# rsync with path
78typeset -r RSYNC=/usr/bin/rsync
79# RSYNC_opt args to rsync
80typeset -r RSYNC_opt="-va"
81# ie storage filesystem
82typeset -r RHOST=platine
83
84#====================================================
85# Set environment tools (ferret, nco, cdo)
86#====================================================
87. /home/cont003/p86ipsl/.atlas_env_platine_ksh
88
89#====================================================
90# Specific for ocean additionnal diagnostic
91export FER_GO="$FER_GO /home/cont003/p86denv/IGCM_POST_UTIL/JNL /home/cont003/p86denv/GRAF /home/cont003/p86denv/GRAF/GO"
92export FER_PALETTE="$FER_PALETTE /home/cont003/p86denv/GRAF/PALET"
93
94#====================================================
95# Host specific DIRECTORIES
96#====================================================
97
98#====================================================
99#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
100typeset -r R_EXE="${MODIPSL}/bin"
101
102#====================================================
103#- SUBMIT_DIR : submission dir
104typeset SUBMIT_DIR=${SUBMIT_DIR:=${PWD}}
105
106#====================================================
107#- ARCHIVE
108typeset -r ARCHIVE=${DMFDIR}
109
110#====================================================
111#- libIGCM_POST
112typeset -r libIGCM_POST=${libIGCM}
113
114#====================================================
115#- IN
116typeset -r R_IN=${R_IN:=/dmnfs/cont003/p86ipsl/IGCM}
117typeset -r R_IN_ECMWF=${R_IN:=/dmnfs/cont003/p24data}
118
119#====================================================
120#- OUT
121typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
122
123#====================================================
124#- OUT_SCR (ONLY FOR double copy an scratch)
125typeset -r R_OUT_SCR=${SCRATCHDIR}/IGCM_OUT
126
127#====================================================
128#- OUT_POST
129typeset -r R_OUT_POST=${SCRATCHDIR}/IGCM_OUT
130
131#====================================================
132#- RUN_DIR_PATH : Temporary working directory (=> TMP)
133typeset RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}}
134if [ $LSB_QUEUE == post ] ; then
135    typeset -r RUN_DIR_PATH=${SCRATCHDIR}/TMPDIR_IGCM/tmp$$
136    if [ ! -d ${RUN_DIR_PATH} ]; then 
137        \mkdir -p ${RUN_DIR_PATH}
138        if [ $? -gt 0 ] ; then
139            echo "Error in creation of "${RUN_DIR_PATH}
140        fi
141    fi
142fi
143
144#====================================================
145#- BIG_DIR : BIG_DIR to store files waiting for rebuild
146typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD}
147
148#====================================================
149#- HOST_MPIRUN_COMMAND
150typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time srun"}
151
152#====================================================
153#- Max number of arguments passed to nco operator or demigration command
154UNIX_MAX_LIMIT=360
155
156#D-#==================================================
157#D-function IGCM_sys_RshMaster
158#D-* Purpose: Just a fake command to wrapp
159#D-           IGCM_card call in post-treatment
160#D-           Ulam do not see brodie filesystem
161#D-           Cesium do not see all mercure filesystem
162#D-           That's why we need this hack.
163#D-* Examples:
164#D-
165function IGCM_sys_RshMaster {
166    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
167    /bin/ksh <<-EOF
168    export libIGCM=${libIGCM}
169    export DEBUG_debug=${DEBUG_debug}
170    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
171    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
172    ${@}
173EOF
174    if [ $? -gt 0 ] ; then
175        echo "IGCM_sys_RshMaster : erreur."
176        IGCM_debug_Exit "IGCM_sys_RshMaster"
177    fi
178    IGCM_debug_PopStack "IGCM_sys_RshMaster"
179}
180
181#D-#==================================================
182#D-function IGCM_sys_RshArchive
183#D-* Purpose: Archive rsh command
184#D-* Examples:
185#D-
186function IGCM_sys_RshArchive {
187    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
188    /bin/ksh <<-EOF
189    ${@}
190EOF
191    if [ $? -gt 0 ] ; then
192        echo "IGCM_sys_RshArchive : erreur."
193        IGCM_debug_Exit "IGCM_sys_RshArchive"
194    fi
195    IGCM_debug_PopStack "IGCM_sys_RshArchive"
196}
197
198#D-#==================================================
199#D-function IGCM_sys_RshPost
200#D-* Purpose: Post-process rsh command
201#D-* Examples:
202#D-
203function IGCM_sys_RshPost {
204    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
205    if ( $DEBUG_sys ) ; then
206        echo "IGCM_sys_RshPost :" $@
207    fi
208    /bin/ksh ${@}
209    if [ $? -gt 0 ] ; then
210        echo "IGCM_sys_RshPost : erreur."
211        IGCM_debug_Exit "IGCM_sys_RshPost"
212    fi
213    IGCM_debug_PopStack "IGCM_sys_RshPost"
214}
215
216#D-#==================================================
217#D-function IGCM_sys_SendMail
218#D-* Purpose: Send mail when simulation is over
219#D-* Examples:
220#D-
221function IGCM_sys_SendMail {
222    IGCM_debug_PushStack "IGCM_sys_SendMailPost" $@
223    if ( $DEBUG_sys ) ; then
224       echo "IGCM_sys_SendMail :" $@
225    fi
226
227    if ( ${ExitFlag} ) ; then
228        status=FAILED
229        cat  << END_MAIL > job_end.mail
230Dear ${LOGIN},
231
232  Simulation ${config_UserChoices_JobName} failed on supercomputer `hostname`.
233  Job started : ${PeriodDateBegin}
234  Job ended   : ${PeriodDateEnd}
235  Output files are available in ${R_SAVE}
236  Script files, Script Outputs and Debug files are available in ${SUBMIT_DIR}
237END_MAIL
238    else
239        status=COMPLETED
240        cat  << END_MAIL > job_end.mail
241Dear ${LOGIN},
242
243  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
244  Job started : ${DateBegin}
245  Job ended   : ${DateEnd}
246  Output files are available in ${R_SAVE}
247  Script files and Script Outputs are available in ${SUBMIT_DIR}
248END_MAIL
249    fi
250
251    if [ ! -z ${config_UserChoices_MailName} ] ; then
252        mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail
253    elif [ -f ~/.forward ] ; then
254        mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
255    fi
256
257    if [ $? -gt 0 ] ; then
258        echo "IGCM_sys_SendMail : erreur."
259        IGCM_debug_Exit "IGCM_sys_SendMail"
260    fi
261    IGCM_debug_PopStack "IGCM_sys_SendMail"
262}
263
264#D-#==================================================
265#D-function IGCM_sys_Mkdir
266#D-* Purpose: Master locale mkdir command
267#D-* Examples:
268#D-
269function IGCM_sys_Mkdir {
270    IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
271    if ( $DEBUG_sys ) ; then
272        echo "IGCM_sys_Mkdir :" $@
273    fi
274    if [ ! -d ${1} ]; then
275        \mkdir -p $1
276        if [ $? -gt 0 ] ; then
277            echo "IGCM_sys_Mkdir : erreur."
278            IGCM_debug_Exit "IGCM_sys_Mkdir"
279        fi
280    fi
281    # vérification :
282    if [ ! -d ${1} ] ; then
283        echo "IGCM_sys_Mkdir : erreur."
284        IGCM_debug_Exit "IGCM_sys_Mkdir"
285    fi
286    IGCM_debug_PopStack "IGCM_sys_Mkdir"
287}
288
289#D-#==================================================
290#D-function IGCM_sys_MkdirArchive
291#D-* Purpose: Mkdir on Archive
292#D-* Examples:
293#D-
294function IGCM_sys_MkdirArchive {
295    IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
296    if ( $DEBUG_sys ) ; then
297        echo "IGCM_sys_MkdirArchive :" $@
298    fi
299    #- creation de repertoire sur le serveur fichier
300    if [ ! -d ${1} ]; then 
301        \mkdir -p $1
302        if [ $? -gt 0 ] ; then
303            echo "IGCM_sys_MkdirArchive : erreur."
304            IGCM_debug_Exit "IGCM_sys_MkdirArchive"
305        fi
306    fi
307    IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
308}
309
310#D-#==================================================
311#D-function IGCM_sys_MkdirWork
312#D-* Purpose: Mkdir on Work
313#D-* Examples:
314#D-
315function IGCM_sys_MkdirWork {
316    IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
317    if ( $DEBUG_sys ) ; then
318        echo "IGCM_sys_MkdirWork :" $@
319    fi
320    #- creation de repertoire sur le serveur fichier
321    if [ ! -d ${1} ]; then 
322        \mkdir -p $1
323        if [ $? -gt 0 ] ; then
324            echo "IGCM_sys_MkdirWork : erreur."
325            IGCM_debug_Exit "IGCM_sys_MkdirWork"
326        fi
327    fi
328    IGCM_debug_PopStack "IGCM_sys_MkdirWork"
329}
330
331#D-#==================================================
332#D-function IGCM_sys_Cd
333#D-* Purpose: master cd command
334#D-* Examples:
335#D-
336function IGCM_sys_Cd {
337    IGCM_debug_PushStack "IGCM_sys_Cd" $@
338    if ( $DEBUG_sys ) ; then
339        echo "IGCM_sys_Cd :" $@
340    fi
341    \cd $1
342    if [ $? -gt 0 ] ; then
343        echo "IGCM_sys_Cd : erreur."
344        IGCM_debug_Exit "IGCM_sys_Cd"
345    fi
346    IGCM_debug_PopStack "IGCM_sys_Cd"
347}
348
349#D-#==================================================
350#D-function IGCM_sys_Chmod
351#D-* Purpose: Chmod
352#D-* Examples:
353#D-
354function IGCM_sys_Chmod {
355    IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
356    if ( $DEBUG_sys ) ; then
357        echo "IGCM_sys_Chmod :" $@
358    fi
359    if [ $DRYRUN -le 1 ]; then
360        \chmod $@
361        if [ $? -gt 0 ] ; then
362            echo "IGCM_sys_Chmod : erreur."
363            IGCM_debug_Exit "IGCM_sys_Chmod"
364        fi
365    else
366        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
367    fi
368    IGCM_debug_PopStack "IGCM_sys_Chmod"
369}
370
371#D-#==================================================
372#D-function IGCM_sys_FileSize
373#D-* Purpose: Filesize
374#D-* Examples:
375#D-
376function IGCM_sys_FileSize {
377    IGCM_debug_PushStack "IGCM_sys_FileSize" $@
378
379    typeset sizeF
380    set +A sizeF -- $( ls -la ${1} )
381    if [ $? -gt 0 ] ; then
382        IGCM_debug_Exit "IGCM_sys_FileSize"
383    fi
384    eval ${2}=${sizeF[4]}
385
386    IGCM_debug_PopStack "IGCM_sys_FileSize"
387}
388
389#D-#==================================================
390#D-function IGCM_sys_TestDir
391#D-* Purpose: Test Directory that must exists
392#D-* Examples:
393#D-
394function IGCM_sys_TestDir {
395    IGCM_debug_PushStack "IGCM_sys_TestDir" $@
396    if ( $DEBUG_sys ) ; then
397        echo "IGCM_sys_TestDir :" $@
398    fi
399    typeset ExistFlag
400    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
401    IGCM_debug_PopStack "IGCM_sys_TestDir"
402
403    return ${ExistFlag}
404}
405
406#D-#==================================================
407#D-function IGCM_sys_TestDirArchive
408#D-* Purpose: Test Directory that must exists on Archive
409#D-* Examples:
410#D-
411function IGCM_sys_TestDirArchive {
412    IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
413    if ( $DEBUG_sys ) ; then
414        echo "IGCM_sys_TestDirArchive :" $@
415    fi
416    typeset ExistFlag
417    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
418    IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
419
420    return ${ExistFlag}
421}
422
423#D-#==================================================
424#D-function IGCM_sys_TestFileArchive
425#D-* Purpose: Test file that must NOT EXISTS on Archive
426#D-* Examples:
427#D-
428function IGCM_sys_TestFileArchive {
429    IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
430    if ( $DEBUG_sys ) ; then
431        echo "IGCM_sys_TestFileArchive :" $@
432    fi
433    typeset ExistFlag
434    ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
435    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
436
437    return ${ExistFlag}
438}
439
440#D-#==================================================
441#D-function IGCM_sys_CountFileArchive
442#D-* Purpose: Count files on Archive filesystem
443#D-* Examples:
444#D-
445function IGCM_sys_CountFileArchive {
446    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
447    ls ${@} 2>/dev/null | wc -l
448    if [ $? -gt 0 ] ; then
449        echo "IGCM_sys_CountFileArchive : erreur."
450    fi
451    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
452}
453
454#D-#==================================================
455#D-function IGCM_sys_Tree
456#D-* Purpose: Tree directories with files on ${ARCHIVE}
457#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
458#D-
459function IGCM_sys_Tree {
460    IGCM_debug_PushStack "IGCM_sys_Tree" $@
461    if ( $DEBUG_sys ) ; then
462        echo "IGCM_sys_Tree :" $@
463    fi
464
465    \tree -f $@
466
467    IGCM_debug_PopStack "IGCM_sys_Tree"
468}
469
470#D-#==================================================
471#D-function IGCM_sys_Tar
472#D-* Purpose: master un-tar command
473#D-* Examples:
474#D-
475function IGCM_sys_Tar {
476    IGCM_debug_PushStack "IGCM_sys_Tar" $@
477    if ( $DEBUG_sys ) ; then
478        echo "IGCM_sys_Tar :" $@
479    fi
480    \tar cvf $@
481    if [ $? -gt 0 ] ; then
482        echo "IGCM_sys_Tar : erreur."
483        IGCM_debug_Exit "IGCM_sys_Tar"
484    fi
485    \tar tvf $1
486
487    IGCM_debug_PopStack "IGCM_sys_Tar"
488}
489
490#D-#==================================================
491#D-function IGCM_sys_UnTar
492#D-* Purpose: master un-tar command
493#D-* Examples:
494#D-
495function IGCM_sys_UnTar {
496    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
497    if ( $DEBUG_sys ) ; then
498        echo "IGCM_sys_UnTar :" $@
499    fi
500    \tar xvf $1
501    if [ $? -gt 0 ] ; then
502        echo "IGCM_sys_UnTar : erreur."
503        IGCM_debug_Exit "IGCM_sys_UnTar"
504    fi
505    IGCM_debug_PopStack "IGCM_sys_UnTar"
506}
507
508#D-#==================================================
509#D-function IGCM_sys_Qsub
510#D-* Purpose: Qsub new job
511#D-* Examples:
512#D-
513function IGCM_sys_Qsub {
514    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
515    if ( $DEBUG_sys ) ; then
516        echo "IGCM_sys_Qsub :" $@
517    fi
518    bsub -o ${Script_Output} -J ${config_UserChoices_JobName}.${CumulPeriod} < $1
519    if [ $? -gt 0 ] ; then
520        echo "IGCM_sys_Qsub : erreur " $@
521        IGCM_debug_Exit "IGCM_sys_Qsub"
522    fi
523    IGCM_debug_PopStack "IGCM_sys_Qsub"
524}
525
526#D-#==================================================
527#D-function IGCM_sys_QsubPost
528#D-* Purpose: Qsub new job on scalaire
529#D-* Examples:
530#D-
531function IGCM_sys_QsubPost {
532    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
533    if ( $DEBUG_sys ) ; then
534        echo "IGCM_sys_QsubPost :" $@
535    fi
536    bsub -o ${POST_DIR}/${Script_Post_Output}.out < ${libIGCM_POST}/$1.job
537    if [ $? -gt 0 ] ; then
538        echo "IGCM_sys_QsubPost : erreur " $@
539        IGCM_debug_Exit "IGCM_sys_QsubPost"
540    fi
541    IGCM_debug_PopStack "IGCM_sys_QsubPost"
542}
543
544#D-*************************
545#D- File transfer functions
546#D-*************************
547#D-
548
549#D-#==================================================
550#D-function IGCM_sys_Rsync_out
551#D-* Purpose: treat return val of rsync
552#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
553#D-  Error values and explanations can depend on your system version.
554function IGCM_sys_Rsync_out {
555    RET=$1
556    if [ ! $RET ] ; then
557        echo "rsync error !"
558    fi
559
560    if [ $MYLANG = "fr" ]; then
561        case $RET in
562            0)  return ;;
563            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
564                echo "Erreur de syntaxe ou d'utilisation."
565                return;;
566            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
567                echo "Incompatibilité de protocole."
568                return;;
569            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
570                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
571                echo "répertoires"
572                return;;
573            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
574                echo "Action demandée non supportée : une tentative de manipulation de"
575                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
576                echo "été faite ; ou une option qui est supportée par le  client  mais"
577                echo "pas par le serveur a été spécifiée."
578                return;;
579            10) echo "Erreur de rsync ; RERR_SOCKETIO"
580                echo "Erreur dans le socket d'entrée sortie"
581                return;;
582            11) echo "Erreur de rsync ; RERR_FILEIO"
583                echo "Erreur d'entrée sortie fichier"
584                return;;
585            12) echo "Erreur de rsync ; RERR_STREAMIO"
586                echo "Erreur dans flux de donnée du protocole rsync"
587                return;;
588            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
589                echo "Erreur avec les diagnostics du programme"
590                return;;
591            14) echo "Erreur de rsync ; RERR_IPC"
592                echo "Erreur dans le code IPC"
593                return;;
594            20) echo "Erreur de rsync ; RERR_SIGNAL"
595                echo "SIGUSR1 ou SIGINT reçu"
596                return;;
597            21) echo "Erreur de rsync ; RERR_WAITCHILD"
598                echo "Une erreur retournée par waitpid()"
599                return;;
600            22) echo "Erreur de rsync ; RERR_MALLOC"
601                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
602                return;;
603            23) echo ""
604                echo "Erreur fichier inexistant"
605                return;;
606            30) echo "Erreur de rsync ; RERR_TIMEOUT"
607                echo "Temps d'attente écoulé dans l'envoi/réception de données"
608                return;;
609            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
610                return;;
611        esac
612    elif [ $MYLANG = "en" ] ; then
613        case $RET in
614            0)  return;;               
615            1)  echo "rsync error : Syntax or usage error "
616                return;;
617            2)  echo "rsync error : Protocol incompatibility "
618                return;;
619            3)  echo "rsync error : Errors selecting input/output files, dirs"
620                return;;
621            4)  echo "rsync error : Requested action not supported: an attempt"
622                echo "was made to manipulate 64-bit files on a platform that cannot support"
623                echo "them; or an option was specified that is supported by the client and"
624                echo "not by the server."
625                return;;
626            5)  echo "rsync error : Error starting client-server protocol"
627                return;;
628            10) echo "rsync error : Error in socket I/O "
629                return;;
630            11) echo "rsync error : Error in file I/O "
631                return;;
632            12) echo "rsync error : Error in rsync protocol data stream "
633                return;;
634            13) echo "rsync error : Errors with program diagnostics "
635                return;;
636            14) echo "rsync error : Error in IPC code "
637                return;;
638            20) echo "rsync error : Received SIGUSR1 or SIGINT "
639                return;;
640            21) echo "rsync error : Some error returned by waitpid() "
641                return;;
642            22) echo "rsync error : Error allocating core memory buffers "
643                return;;
644            23) echo "rsync error : Partial transfer due to error"
645                return;;
646            24) echo "rsync error : Partial transfer due to vanished source files"
647                return;;
648            30) echo "rsync error : Timeout in data send/receive "
649                return;;
650            *)  echo "rsync error : return code of rsync unknown :" $RET
651                return;;
652        esac
653    else
654        echo "unknown language $MYLANG."
655        return
656    fi
657}
658   
659#D-#==================================================
660#D-function IGCM_sys_Cp
661#D-* Purpose: generic cp
662#D-* Examples:
663#D-
664function IGCM_sys_Cp {
665    IGCM_debug_PushStack "IGCM_sys_Cp" $@
666    if ( $DEBUG_sys ) ; then
667        echo "IGCM_sys_Cp :" $@
668    fi
669
670    typeset RET
671
672    echo cp $@ > out_rsync 2>&1
673    \cp $@ >> out_rsync 2>&1
674    RET=$?
675
676    if [ ${RET} -gt 0 ] ; then
677        echo "IGCM_sys_Cp : error."
678        cat out_rsync
679        IGCM_debug_Exit "IGCM_sys_Cp"
680     else
681         \rm out_rsync
682    fi
683    IGCM_debug_PopStack "IGCM_sys_Cp"
684}
685
686#D-#==================================================
687#D-function IGCM_sys_Rm
688#D-* Purpose: generic rm
689#D-* Examples:
690#D-
691function IGCM_sys_Rm {
692    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
693    if ( $DEBUG_sys ) ; then
694        echo "IGCM_sys_Rm :" $@
695    fi
696
697    typeset RET
698
699    echo rm $@ > out_rsync 2>&1
700    \rm $@ >> out_rsync 2>&1
701    RET=$?
702
703    if [ ${RET} -gt 0 ] ; then
704        echo "IGCM_sys_Rm : error."
705        cat out_rsync
706        IGCM_debug_Exit "IGCM_sys_Rm"
707    else
708        \rm out_rsync
709    fi
710    IGCM_debug_PopStack "IGCM_sys_Rm"
711}
712
713#D-#==================================================
714#D-function IGCM_sys_RmRunDir
715#D-* Purpose: rm tmpdir (dummy function most of the time batch
716#D-                      scheduler will do the job)
717#D-* Examples:
718#D-
719function IGCM_sys_RmRunDir {
720    IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
721    if ( $DEBUG_sys ) ; then
722        echo "IGCM_sys_RmRunDir :" $@
723        echo "Dummy call, let the scheduler do that."
724    fi
725    IGCM_debug_PopStack "IGCM_sys_RmRunDir"
726}
727
728#D-#==================================================
729#D-function IGCM_sys_Mv
730#D-* Purpose: generic move
731#D-* Examples:
732#D-
733function IGCM_sys_Mv {
734    IGCM_debug_PushStack "IGCM_sys_Mv" $@
735    if ( $DEBUG_sys ) ; then
736        echo "IGCM_sys_Mv :" $@
737    fi
738
739    if [ $DRYRUN = 0 ]; then
740
741        typeset RET
742           
743        echo mv $@ > out_rsync 2>&1
744        \mv $@ >> out_rsync 2>&1
745        RET=$?
746   
747        if [ ${RET} -gt 0 ] ; then
748            echo "IGCM_sys_Mv : error in mv."
749            cat out_rsync
750            IGCM_debug_Exit "IGCM_sys_Mv"
751        else
752            \rm out_rsync
753        fi
754    else
755        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
756    fi
757
758    IGCM_debug_PopStack "IGCM_sys_Mv"
759}
760
761#D-#==================================================
762#D-function IGCM_sys_Put_Dir
763#D-* Purpose: Copy a complete directory on $(ARCHIVE)
764#D-* Examples:
765#D-
766function IGCM_sys_Put_Dir {
767    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
768    if ( $DEBUG_sys ) ; then
769        echo "IGCM_sys_Put_Dir :" $@
770    fi
771    if [ $DRYRUN = 0 ]; then
772        if [ ! -d ${1} ] ; then
773            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
774            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
775            return
776        fi
777
778        typeset RET
779
780        # Only if we use rsync
781        #IGCM_sys_TestDirArchive $( dirname $2 )
782        #
783        #USUAL WAY
784        \cp -r $1 $2 > out_rsync 2>&1
785        RET=$?
786
787        if [ ${RET} -gt 0 ] ; then
788            echo "IGCM_sys_Put_Dir : error."
789            cat out_rsync
790            IGCM_debug_Exit "IGCM_sys_Put_Dir"
791        else
792            \rm out_rsync
793        fi
794    else
795        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
796    fi
797    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
798}
799
800#D-#==================================================
801#D-function IGCM_sys_Get_Dir
802#D-* Purpose: Copy a complete directory from $(ARCHIVE)
803#D-* Examples:
804#D-
805function IGCM_sys_Get_Dir {
806    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
807    if ( $DEBUG_sys ) ; then
808        echo "IGCM_sys_Get_Dir :" $@
809    fi
810    if [ $DRYRUN = 0 ]; then
811#       if [ ! -d ${1} ] ; then
812#           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
813#           IGCM_debug_PopStack "IGCM_sys_Get_Dir"
814#           return
815#       fi
816
817        typeset RET
818
819        # Only if we use rsync
820        #IGCM_sys_TestDirArchive $( dirname $2 )
821        #
822        #USUAL WAY
823        \cp -r $1 $2 > out_rsync 2>&1
824        RET=$?
825
826        if [ ${RET} -gt 0 ] ; then
827            echo "IGCM_sys_Get_Dir : error."
828            cat out_rsync
829            IGCM_debug_Exit "IGCM_sys_Get_Dir"
830        else
831            \rm out_rsync
832        fi
833    else
834        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
835    fi
836    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
837}
838
839#D-#==================================================
840#D-function IGCM_sys_Get_Master
841#D-* Purpose: Copy a complete directory from MASTER filesystem
842#D-* Examples:
843#D-
844function IGCM_sys_Get_Master {
845    IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
846    if ( $DEBUG_sys ) ; then
847        echo "IGCM_sys_Get_Master :" $@
848    fi
849    if [ $DRYRUN = 0 ]; then
850        if [ ! -d ${1} ] ; then
851            echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
852            IGCM_debug_PopStack "IGCM_sys_Get_Master"
853            return
854        fi
855
856        typeset RET
857        sleep 60
858
859        #USUAL WAY
860        \cp -r $1 $2 > out_rsync 2>&1
861        RET=$?
862
863        if [ ${RET} -gt 0 ] ; then
864            echo "IGCM_sys_Get_Master : error."
865            cat out_rsync
866            IGCM_debug_Exit "IGCM_sys_Get_Master"
867        fi
868    else
869        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
870    fi
871    IGCM_debug_PopStack "IGCM_sys_Get_Master"
872}
873
874#D-#==================================================
875#D-function IGCM_sys_Put_Rest
876#D-* Purpose: Put computied restarts on $(ARCHIVE).
877#D-           File and target directory must exist.
878#D-* Examples:
879#D-
880function IGCM_sys_Put_Rest {
881    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
882    if ( $DEBUG_sys ) ; then
883        echo "IGCM_sys_Put_Rest :" $@
884    fi
885    if [ $DRYRUN = 0 ]; then
886        if [ ! -f ${1} ] ; then
887            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
888            IGCM_debug_Exit "IGCM_sys_Put_Rest"
889        fi
890
891        typeset RET
892        #
893        if [ X${JobType} = XRUN ] ; then
894            IGCM_sys_Chmod 444 ${1}
895        fi
896        #
897        IGCM_sys_TestDirArchive $( dirname $2 )
898        #
899        # USUAL WAY
900        putfer $1 $2 > out_rsync 2>&1
901        RET=$?
902
903#       #RSYNC WITH NETWORK RSH CALL
904#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
905#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
906
907#       #RSYNC WITH NFS USE
908#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
909#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
910
911#       RET=$?
912#       IGCM_sys_Rsync_out $RET
913
914#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
915#       (( RET=RET+$? ))
916
917        if [ ${RET} -gt 0 ] ; then
918            echo "IGCM_sys_Put_Rest : error."
919            cat out_rsync
920            IGCM_debug_Exit "IGCM_sys_Put_Rest"
921        else
922            \rm out_rsync
923        fi
924    else
925        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
926    fi
927    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
928}
929
930#D-#==================================================
931#D-function IGCM_sys_Put_Out
932#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
933#D-* Examples:
934#D-
935function IGCM_sys_Put_Out {
936    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
937    if ( $DEBUG_sys ) ; then
938        echo "IGCM_sys_Put_Out :" $@
939    fi
940    if [ $DRYRUN = 0 ]; then
941        if [ ! -f ${1} ] ; then
942            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
943            IGCM_debug_PopStack "IGCM_sys_Put_Out"
944            return 1
945        fi
946        #
947        IGCM_sys_MkdirArchive $( dirname $2 )
948        #
949        typeset RET
950        #
951        if [ X${JobType} = XRUN ] ; then
952            if [ X${3} = X ] ; then
953                IGCM_sys_Chmod 444 ${1}
954            fi
955        fi
956        #
957        # USUAL WAY
958        putfer $1 $2 > out_rsync 2>&1
959        RET=$?
960
961#       #RSYNC WITH NETWORK RSH CALL
962#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
963#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
964
965#       #RSYNC WITH NFS USE
966#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
967#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
968
969#       RET=$?
970#       IGCM_sys_Rsync_out $RET
971
972#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
973#       (( RET=RET+$? ))
974
975        if [ ${RET} -gt 0 ] ; then
976            echo "IGCM_sys_Put_Out : error."
977            cat out_rsync
978            IGCM_debug_Exit "IGCM_sys_Put_Out"
979        else
980            \rm out_rsync
981        fi
982    else
983        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
984    fi
985    IGCM_debug_PopStack "IGCM_sys_Put_Out"
986    return 0
987}
988
989#D-#==================================================
990#D-function IGCM_sys_Get
991#D-* Purpose: Get a file from ${ARCHIVE}
992#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
993#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
994function IGCM_sys_Get {
995    IGCM_debug_PushStack "IGCM_sys_Get" $@
996
997    typeset DEST RET dm_liste ifile target file_work
998
999    if ( $DEBUG_sys ) ; then
1000        echo "IGCM_sys_Get :" $@
1001    fi
1002    if [ $DRYRUN -le 2 ]; then
1003        if [ X${1} = X'/l' ] ; then
1004            # test if the first file is present in the old computation :
1005            eval set +A dm_liste \${${2}}
1006        else
1007            eval set +A dm_liste ${1}
1008        fi
1009        eval DEST=\${${#}}
1010
1011        #=====================================================
1012        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1013        #=====================================================
1014
1015        # Is it an R_OUT file (not R_IN) ?
1016        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1017        #if [ $? -eq 0 ] ; then
1018        #    # Yes  ? then we try to get it in SCRATCHDIR
1019        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
1020        #    if [ -f ${file_work[0]} ] ; then
1021        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
1022        #       IGCM_debug_PopStack "IGCM_sys_Get"
1023        #       return
1024        #    fi
1025        #fi
1026
1027        # test if the (first) file is present in the old computation :
1028        IGCM_sys_TestFileArchive ${dm_liste[0]}
1029        RET=$?
1030        if [ ${RET} -gt 0 ] ; then
1031            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1032            IGCM_debug_Exit "IGCM_sys_Get"
1033            #IGCM_debug_PopStack "IGCM_sys_Get"
1034            #return
1035        fi
1036
1037#       dmget ${dm_liste[*]} > out_rsync 2>&1
1038#       RET=$?
1039#       if [ ${RET} -gt 0 ] ; then
1040#           echo "IGCM_sys_Get : demigration error."
1041#           cat out_rsync
1042#           IGCM_debug_Exit "IGCM_sys_Get"
1043#           IGCM_debug_PopStack "IGCM_sys_Get"
1044#           return
1045#       fi
1046
1047        #USUAL WAY
1048        (( RET=0 ))
1049        if [ X${1} = X'/l' ] ; then
1050            (( RET=0 ))
1051            for target in ${dm_liste[*]} ; do
1052                local_file=$( basename ${target} )
1053                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1054                (( RET = RET + $? ))
1055            done
1056        else
1057            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1058            RET=$?
1059        fi
1060
1061#       #RSYNC WITH NETWORK RSH CALL
1062#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1063#       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1064
1065#       #RSYNC WITH NFS USE
1066#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1067#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1068
1069#       RET=$?
1070#       IGCM_sys_Rsync_out $RET
1071
1072#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1073#       (( RET=RET+$? ))
1074
1075        if [ ${RET} -gt 0 ] ; then
1076            echo "IGCM_sys_Get : copy error."
1077            cat out_rsync
1078            IGCM_debug_Exit "IGCM_sys_Get"
1079        else
1080            \rm out_rsync
1081        fi
1082    else
1083        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1084    fi
1085    IGCM_debug_PopStack "IGCM_sys_Get"
1086}
1087
1088#D-#==================================================
1089#D-function IGCM_sys_Dods_Rm
1090#D-* Purpose: DO NOTHING ! Put $(ARCHIVE) files on DODS internet protocole.
1091#D-* Examples:
1092#D-
1093function IGCM_sys_Dods_Rm {
1094    if ( $DEBUG_sys ) ; then
1095        echo "IGCM_sys_Dods_Rm :" $@
1096    fi
1097    typeset RET
1098    RET=0
1099    if [ $DRYRUN = 0 ]; then
1100        if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
1101            echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
1102            echo "Nothing has been done."
1103            return
1104        fi
1105        dods_rm public/${LOGIN}/${R_DODS}/${1} #> out_dods_rm 2>&1
1106        RET=$?
1107       
1108#       if [ ${RET} -gt 0 ] ; then
1109#           echo "IGCM_sys_Put_Dods : error."
1110#           cat out_dods_rm
1111#           IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1112#       else
1113#           rm out_dods_rm
1114#       fi
1115
1116    else
1117        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1118    fi
1119    return $RET
1120}
1121
1122
1123#D-#==================================================
1124#D-function IGCM_sys_Dods_Cp
1125#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1126#D-* Examples:
1127#D-
1128function IGCM_sys_Dods_Cp {
1129    if ( $DEBUG_sys ) ; then
1130        echo "IGCM_sys_Dods_Cp :" $@
1131    fi
1132    typeset RET
1133    RET=0
1134    if [ $DRYRUN = 0 ]; then
1135        if [ ! -d ${R_SAVE}/${1} ] ; then
1136            echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1137            echo "Nothing has been done."
1138            return
1139        fi
1140        #
1141        dods_cp ${1} public/${LOGIN}/${R_DODS} #> out_dods_cp 2>&1
1142        RET=$?
1143       
1144#       if [ ${RET} -gt 0 ] ; then
1145#           echo "IGCM_sys_Dods_Cp : error."
1146#           cat out_dods_cp
1147#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1148#       else
1149#           rm out_dods_cp
1150#       fi
1151
1152    else
1153        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1154    fi
1155    return $RET
1156}
1157
1158#D-#==================================================
1159#D-function IGCM_sys_Put_Dods
1160#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1161#D-* Examples:
1162#D-
1163function IGCM_sys_Put_Dods {
1164    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1165    if ( $DEBUG_sys ) ; then
1166        echo "IGCM_sys_Put_Dods :" $@
1167    fi
1168    if [ $DRYRUN = 0 ]; then
1169        if [ ! -d ${R_SAVE}/${1} ] ; then
1170            echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
1171            IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1172            return
1173        fi
1174
1175        typeset RET
1176        #
1177        cd ${R_SAVE}
1178        IGCM_sys_Dods_Rm ${1}
1179        IGCM_sys_Dods_Cp ${1}
1180        RET=0
1181
1182        if [ ${RET} -gt 0 ] ; then
1183            echo "IGCM_sys_Put_Dods : error."
1184            IGCM_debug_Exit "IGCM_sys_Put_Dods"
1185        fi
1186    else
1187        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1188    fi
1189    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1190}
1191
1192############################################################## A FINIR !!
1193
1194#D-#==================================================
1195#D-function IGCM_sys_GetDate_FichWork
1196#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1197#D-* Examples:
1198#D-
1199function IGCM_sys_GetDate_FichWork {
1200    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1201    if ( $DEBUG_sys ) ; then
1202        echo "IGCM_sys_GetDate_FichWork :" $@
1203    fi
1204    # donne la date filesys d'un fichier sur la machine work
1205    IGCM_debug_PopStack "IGCM_sys_FichWork"
1206}
1207
1208#D-#==================================================
1209#D-function IGCM_sys_GetDate_FichArchive
1210#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1211#D-* Examples:
1212#D-
1213function IGCM_sys_GetDate_FichArchive {
1214    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1215    if ( $DEBUG_sys ) ; then
1216        echo "IGCM_sys_GetDate_FichArchive :" $@
1217    fi
1218    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1219}
1220
1221##############################################################
1222# REBUILD OPERATOR
1223
1224function IGCM_sys_rebuild {
1225    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1226    if ( $DEBUG_sys ) ; then
1227        echo "IGCM_sys_rebuild :" $@
1228    fi
1229    /home/cont003/p86ipsl/IA64/bin/rebuild -f -o $@
1230    if [ $? -gt 0 ] ; then
1231       echo "IGCM_sys_rebuild : erreur ${@}."
1232       IGCM_debug_Exit "rebuild"
1233    fi
1234
1235    IGCM_debug_PopStack "IGCM_sys_rebuild"
1236}
1237
1238##############################################################
1239# NCO OPERATOR
1240
1241function IGCM_sys_ncap2 {
1242    IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
1243    if ( $DEBUG_sys ) ; then
1244        echo "IGCM_sys_ncap2 :" $@
1245    fi
1246    /applications/nco/bin/ncap2 "$@"
1247    if [ $? -gt 0 ] ; then
1248       echo "IGCM_sys_ncap2 : erreur ${@}."
1249       IGCM_debug_Exit "ncap2"
1250    fi
1251
1252    IGCM_debug_PopStack "IGCM_sys_ncap2"
1253}
1254
1255function IGCM_sys_ncatted {
1256    IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1257    if ( $DEBUG_sys ) ; then
1258        echo "IGCM_sys_ncatted :" $@
1259    fi
1260    /usr/local/bin/ncatted "$@"
1261    if [ $? -gt 0 ] ; then
1262       echo "IGCM_sys_ncatted : erreur ${@}."
1263       IGCM_debug_Exit "ncatted"
1264    fi
1265
1266    IGCM_debug_PopStack "IGCM_sys_ncatted"
1267}
1268
1269function IGCM_sys_ncbo {
1270    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1271    if ( $DEBUG_sys ) ; then
1272        echo "IGCM_sys_ncbo :" $@
1273    fi
1274    /applications/nco/bin/ncbo $@
1275    if [ $? -gt 0 ] ; then
1276       echo "IGCM_sys_ncbo : erreur ${@}."
1277       IGCM_debug_Exit "ncbo"
1278    fi
1279
1280    IGCM_debug_PopStack "IGCM_sys_ncbo"
1281}
1282
1283function IGCM_sys_ncdiff {
1284    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1285    if ( $DEBUG_sys ) ; then
1286        echo "IGCM_sys_ncdiff :" $@
1287    fi
1288    /applications/nco/bin/ncdiff $@
1289    if [ $? -gt 0 ] ; then
1290       echo "IGCM_sys_ncdiff : erreur ${@}."
1291       IGCM_debug_Exit "ncdiff"
1292    fi
1293
1294    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1295}
1296
1297function IGCM_sys_ncea {
1298    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1299    if ( $DEBUG_sys ) ; then
1300        echo "IGCM_sys_ncea :" $@
1301    fi
1302    /applications/nco/bin/ncea $@
1303    if [ $? -gt 0 ] ; then
1304       echo "IGCM_sys_ncea : erreur ${@}."
1305       IGCM_debug_Exit "ncea"
1306    fi
1307
1308    IGCM_debug_PopStack "IGCM_sys_ncea"
1309}
1310
1311function IGCM_sys_ncecat {
1312    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1313    if ( $DEBUG_sys ) ; then
1314        echo "IGCM_sys_ncecat :" $@
1315    fi
1316    /applications/nco/bin/ncecat $@
1317    if [ $? -gt 0 ] ; then
1318       echo "IGCM_sys_ncecat : erreur ${@}."
1319       IGCM_debug_Exit "ncecat"
1320    fi
1321
1322    IGCM_debug_PopStack "IGCM_sys_ncecat"
1323}
1324
1325function IGCM_sys_ncflint {
1326    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1327    if ( $DEBUG_sys ) ; then
1328        echo "IGCM_sys_ncflint :" $@
1329    fi
1330    /usr/local/bin/ncflint $@
1331    if [ $? -gt 0 ] ; then
1332       echo "IGCM_sys_ncflint : erreur ${@}."
1333       IGCM_debug_Exit "ncflint"
1334    fi
1335
1336    IGCM_debug_PopStack "IGCM_sys_ncflint"
1337}
1338
1339function IGCM_sys_ncks {
1340    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1341    if ( $DEBUG_sys ) ; then
1342        echo "IGCM_sys_ncks :" $@
1343    fi
1344    /applications/nco/bin/ncks $@
1345    if [ $? -gt 0 ] ; then
1346       echo "IGCM_sys_ncks : erreur ${@}."
1347       IGCM_debug_Exit "ncks"
1348    fi
1349
1350    IGCM_debug_PopStack "IGCM_sys_ncks"
1351}
1352
1353function IGCM_sys_ncpdq {
1354    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1355    if ( $DEBUG_sys ) ; then
1356        echo "IGCM_sys_ncpdq :" $@
1357    fi
1358    /applications/nco/bin/ncpdq $@
1359    if [ $? -gt 0 ] ; then
1360       echo "IGCM_sys_ncpdq : erreur ${@}."
1361       IGCM_debug_Exit "ncpdq"
1362    fi
1363
1364    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1365}
1366
1367function IGCM_sys_ncra {
1368    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1369    if ( $DEBUG_sys ) ; then
1370        echo "IGCM_sys_ncra :" $@
1371    fi
1372    /applications/nco/bin/ncra $@
1373    if [ $? -gt 0 ] ; then
1374       echo "IGCM_sys_ncra : erreur ${@}."
1375       IGCM_debug_Exit "ncra"
1376    fi
1377
1378    IGCM_debug_PopStack "IGCM_sys_ncra"
1379}
1380
1381function IGCM_sys_ncrcat {
1382    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1383    if ( $DEBUG_sys ) ; then
1384        echo "IGCM_sys_ncrcat :" $@
1385    fi
1386    /applications/nco/bin/ncrcat $@
1387    if [ $? -gt 0 ] ; then
1388       echo "IGCM_sys_ncrcat : erreur ${@}."
1389#       IGCM_debug_Exit "ncrcat"
1390    fi
1391
1392    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1393}
1394
1395function IGCM_sys_ncrename {
1396    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1397    if ( $DEBUG_sys ) ; then
1398        echo "IGCM_sys_ncrename :" $@
1399    fi
1400    /applications/nco/bin/ncrename $@
1401    if [ $? -gt 0 ] ; then
1402       echo "IGCM_sys_ncrename : erreur ${@}."
1403       IGCM_debug_Exit "ncrename"
1404    fi
1405
1406    IGCM_debug_PopStack "IGCM_sys_ncrename"
1407}
1408
1409function IGCM_sys_ncwa {
1410    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1411    if ( $DEBUG_sys ) ; then
1412        echo "IGCM_sys_ncwa :" $@
1413    fi
1414    /applications/nco/bin/ncwa $@
1415    if [ $? -gt 0 ] ; then
1416       echo "IGCM_sys_ncwa : erreur ${@}."
1417       IGCM_debug_Exit "ncwa"
1418    fi
1419
1420    IGCM_debug_PopStack "IGCM_sys_ncwa"
1421}
1422
1423##############################################################
1424# CDO OPERATOR
1425
1426function IGCM_sys_cdo {
1427    IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
1428
1429    \cdo $@
1430    if [ $? -gt 0 ] ; then
1431        echo "IGCM_sys_cdo : erreur ${@}."
1432        IGCM_debug_PopStack "IGCM_sys_cdo"
1433        return 1
1434    else
1435        IGCM_debug_PopStack "IGCM_sys_cdo"
1436        return 0
1437    fi
1438
1439    IGCM_debug_PopStack "IGCM_sys_cdo"
1440}
1441
1442############################################################
1443# Activate Running Environnment Variables
1444
1445function IGCM_sys_activ_variables {
1446    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1447    if ( $DEBUG_sys ) ; then
1448        echo "IGCM_sys_activ_variables"
1449    fi
1450    ulimit -s 2097152
1451    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1452}
1453
1454############################################################
1455# Desactivate Running Environnment Variables
1456
1457function IGCM_sys_desactiv_variables {
1458    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1459    if ( $DEBUG_sys ) ; then
1460        echo "IGCM_sys_desactiv_variables"
1461    fi
1462    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1463}
1464
1465############################################################
1466# Build run file
1467
1468function IGCM_sys_build_run_file {
1469    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1470    if ( $DEBUG_sys ) ; then
1471        echo "IGCM_sys_build_run_file " $@
1472    fi
1473    NUM_PROC_OCE=1
1474    (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE - 1))
1475    (( nb_tot_m1    = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE ))
1476    if [ $1 = MPI1 ]; then
1477        cat <<EOF > run_file
1478#!/bin/bash
1479if [ \$SLURM_PROCID -eq 0 ]
1480  then ./oasis ;
1481elif ( [ \$SLURM_PROCID -ge 1 ] && [ \$SLURM_PROCID -lt ${nb_tot_m1} ] )
1482  then ./lmdz.x ;
1483else ./opa.xx ;
1484fi
1485EOF
1486        config_UserChoices_JobRunOptions='"-n ${BATCH_NUM_PROC_TOT}"'
1487        IGCM_sys_Chmod u+x run_file
1488    fi
1489    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1490 
1491}
Note: See TracBrowser for help on using the repository browser.