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

Last change on this file since 263 was 263, checked in by mafoipsl, 14 years ago

Adapt libIGCM and jobs to new output Names : ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName?} if SpaceName? and ExperimentName? are set into config.card. Still working with old types : ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}.
More information here : IPSLCM5A?
Add IPSLCM5A into atlas.

  • 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 Date Author Revision
File size: 37.2 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip
5# Contact: Martial.Mancip_ipsl.jussieu.fr
6# $Date$
7# $Author$
8# $Revision$
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11# History:
12# Modification:
13#
14#**************************************************************
15
16#=========================================================
17# The documentation of this file can be automatically generated
18# if you use the prefix #D- for comments to be extracted.
19# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
20#=========================================================
21
22#D-#==================================================
23#D-LibIGCM_sys for Platine
24#D-#==================================================
25#D-
26#D- This ksh library if a layer under some usefull
27#D-environment variables and shell commands.
28#D-All those definitions depend on host particularities.
29#D-It manages a stack mechanism and test validity of operations.
30#D-All function described bellow must be prefixed by IGCM_sys.
31
32#====================================================
33# libIGCM_sys PARAMETERS
34#====================================================
35
36#====================================================
37# set DEBUG_sys to true to output calls of function
38typeset -r DEBUG_sys=${DEBUG_sys:=true}
39
40#====================================================
41# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
42typeset -r DRYRUN=${DRYRUN:=0}
43
44# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
45# -------------------------------------------------------------------------------------
46# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
47# |          |  Cp/Exe param files |            |  Chmod  |                           |
48# |          |      Qsub           |            |         |                           |
49# -------------------------------------------------------------------------------------
50# |    0     |       yes           |    yes     |  yes    |      yes                  |
51# -------------------------------------------------------------------------------------
52# |    1     |       yes           |    yes     |  yes    |      no                   |
53# -------------------------------------------------------------------------------------
54# |    2     |       yes           |    yes     |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56# |    3     |       yes           |    no      |  no     |      no                   |
57# -------------------------------------------------------------------------------------
58
59#=====================================================
60# Global Variables :
61#=====================================================
62# Language : "fr" or "en"
63typeset -r MYLANG="fr"
64
65#=====================================================
66# Host and user names
67# $hostname ou hostname
68typeset  HOST=${HOST:=$( hostname )}
69# $username ou whoami
70typeset  LOGIN=${LOGIN:=$( whoami )}
71# $hostname of the MASTER job
72typeset MASTER=platine
73
74#D-
75#D-#==================================================
76#D-Program used in libIGCM
77#D-#==================================================
78
79# rsync with path
80typeset -r RSYNC=/usr/bin/rsync
81# RSYNC_opt args to rsync
82typeset -r RSYNC_opt="-va"
83# ie storage filesystem
84typeset -r RHOST=platine
85
86#====================================================
87# Source Ferret
88. /home/cont003/p86ipsl/.atlas_env_platine_ksh
89
90#====================================================
91# Specific for ocean additionnal diagnostic
92export FER_GO="$FER_GO /home/cont003/p86denv/IGCM_POST_UTIL/JNL /home/cont003/p86denv/GRAF /home/cont003/p86denv/GRAF/GO"
93export FER_PALETTE="$FER_PALETTE /home/cont003/p86denv/GRAF/PALET"
94
95#====================================================
96# Host specific DIRECTORIES
97#====================================================
98
99#====================================================
100#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
101typeset -r R_EXE="${MODIPSL}/bin"
102
103#====================================================
104#- SUBMIT_DIR : submission dir
105typeset SUBMIT_DIR=${SUBMIT_DIR:=${PWD}}
106
107#====================================================
108#- ARCHIVE
109typeset -r ARCHIVE=${DMFDIR}
110
111#====================================================
112#- libIGCM_POST
113typeset -r libIGCM_POST=${libIGCM}
114
115#====================================================
116#- IN
117typeset -r R_IN=${R_IN:=/dmnfs/cont003/p86ipsl/IGCM}
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    #set -vx
167    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
168    /bin/ksh <<-EOF
169    export libIGCM=${libIGCM}
170    export DEBUG_debug=${DEBUG_debug}
171    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
172    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
173    ${@}
174EOF
175    if [ $? -gt 0 ] ; then
176        echo "IGCM_sys_RshMaster : erreur."
177        IGCM_debug_Exit "IGCM_sys_RshMaster"
178    fi
179    IGCM_debug_PopStack "IGCM_sys_RshMaster"
180}
181
182#D-#==================================================
183#D-function IGCM_sys_RshArchive
184#D-* Purpose: Archive rsh command
185#D-* Examples:
186#D-
187function IGCM_sys_RshArchive {
188    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
189    /bin/ksh <<-EOF
190    ${@}
191EOF
192    if [ $? -gt 0 ] ; then
193        echo "IGCM_sys_RshArchive : erreur."
194        IGCM_debug_Exit "IGCM_sys_RshArchive"
195    fi
196    IGCM_debug_PopStack "IGCM_sys_RshArchive"
197}
198
199#D-#==================================================
200#D-function IGCM_sys_RshPost
201#D-* Purpose: Post-process rsh command
202#D-* Examples:
203#D-
204function IGCM_sys_RshPost {
205    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
206    if ( $DEBUG_sys ) ; then
207        echo "IGCM_sys_RshPost :" $@
208    fi
209    /bin/ksh ${@}
210    if [ $? -gt 0 ] ; then
211        echo "IGCM_sys_RshPost : erreur."
212        IGCM_debug_Exit "IGCM_sys_RshPost"
213    fi
214    IGCM_debug_PopStack "IGCM_sys_RshPost"
215}
216
217#D-#==================================================
218#D-function IGCM_sys_SendMail
219#D-* Purpose: Send mail when simulation is over
220#D-* Examples:
221#D-
222function IGCM_sys_SendMail {
223    IGCM_debug_PushStack "IGCM_sys_SendMailPost" $@
224    if ( $DEBUG_sys ) ; then
225       echo "IGCM_sys_SendMail :" $@
226    fi
227    cat  << END_MAIL > job_end.mail
228Dear ${LOGIN},
229
230  Simulation ${config_UserChoices_JobName} is finished on supercomputer `hostname`.
231  Job started : ${DateBegin}
232  Job ended   : ${DateEnd}
233  Ouput files are available in ${R_SAVE}
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    typeset ExistFlag
416    ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
417    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
418
419    return ${ExistFlag}
420}
421
422#D-#==================================================
423#D-function IGCM_sys_CountFileArchive
424#D-* Purpose: Count files on Archive filesystem
425#D-* Examples:
426#D-
427function IGCM_sys_CountFileArchive {
428    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
429    ls ${@} 2>/dev/null | wc -l
430    if [ $? -gt 0 ] ; then
431        echo "IGCM_sys_CountFileArchive : erreur."
432    fi
433    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
434}
435
436#D-#==================================================
437#D-function IGCM_sys_Tree
438#D-* Purpose: Tree directories with files on ${ARCHIVE}
439#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
440#D-
441function IGCM_sys_Tree {
442    IGCM_debug_PushStack "IGCM_sys_Tree" $@
443    if ( $DEBUG_sys ) ; then
444        echo "IGCM_sys_Tree :" $@
445    fi
446
447    \tree -f $@
448
449    IGCM_debug_PopStack "IGCM_sys_Tree"
450}
451
452#D-#==================================================
453#D-function IGCM_sys_Tar
454#D-* Purpose: master un-tar command
455#D-* Examples:
456#D-
457function IGCM_sys_Tar {
458    IGCM_debug_PushStack "IGCM_sys_Tar" $@
459    if ( $DEBUG_sys ) ; then
460        echo "IGCM_sys_Tar :" $@
461    fi
462    \tar cvf $@
463    if [ $? -gt 0 ] ; then
464        echo "IGCM_sys_Tar : erreur."
465        IGCM_debug_Exit "IGCM_sys_Tar"
466    fi
467    \tar tvf $1
468
469    IGCM_debug_PopStack "IGCM_sys_Tar"
470}
471
472#D-#==================================================
473#D-function IGCM_sys_UnTar
474#D-* Purpose: master un-tar command
475#D-* Examples:
476#D-
477function IGCM_sys_UnTar {
478    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
479    if ( $DEBUG_sys ) ; then
480        echo "IGCM_sys_UnTar :" $@
481    fi
482    \tar xvf $1
483    if [ $? -gt 0 ] ; then
484        echo "IGCM_sys_UnTar : erreur."
485        IGCM_debug_Exit "IGCM_sys_UnTar"
486    fi
487    IGCM_debug_PopStack "IGCM_sys_UnTar"
488}
489
490#D-#==================================================
491#D-function IGCM_sys_Qsub
492#D-* Purpose: Qsub new job
493#D-* Examples:
494#D-
495function IGCM_sys_Qsub {
496    IGCM_debug_PushStack "IGCM_sys_Qsub" $@
497    if ( $DEBUG_sys ) ; then
498        echo "IGCM_sys_Qsub :" $@
499    fi
500    bsub -o ${Script_Output} -J ${config_UserChoices_JobName}.${CumulPeriod} < $1
501    if [ $? -gt 0 ] ; then
502        echo "IGCM_sys_Qsub : erreur " $@
503        IGCM_debug_Exit "IGCM_sys_Qsub"
504    fi
505    IGCM_debug_PopStack "IGCM_sys_Qsub"
506}
507
508#D-#==================================================
509#D-function IGCM_sys_QsubPost
510#D-* Purpose: Qsub new job on scalaire
511#D-* Examples:
512#D-
513function IGCM_sys_QsubPost {
514    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
515    if ( $DEBUG_sys ) ; then
516        echo "IGCM_sys_QsubPost :" $@
517    fi
518    bsub -o ${POST_DIR}/$1.${PeriodDateEnd}.out < ${libIGCM_POST}/$1.job
519    if [ $? -gt 0 ] ; then
520        echo "IGCM_sys_QsubPost : erreur " $@
521        IGCM_debug_Exit "IGCM_sys_QsubPost"
522    fi
523    IGCM_debug_PopStack "IGCM_sys_QsubPost"
524}
525
526#D-*************************
527#D- File transfer functions
528#D-*************************
529#D-
530
531#D-#==================================================
532#D-function IGCM_sys_Rsync_out
533#D-* Purpose: treat return val of rsync
534#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
535#D-  Error values and explanations can depend on your system version.
536function IGCM_sys_Rsync_out {
537    RET=$1
538    if [ ! $RET ] ; then
539        echo "rsync error !"
540    fi
541
542    if [ $MYLANG = "fr" ]; then
543        case $RET in
544            0)  return ;;
545            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
546                echo "Erreur de syntaxe ou d'utilisation."
547                return;;
548            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
549                echo "Incompatibilité de protocole."
550                return;;
551            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
552                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
553                echo "répertoires"
554                return;;
555            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
556                echo "Action demandée non supportée : une tentative de manipulation de"
557                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
558                echo "été faite ; ou une option qui est supportée par le  client  mais"
559                echo "pas par le serveur a été spécifiée."
560                return;;
561            10) echo "Erreur de rsync ; RERR_SOCKETIO"
562                echo "Erreur dans le socket d'entrée sortie"
563                return;;
564            11) echo "Erreur de rsync ; RERR_FILEIO"
565                echo "Erreur d'entrée sortie fichier"
566                return;;
567            12) echo "Erreur de rsync ; RERR_STREAMIO"
568                echo "Erreur dans flux de donnée du protocole rsync"
569                return;;
570            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
571                echo "Erreur avec les diagnostics du programme"
572                return;;
573            14) echo "Erreur de rsync ; RERR_IPC"
574                echo "Erreur dans le code IPC"
575                return;;
576            20) echo "Erreur de rsync ; RERR_SIGNAL"
577                echo "SIGUSR1 ou SIGINT reçu"
578                return;;
579            21) echo "Erreur de rsync ; RERR_WAITCHILD"
580                echo "Une erreur retournée par waitpid()"
581                return;;
582            22) echo "Erreur de rsync ; RERR_MALLOC"
583                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
584                return;;
585            23) echo ""
586                echo "Erreur fichier inexistant"
587                return;;
588            30) echo "Erreur de rsync ; RERR_TIMEOUT"
589                echo "Temps d'attente écoulé dans l'envoi/réception de données"
590                return;;
591            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
592                return;;
593        esac
594    elif [ $MYLANG = "en" ] ; then
595        case $RET in
596            0)  return;;               
597            1)  echo "rsync error : Syntax or usage error "
598                return;;
599            2)  echo "rsync error : Protocol incompatibility "
600                return;;
601            3)  echo "rsync error : Errors selecting input/output files, dirs"
602                return;;
603            4)  echo "rsync error : Requested action not supported: an attempt"
604                echo "was made to manipulate 64-bit files on a platform that cannot support"
605                echo "them; or an option was specified that is supported by the client and"
606                echo "not by the server."
607                return;;
608            5)  echo "rsync error : Error starting client-server protocol"
609                return;;
610            10) echo "rsync error : Error in socket I/O "
611                return;;
612            11) echo "rsync error : Error in file I/O "
613                return;;
614            12) echo "rsync error : Error in rsync protocol data stream "
615                return;;
616            13) echo "rsync error : Errors with program diagnostics "
617                return;;
618            14) echo "rsync error : Error in IPC code "
619                return;;
620            20) echo "rsync error : Received SIGUSR1 or SIGINT "
621                return;;
622            21) echo "rsync error : Some error returned by waitpid() "
623                return;;
624            22) echo "rsync error : Error allocating core memory buffers "
625                return;;
626            23) echo "rsync error : Partial transfer due to error"
627                return;;
628            24) echo "rsync error : Partial transfer due to vanished source files"
629                return;;
630            30) echo "rsync error : Timeout in data send/receive "
631                return;;
632            *)  echo "rsync error : return code of rsync unknown :" $RET
633                return;;
634        esac
635    else
636        echo "unknown language $MYLANG."
637        return
638    fi
639}
640   
641#D-#==================================================
642#D-function IGCM_sys_Cp
643#D-* Purpose: generic cp
644#D-* Examples:
645#D-
646function IGCM_sys_Cp {
647    IGCM_debug_PushStack "IGCM_sys_Cp" $@
648    if ( $DEBUG_sys ) ; then
649        echo "IGCM_sys_Cp :" $@
650    fi
651
652    typeset RET
653
654    echo cp $@ > out_rsync 2>&1
655    \cp $@ >> out_rsync 2>&1
656    RET=$?
657
658    if [ ${RET} -gt 0 ] ; then
659        echo "IGCM_sys_Cp : error."
660        cat out_rsync
661        IGCM_debug_Exit "IGCM_sys_Cp"
662    fi
663    IGCM_debug_PopStack "IGCM_sys_Cp"
664}
665
666#D-#==================================================
667#D-function IGCM_sys_Rm
668#D-* Purpose: generic rm
669#D-* Examples:
670#D-
671function IGCM_sys_Rm {
672    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
673    if ( $DEBUG_sys ) ; then
674        echo "IGCM_sys_Rm :" $@
675    fi
676
677    typeset RET
678
679    echo rm $@ > out_rsync 2>&1
680    \rm $@ >> out_rsync 2>&1
681    RET=$?
682
683    if [ ${RET} -gt 0 ] ; then
684        echo "IGCM_sys_Rm : error."
685        cat out_rsync
686        IGCM_debug_Exit "IGCM_sys_Rm"
687    fi
688    IGCM_debug_PopStack "IGCM_sys_Rm"
689}
690
691#D-#==================================================
692#D-function IGCM_sys_RmRunDir
693#D-* Purpose: rm tmpdir (dummy function most of the time batch
694#D-                      scheduler will do the job)
695#D-* Examples:
696#D-
697function IGCM_sys_RmRunDir {
698    IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
699    if ( $DEBUG_sys ) ; then
700        echo "IGCM_sys_RmRunDir :" $@
701        echo "Dummy call, let the scheduler do that."
702    fi
703    IGCM_debug_PopStack "IGCM_sys_RmRunDir"
704}
705
706#D-#==================================================
707#D-function IGCM_sys_Mv
708#D-* Purpose: generic move
709#D-* Examples:
710#D-
711function IGCM_sys_Mv {
712    IGCM_debug_PushStack "IGCM_sys_Mv" $@
713    if ( $DEBUG_sys ) ; then
714        echo "IGCM_sys_Mv :" $@
715    fi
716
717    if [ $DRYRUN = 0 ]; then
718
719        typeset RET
720           
721        echo mv $@ > out_rsync 2>&1
722        \mv $@ >> out_rsync 2>&1
723        RET=$?
724   
725        if [ ${RET} -gt 0 ] ; then
726            echo "IGCM_sys_Mv : error in mv."
727            cat out_rsync
728            IGCM_debug_Exit "IGCM_sys_Mv"
729        fi
730    else
731        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
732    fi
733
734    IGCM_debug_PopStack "IGCM_sys_Mv"
735}
736
737#D-#==================================================
738#D-function IGCM_sys_Put_Dir
739#D-* Purpose: Copy a complete directory on $(ARCHIVE)
740#D-* Examples:
741#D-
742function IGCM_sys_Put_Dir {
743    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
744    if ( $DEBUG_sys ) ; then
745        echo "IGCM_sys_Put_Dir :" $@
746    fi
747    if [ $DRYRUN = 0 ]; then
748        if [ ! -d ${1} ] ; then
749            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
750            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
751            return
752        fi
753
754        typeset RET
755
756        # Only if we use rsync
757        #IGCM_sys_TestDirArchive $( dirname $2 )
758        #
759        #USUAL WAY
760        \cp -r $1 $2 > out_rsync 2>&1
761        RET=$?
762
763        if [ ${RET} -gt 0 ] ; then
764            echo "IGCM_sys_Put_Dir : error."
765            cat out_rsync
766            IGCM_debug_Exit "IGCM_sys_Put_Dir"
767        fi
768    else
769        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
770    fi
771    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
772}
773
774#D-#==================================================
775#D-function IGCM_sys_Get_Dir
776#D-* Purpose: Copy a complete directory from $(ARCHIVE)
777#D-* Examples:
778#D-
779function IGCM_sys_Get_Dir {
780    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
781    if ( $DEBUG_sys ) ; then
782        echo "IGCM_sys_Get_Dir :" $@
783    fi
784    if [ $DRYRUN = 0 ]; then
785#       if [ ! -d ${1} ] ; then
786#           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
787#           IGCM_debug_PopStack "IGCM_sys_Get_Dir"
788#           return
789#       fi
790
791        typeset RET
792
793        # Only if we use rsync
794        #IGCM_sys_TestDirArchive $( dirname $2 )
795        #
796        #USUAL WAY
797        \cp -r $1 $2 > out_rsync 2>&1
798        RET=$?
799
800        if [ ${RET} -gt 0 ] ; then
801            echo "IGCM_sys_Get_Dir : error."
802            cat out_rsync
803            IGCM_debug_Exit "IGCM_sys_Get_Dir"
804        fi
805    else
806        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
807    fi
808    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
809}
810
811#D-#==================================================
812#D-function IGCM_sys_Get_Master
813#D-* Purpose: Copy a complete directory from MASTER filesystem
814#D-* Examples:
815#D-
816function IGCM_sys_Get_Master {
817    IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
818    if ( $DEBUG_sys ) ; then
819        echo "IGCM_sys_Get_Master :" $@
820    fi
821    if [ $DRYRUN = 0 ]; then
822        if [ ! -d ${1} ] ; then
823            echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
824            IGCM_debug_PopStack "IGCM_sys_Get_Master"
825            return
826        fi
827
828        typeset RET
829        sleep 60
830
831        #USUAL WAY
832        \cp -r $1 $2 > out_rsync 2>&1
833        RET=$?
834
835        if [ ${RET} -gt 0 ] ; then
836            echo "IGCM_sys_Get_Master : error."
837            cat out_rsync
838            IGCM_debug_Exit "IGCM_sys_Get_Master"
839        fi
840    else
841        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
842    fi
843    IGCM_debug_PopStack "IGCM_sys_Get_Master"
844}
845
846#D-#==================================================
847#D-function IGCM_sys_Put_Rest
848#D-* Purpose: Put computied restarts on $(ARCHIVE).
849#D-           File and target directory must exist.
850#D-* Examples:
851#D-
852function IGCM_sys_Put_Rest {
853    IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
854    if ( $DEBUG_sys ) ; then
855        echo "IGCM_sys_Put_Rest :" $@
856    fi
857    if [ $DRYRUN = 0 ]; then
858        if [ ! -f ${1} ] ; then
859            echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
860            IGCM_debug_Exit "IGCM_sys_Put_Rest"
861        fi
862
863        typeset RET
864        #
865        if [ X${JobType} = XRUN ] ; then
866            IGCM_sys_Chmod 444 ${1}
867        fi
868        #
869        IGCM_sys_TestDirArchive $( dirname $2 )
870        #
871        # USUAL WAY
872        putfer $1 $2 > out_rsync 2>&1
873        RET=$?
874
875#       #RSYNC WITH NETWORK RSH CALL
876#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
877#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
878
879#       #RSYNC WITH NFS USE
880#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
881#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
882
883#       RET=$?
884#       IGCM_sys_Rsync_out $RET
885
886#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
887#       (( RET=RET+$? ))
888
889        if [ ${RET} -gt 0 ] ; then
890            echo "IGCM_sys_Put_Rest : error."
891            cat out_rsync
892            IGCM_debug_Exit "IGCM_sys_Put_Rest"
893        fi
894    else
895        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
896    fi
897    IGCM_debug_PopStack "IGCM_sys_Put_Rest"
898}
899
900#D-#==================================================
901#D-function IGCM_sys_Put_Out
902#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
903#D-* Examples:
904#D-
905function IGCM_sys_Put_Out {
906    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
907    if ( $DEBUG_sys ) ; then
908        echo "IGCM_sys_Put_Out :" $@
909    fi
910    if [ $DRYRUN = 0 ]; then
911        if [ ! -f ${1} ] ; then
912            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
913            IGCM_debug_PopStack "IGCM_sys_Put_Out"
914            return 1
915        fi
916        #
917        IGCM_sys_MkdirArchive $( dirname $2 )
918        #
919        typeset RET
920        #
921        if [ X${JobType} = XRUN ] ; then
922            if [ X${3} = X ] ; then
923                IGCM_sys_Chmod 444 ${1}
924            fi
925        fi
926        #
927        # USUAL WAY
928        putfer $1 $2 > out_rsync 2>&1
929        RET=$?
930
931#       #RSYNC WITH NETWORK RSH CALL
932#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
933#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
934
935#       #RSYNC WITH NFS USE
936#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
937#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
938
939#       RET=$?
940#       IGCM_sys_Rsync_out $RET
941
942#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
943#       (( RET=RET+$? ))
944
945        if [ ${RET} -gt 0 ] ; then
946            echo "IGCM_sys_Put_Out : error."
947            cat out_rsync
948            IGCM_debug_Exit "IGCM_sys_Put_Out"
949        fi
950    else
951        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
952    fi
953    IGCM_debug_PopStack "IGCM_sys_Put_Out"
954    return 0
955}
956
957#D-#==================================================
958#D-function IGCM_sys_Get
959#D-* Purpose: Get a file from ${ARCHIVE}
960#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
961#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
962function IGCM_sys_Get {
963    IGCM_debug_PushStack "IGCM_sys_Get" $@
964
965    typeset DEST RET dm_liste ifile target file_work
966
967    if ( $DEBUG_sys ) ; then
968        echo "IGCM_sys_Get :" $@
969    fi
970    if [ $DRYRUN -le 2 ]; then
971        if [ X${1} = X'/l' ] ; then
972            # test if the first file is present in the old computation :
973            eval set +A dm_liste \${${2}}
974        else
975            eval set +A dm_liste ${1}
976        fi
977        eval DEST=\${${#}}
978
979        #=====================================================
980        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
981        #=====================================================
982
983        # Is it an R_OUT file (not R_IN) ?
984        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
985        #if [ $? -eq 0 ] ; then
986        #    # Yes  ? then we try to get it in SCRATCHDIR
987        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
988        #    if [ -f ${file_work[0]} ] ; then
989        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
990        #       IGCM_debug_PopStack "IGCM_sys_Get"
991        #       return
992        #    fi
993        #fi
994
995        # test if the (first) file is present in the old computation :
996        IGCM_sys_TestFileArchive ${dm_liste[0]}
997        RET=$?
998        if [ ${RET} -gt 0 ] ; then
999            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
1000            IGCM_debug_Exit "IGCM_sys_Get"
1001            #IGCM_debug_PopStack "IGCM_sys_Get"
1002            #return
1003        fi
1004
1005#       dmget ${dm_liste[*]} > out_rsync 2>&1
1006#       RET=$?
1007#       if [ ${RET} -gt 0 ] ; then
1008#           echo "IGCM_sys_Get : demigration error."
1009#           cat out_rsync
1010#           IGCM_debug_Exit "IGCM_sys_Get"
1011#           IGCM_debug_PopStack "IGCM_sys_Get"
1012#           return
1013#       fi
1014
1015        #USUAL WAY
1016        (( RET=0 ))
1017        if [ X${1} = X'/l' ] ; then
1018            (( RET=0 ))
1019            for target in ${dm_liste[*]} ; do
1020                local_file=$( basename ${target} )
1021                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1022                (( RET = RET + $? ))
1023            done
1024        else
1025            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1026            RET=$?
1027        fi
1028
1029#       #RSYNC WITH NETWORK RSH CALL
1030#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1031#       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1032
1033#       #RSYNC WITH NFS USE
1034#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1035#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1036
1037#       RET=$?
1038#       IGCM_sys_Rsync_out $RET
1039
1040#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1041#       (( RET=RET+$? ))
1042
1043        if [ ${RET} -gt 0 ] ; then
1044            echo "IGCM_sys_Get : copy error."
1045            cat out_rsync
1046            IGCM_debug_Exit "IGCM_sys_Get"
1047        fi
1048    else
1049        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1050    fi
1051    IGCM_debug_PopStack "IGCM_sys_Get"
1052}
1053
1054#D-#==================================================
1055#D-function IGCM_sys_Put_Dods
1056#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1057#D-* Examples:
1058#D-
1059function IGCM_sys_Put_Dods {
1060    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1061    if ( $DEBUG_sys ) ; then
1062        echo "IGCM_sys_Put_Dods :" $@
1063    fi
1064    if [ $DRYRUN = 0 ]; then
1065        if [ ! -d ${R_SAVE}/${1} ] ; then
1066            echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
1067            IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1068            return
1069        fi
1070
1071        typeset RET
1072        #
1073        cd ${R_SAVE}
1074        dods_rm public/${LOGIN}/${R_DODS}/${1} > /dev/null 2>&1
1075        dods_cp ${1} public/${LOGIN}/${R_DODS} > /dev/null 2>&1
1076        RET=0
1077
1078        if [ ${RET} -gt 0 ] ; then
1079            echo "IGCM_sys_Put_Dods : error."
1080            IGCM_debug_Exit "IGCM_sys_Put_Dods"
1081        fi
1082    else
1083        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1084    fi
1085    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1086}
1087
1088############################################################## A FINIR !!
1089
1090#D-#==================================================
1091#D-function IGCM_sys_GetDate_FichWork
1092#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1093#D-* Examples:
1094#D-
1095function IGCM_sys_GetDate_FichWork {
1096    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1097    if ( $DEBUG_sys ) ; then
1098        echo "IGCM_sys_GetDate_FichWork :" $@
1099    fi
1100    # donne la date filesys d'un fichier sur la machine work
1101    IGCM_debug_PopStack "IGCM_sys_FichWork"
1102}
1103
1104#D-#==================================================
1105#D-function IGCM_sys_GetDate_FichArchive
1106#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1107#D-* Examples:
1108#D-
1109function IGCM_sys_GetDate_FichArchive {
1110    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1111    if ( $DEBUG_sys ) ; then
1112        echo "IGCM_sys_GetDate_FichArchive :" $@
1113    fi
1114    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1115}
1116
1117##############################################################
1118# NCO OPERATOR
1119
1120function IGCM_sys_ncap {
1121    IGCM_debug_PushStack "IGCM_sys_ncap" -- $@
1122    if ( $DEBUG_sys ) ; then
1123        echo "IGCM_sys_ncap :" $@
1124    fi
1125    /applications/nco/bin/ncap $@
1126    if [ $? -gt 0 ] ; then
1127       echo "IGCM_sys_ncap : erreur ${@}."
1128#       IGCM_debug_Exit "ncap"
1129    fi
1130
1131    IGCM_debug_PopStack "IGCM_sys_ncap"
1132}
1133
1134ncatted=/applications/nco/bin/ncatted
1135# Problem with ksh and string passed in this function to ncatted !
1136# function IGCM_sys_ncatted {
1137#     IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1138#     if ( $DEBUG_sys ) ; then
1139#       echo "IGCM_sys_ncatted :" $@
1140#     fi
1141#     /usr/local/bin/ncatted $@
1142#     if [ $? -gt 0 ] ; then
1143#        echo "IGCM_sys_ncatted : erreur ${@}."
1144#        IGCM_debug_Exit "ncatted"
1145#     fi
1146
1147#     IGCM_debug_PopStack "IGCM_sys_ncatted"
1148# }
1149
1150function IGCM_sys_ncbo {
1151    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1152    if ( $DEBUG_sys ) ; then
1153        echo "IGCM_sys_ncbo :" $@
1154    fi
1155    /applications/nco/bin/ncbo $@
1156    if [ $? -gt 0 ] ; then
1157       echo "IGCM_sys_ncbo : erreur ${@}."
1158#       IGCM_debug_Exit "ncbo"
1159    fi
1160
1161    IGCM_debug_PopStack "IGCM_sys_ncbo"
1162}
1163
1164function IGCM_sys_ncdiff {
1165    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1166    if ( $DEBUG_sys ) ; then
1167        echo "IGCM_sys_ncdiff :" $@
1168    fi
1169    /applications/nco/bin/ncdiff $@
1170    if [ $? -gt 0 ] ; then
1171       echo "IGCM_sys_ncdiff : erreur ${@}."
1172#       IGCM_debug_Exit "ncdiff"
1173    fi
1174
1175    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1176}
1177
1178function IGCM_sys_ncea {
1179    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1180    if ( $DEBUG_sys ) ; then
1181        echo "IGCM_sys_ncea :" $@
1182    fi
1183    /applications/nco/bin/ncea $@
1184    if [ $? -gt 0 ] ; then
1185       echo "IGCM_sys_ncea : erreur ${@}."
1186#       IGCM_debug_Exit "ncea"
1187    fi
1188
1189    IGCM_debug_PopStack "IGCM_sys_ncea"
1190}
1191
1192function IGCM_sys_ncecat {
1193    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1194    if ( $DEBUG_sys ) ; then
1195        echo "IGCM_sys_ncecat :" $@
1196    fi
1197    /applications/nco/bin/ncecat $@
1198    if [ $? -gt 0 ] ; then
1199       echo "IGCM_sys_ncecat : erreur ${@}."
1200#       IGCM_debug_Exit "ncecat"
1201    fi
1202
1203    IGCM_debug_PopStack "IGCM_sys_ncecat"
1204}
1205
1206function IGCM_sys_ncflint {
1207    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1208    if ( $DEBUG_sys ) ; then
1209        echo "IGCM_sys_ncflint :" $@
1210    fi
1211    /usr/local/bin/ncflint $@
1212    if [ $? -gt 0 ] ; then
1213       echo "IGCM_sys_ncflint : erreur ${@}."
1214#       IGCM_debug_Exit "ncflint"
1215    fi
1216
1217    IGCM_debug_PopStack "IGCM_sys_ncflint"
1218}
1219
1220function IGCM_sys_ncks {
1221    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1222    if ( $DEBUG_sys ) ; then
1223        echo "IGCM_sys_ncks :" $@
1224    fi
1225    /applications/nco/bin/ncks $@
1226    if [ $? -gt 0 ] ; then
1227       echo "IGCM_sys_ncks : erreur ${@}."
1228#       IGCM_debug_Exit "ncks"
1229    fi
1230
1231    IGCM_debug_PopStack "IGCM_sys_ncks"
1232}
1233
1234function IGCM_sys_ncpdq {
1235    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1236    if ( $DEBUG_sys ) ; then
1237        echo "IGCM_sys_ncpdq :" $@
1238    fi
1239    /applications/nco/bin/ncpdq $@
1240    if [ $? -gt 0 ] ; then
1241       echo "IGCM_sys_ncpdq : erreur ${@}."
1242#       IGCM_debug_Exit "ncpdq"
1243    fi
1244
1245    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1246}
1247
1248function IGCM_sys_ncra {
1249    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1250    if ( $DEBUG_sys ) ; then
1251        echo "IGCM_sys_ncra :" $@
1252    fi
1253    /applications/nco/bin/ncra $@
1254    if [ $? -gt 0 ] ; then
1255       echo "IGCM_sys_ncra : erreur ${@}."
1256#       IGCM_debug_Exit "ncra"
1257    fi
1258
1259    IGCM_debug_PopStack "IGCM_sys_ncra"
1260}
1261
1262function IGCM_sys_ncrcat {
1263    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1264    if ( $DEBUG_sys ) ; then
1265        echo "IGCM_sys_ncrcat :" $@
1266    fi
1267    /applications/nco/bin/ncrcat $@
1268    if [ $? -gt 0 ] ; then
1269       echo "IGCM_sys_ncrcat : erreur ${@}."
1270#       IGCM_debug_Exit "ncrcat"
1271    fi
1272
1273    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1274}
1275
1276function IGCM_sys_ncrename {
1277    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1278    if ( $DEBUG_sys ) ; then
1279        echo "IGCM_sys_ncrename :" $@
1280    fi
1281    /applications/nco/bin/ncrename $@
1282    if [ $? -gt 0 ] ; then
1283       echo "IGCM_sys_ncrename : erreur ${@}."
1284#       IGCM_debug_Exit "ncrename"
1285    fi
1286
1287    IGCM_debug_PopStack "IGCM_sys_ncrename"
1288}
1289
1290function IGCM_sys_ncwa {
1291    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1292    if ( $DEBUG_sys ) ; then
1293        echo "IGCM_sys_ncwa :" $@
1294    fi
1295    /applications/nco/bin/ncwa $@
1296    if [ $? -gt 0 ] ; then
1297       echo "IGCM_sys_ncwa : erreur ${@}."
1298#       IGCM_debug_Exit "ncwa"
1299    fi
1300
1301    IGCM_debug_PopStack "IGCM_sys_ncwa"
1302}
1303
1304##############################################################
1305# REBUILD OPERATOR
1306
1307function IGCM_sys_rebuild {
1308    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1309    if ( $DEBUG_sys ) ; then
1310        echo "IGCM_sys_rebuild :" $@
1311    fi
1312    /home/cont003/p86ipsl/IA64/bin/rebuild -f -o $@
1313    if [ $? -gt 0 ] ; then
1314       echo "IGCM_sys_rebuild : erreur ${@}."
1315       IGCM_debug_Exit "rebuild"
1316    fi
1317
1318    IGCM_debug_PopStack "IGCM_sys_rebuild"
1319}
1320
1321############################################################
1322# Activate Running Environnment Variables
1323
1324function IGCM_sys_activ_variables {
1325    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1326    if ( $DEBUG_sys ) ; then
1327        echo "IGCM_sys_activ_variables"
1328    fi
1329    ulimit -s 2097152
1330    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1331}
1332
1333############################################################
1334# Desactivate Running Environnment Variables
1335
1336function IGCM_sys_desactiv_variables {
1337    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1338    if ( $DEBUG_sys ) ; then
1339        echo "IGCM_sys_desactiv_variables"
1340    fi
1341    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1342}
1343
1344############################################################
1345# Build run file
1346
1347function IGCM_sys_build_run_file {
1348    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1349    if ( $DEBUG_sys ) ; then
1350        echo "IGCM_sys_build_run_file " $@
1351    fi
1352    NUM_PROC_OCE=1
1353    (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE - 1))
1354    (( nb_tot_m1    = $BATCH_NUM_PROC_TOT - NUM_PROC_OCE ))
1355    if [ $1 = MPI1 ]; then
1356        cat <<EOF > run_file
1357#!/bin/bash
1358if [ \$SLURM_PROCID -eq 0 ]
1359  then ./oasis ;
1360elif ( [ \$SLURM_PROCID -ge 1 ] && [ \$SLURM_PROCID -lt ${nb_tot_m1} ] )
1361  then ./lmdz.x ;
1362else ./opa.xx ;
1363fi
1364EOF
1365        config_UserChoices_JobRunOptions='"-n ${BATCH_NUM_PROC_TOT}"'
1366        IGCM_sys_Chmod u+x run_file
1367    fi
1368    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1369 
1370}
Note: See TracBrowser for help on using the repository browser.