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

Last change on this file since 434 was 434, checked in by mmaipsl, 13 years ago

correct a typo in Message send by mail.

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