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

Last change on this file since 17 was 17, checked in by mmaipsl, 16 years ago

MM: Correct platine lib.

Update trunk from tag libIGCM_v1.

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