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

Last change on this file since 39 was 39, checked in by sdipsl, 16 years ago

SD : Add sleep 60 in function IGCM_sys_Get_Master to prevent NFS problem

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

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

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

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

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

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

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

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