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

Last change on this file since 128 was 128, checked in by mmaipsl, 15 years ago

Add experience type management : JobType? = DEB(ug), DEV(elopment), RUN (default)
(No propoagation in Post-treatment for instance).
Put "Where do we run ?" question in libIGCM_sys.

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