source: tags/libIGCM_v1_2/libIGCM_sys/libIGCM_sys_platine.ksh @ 293

Last change on this file since 293 was 44, checked in by sdipsl, 15 years ago

SD : - correct bug with post-processing in case of asynchronous rebuild.

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