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

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

libIGCM is ready for ulam except concerning the monitoring

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