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

Last change on this file since 101 was 98, checked in by sdipsl, 15 years ago
  • Try to avoid having stack files every where during post-processing job.
  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

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