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

Last change on this file since 145 was 145, checked in by sdipsl, 15 years ago
  • Cesium : netcdf 3.6.3 depends on hdf5/1.8.2
  • Be more flexible in IGCM_sys_Get on post-processing machine
  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

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

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

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

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

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

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

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