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

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

Explicit all MASTER name.
for exemple you can not rcp vargas92, but vargas you can

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