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

Last change on this file since 217 was 217, checked in by sdipsl, 14 years ago

Avoid side effect with user environment. Do not define read-only varible potentially defined by system environment.

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