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

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

ACa/SD : Function IGCM_sys_RshArchive will be use to manage NEMO restart in the parallel case

  • 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
821        #USUAL WAY
822        \cp -r $1 $2 > out_rsync 2>&1
823        RET=$?
824
825        if [ ${RET} -gt 0 ] ; then
826            echo "IGCM_sys_Get_Master : error."
827            cat out_rsync
828            IGCM_debug_Exit "IGCM_sys_Get_Master"
829        fi
830    else
831        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
832    fi
833    IGCM_debug_PopStack "IGCM_sys_Get_Master"
834}
835
836#D-#==================================================
837#D-function IGCM_sys_Put_Out
838#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
839#D-* Examples:
840#D-
841function IGCM_sys_Put_Out {
842    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
843    if ( $DEBUG_sys ) ; then
844        echo "IGCM_sys_Put_Out :" $@
845    fi
846    if [ $DRYRUN = 0 ]; then
847        if [ ! -f ${1} ] ; then
848            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
849            IGCM_debug_PopStack "IGCM_sys_Put_Out"
850            return 1
851        fi
852        #
853        IGCM_sys_MkdirArchive $( dirname $2 )
854        #
855        typeset RET
856        #
857        IGCM_sys_Chmod 444 ${1}
858        #
859        # USUAL WAY
860        putfer $1 $2 > out_rsync 2>&1
861        RET=$?
862
863#       #RSYNC WITH NETWORK RSH CALL
864#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
865#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
866
867#       #RSYNC WITH NFS USE
868#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
869#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
870
871#       RET=$?
872#       IGCM_sys_Rsync_out $RET
873
874#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
875#       (( RET=RET+$? ))
876
877        if [ ${RET} -gt 0 ] ; then
878            echo "IGCM_sys_Put_Out : error."
879            cat out_rsync
880            IGCM_debug_Exit "IGCM_sys_Put_Out"
881        fi
882    else
883        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
884    fi
885    IGCM_debug_PopStack "IGCM_sys_Put_Out"
886    return 0
887}
888
889#D-#==================================================
890#D-function IGCM_sys_Get
891#D-* Purpose: Get a file from ${ARCHIVE}
892#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
893#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
894function IGCM_sys_Get {
895    IGCM_debug_PushStack "IGCM_sys_Get" $@
896
897    typeset DEST RET dm_liste ifile target file_work
898
899    if ( $DEBUG_sys ) ; then
900        echo "IGCM_sys_Get :" $@
901    fi
902    if [ $DRYRUN -le 2 ]; then
903        if [ X${1} = X'/l' ] ; then
904            # test if the first file is present in the old computation :
905            eval set +A dm_liste \${${2}}
906        else
907            eval set +A dm_liste ${1}
908        fi
909        eval DEST=\${${#}}
910
911        #=====================================================
912        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
913        #=====================================================
914
915        # Is it an R_OUT file (not R_IN) ?
916        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
917        #if [ $? -eq 0 ] ; then
918        #    # Yes  ? then we try to get it in SCRATCHDIR
919        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
920        #    if [ -f ${file_work[0]} ] ; then
921        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
922        #       IGCM_debug_PopStack "IGCM_sys_Get"
923        #       return
924        #    fi
925        #fi
926
927        # test if the (first) file is present in the old computation :
928        IGCM_sys_TestFileArchive ${dm_liste[0]}
929        RET=$?
930        if [ ${RET} -gt 0 ] ; then
931            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
932            IGCM_debug_Exit "IGCM_sys_Get"
933            IGCM_debug_PopStack "IGCM_sys_Get"
934            return
935        fi
936
937        dmget ${dm_liste[*]} > out_rsync 2>&1
938        RET=$?
939        if [ ${RET} -gt 0 ] ; then
940            echo "IGCM_sys_Get : demigration error."
941            cat out_rsync
942            IGCM_debug_Exit "IGCM_sys_Get"
943            IGCM_debug_PopStack "IGCM_sys_Get"
944            return
945        fi
946
947        #USUAL WAY
948        (( RET=0 ))
949        if [ X${1} = X'/l' ] ; then
950            (( RET=0 ))
951            for target in ${dm_liste[*]} ; do
952                local_file=$( basename ${target} )
953                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
954                (( RET = RET + $? ))
955            done
956        else
957            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
958            RET=$?
959        fi
960
961#       #RSYNC WITH NETWORK RSH CALL
962#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
963#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
964
965#       #RSYNC WITH NFS USE
966#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
967#       ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
968
969#       RET=$?
970#       IGCM_sys_Rsync_out $RET
971
972#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
973#       (( RET=RET+$? ))
974
975        if [ ${RET} -gt 0 ] ; then
976            echo "IGCM_sys_Get : copy error."
977            cat out_rsync
978            IGCM_debug_Exit "IGCM_sys_Get"
979        fi
980    else
981        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
982    fi
983    IGCM_debug_PopStack "IGCM_sys_Get"
984}
985
986#D-#==================================================
987#D-function IGCM_sys_Put_Dods
988#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
989#D-* Examples:
990#D-
991function IGCM_sys_Put_Dods {
992    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
993    if ( $DEBUG_sys ) ; then
994        echo "IGCM_sys_Put_Dods :" $@
995    fi
996    if [ $DRYRUN = 0 ]; then
997        if [ ! -d ${R_SAVE}/${1} ] ; then
998            echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
999            IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1000            return
1001        fi
1002
1003        typeset RET
1004        #
1005        cd ${R_SAVE}
1006        dods_rm public/${LOGIN}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/${1} > /dev/null 2>&1
1007        #/bin/chmod -R u+w  ${R_SAVE}/${1}
1008        dods_cp ${1} public/${LOGIN}/${config_UserChoices_TagName}/${config_UserChoices_JobName} > /dev/null 2>&1
1009        #/bin/chmod -R +rX ${R_SAVE}/${1}
1010        #/bin/chmod -R a+rX /dmnfs/cont003/dods/public/${LOGIN}/${config_UserChoices_TagName}
1011        #RET=$?
1012        RET=0
1013
1014        if [ ${RET} -gt 0 ] ; then
1015            echo "IGCM_sys_Put_Dods : error."
1016            IGCM_debug_Exit "IGCM_sys_Put_Dods"
1017        fi
1018    else
1019        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1020    fi
1021    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1022}
1023
1024#D-#==================================================
1025#D-function IGCM_sys_Rapatrie
1026#D-* Purpose: Rapatrie
1027#D-* Examples:
1028#D-
1029function IGCM_sys_Rapatrie {
1030    IGCM_debug_PushStack "IGCM_sys_Rapatrie" $@
1031    if ( $DEBUG_sys ) ; then
1032        echo "IGCM_sys_Rapatrie :" $@
1033    fi
1034
1035    typeset RET=0
1036
1037    IGCM_sys_Get ${R_STOCKAGE}/$2 $1 ;
1038    let $(( RET=RET+$? ))
1039    IGCM_sys_Cd $1 ;
1040    let $(( RET=RET+$? ))
1041    IGCM_sys_UnTar $2 ;
1042    let $(( RET=RET+$? ))
1043
1044    if [ ${RET} -gt 0 ] ; then
1045        echo "IGCM_sys_Rapatrie : erreur."
1046        IGCM_debug_Exit "IGCM_sys_Rapatrie"
1047    fi
1048    IGCM_debug_PopStack "IGCM_sys_Rapatrie"
1049}
1050
1051############################################################## A FINIR !!
1052
1053#D-#==================================================
1054#D-function IGCM_sys_GetDate_FichWork
1055#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1056#D-* Examples:
1057#D-
1058function IGCM_sys_GetDate_FichWork {
1059    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1060    if ( $DEBUG_sys ) ; then
1061        echo "IGCM_sys_GetDate_FichWork :" $@
1062    fi
1063    # donne la date filesys d'un fichier sur la machine work
1064    IGCM_debug_PopStack "IGCM_sys_FichWork"
1065}
1066
1067#D-#==================================================
1068#D-function IGCM_sys_GetDate_FichArchive
1069#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1070#D-* Examples:
1071#D-
1072function IGCM_sys_GetDate_FichArchive {
1073    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1074    if ( $DEBUG_sys ) ; then
1075        echo "IGCM_sys_GetDate_FichArchive :" $@
1076    fi
1077    IGCM_debug_PopStack "IGCM_sys_FichArchive"
1078}
1079
1080##############################################################
1081# NCO OPERATOR
1082
1083function IGCM_sys_ncap {
1084    IGCM_debug_PushStack "IGCM_sys_ncap" -- $@
1085    if ( $DEBUG_sys ) ; then
1086        echo "IGCM_sys_ncap :" $@
1087    fi
1088    /applications/nco/bin/ncap $@
1089    if [ $? -gt 0 ] ; then
1090       echo "IGCM_sys_ncap : erreur ${@}."
1091#       IGCM_debug_Exit "ncap"
1092    fi
1093
1094    IGCM_debug_PopStack "IGCM_sys_ncap"
1095}
1096
1097ncatted=/applications/nco/bin/ncatted
1098# Problem with ksh and string passed in this function to ncatted !
1099# function IGCM_sys_ncatted {
1100#     IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1101#     if ( $DEBUG_sys ) ; then
1102#       echo "IGCM_sys_ncatted :" $@
1103#     fi
1104#     /usr/local/bin/ncatted $@
1105#     if [ $? -gt 0 ] ; then
1106#        echo "IGCM_sys_ncatted : erreur ${@}."
1107#        IGCM_debug_Exit "ncatted"
1108#     fi
1109
1110#     IGCM_debug_PopStack "IGCM_sys_ncatted"
1111# }
1112
1113function IGCM_sys_ncbo {
1114    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1115    if ( $DEBUG_sys ) ; then
1116        echo "IGCM_sys_ncbo :" $@
1117    fi
1118    /applications/nco/bin/ncbo $@
1119    if [ $? -gt 0 ] ; then
1120       echo "IGCM_sys_ncbo : erreur ${@}."
1121#       IGCM_debug_Exit "ncbo"
1122    fi
1123
1124    IGCM_debug_PopStack "IGCM_sys_ncbo"
1125}
1126
1127function IGCM_sys_ncdiff {
1128    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1129    if ( $DEBUG_sys ) ; then
1130        echo "IGCM_sys_ncdiff :" $@
1131    fi
1132    /applications/nco/bin/ncdiff $@
1133    if [ $? -gt 0 ] ; then
1134       echo "IGCM_sys_ncdiff : erreur ${@}."
1135#       IGCM_debug_Exit "ncdiff"
1136    fi
1137
1138    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1139}
1140
1141function IGCM_sys_ncea {
1142    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1143    if ( $DEBUG_sys ) ; then
1144        echo "IGCM_sys_ncea :" $@
1145    fi
1146    /applications/nco/bin/ncea $@
1147    if [ $? -gt 0 ] ; then
1148       echo "IGCM_sys_ncea : erreur ${@}."
1149#       IGCM_debug_Exit "ncea"
1150    fi
1151
1152    IGCM_debug_PopStack "IGCM_sys_ncea"
1153}
1154
1155function IGCM_sys_ncecat {
1156    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1157    if ( $DEBUG_sys ) ; then
1158        echo "IGCM_sys_ncecat :" $@
1159    fi
1160    /applications/nco/bin/ncecat $@
1161    if [ $? -gt 0 ] ; then
1162       echo "IGCM_sys_ncecat : erreur ${@}."
1163#       IGCM_debug_Exit "ncecat"
1164    fi
1165
1166    IGCM_debug_PopStack "IGCM_sys_ncecat"
1167}
1168
1169function IGCM_sys_ncflint {
1170    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1171    if ( $DEBUG_sys ) ; then
1172        echo "IGCM_sys_ncflint :" $@
1173    fi
1174    /usr/local/bin/ncflint $@
1175    if [ $? -gt 0 ] ; then
1176       echo "IGCM_sys_ncflint : erreur ${@}."
1177#       IGCM_debug_Exit "ncflint"
1178    fi
1179
1180    IGCM_debug_PopStack "IGCM_sys_ncflint"
1181}
1182
1183function IGCM_sys_ncks {
1184    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1185    if ( $DEBUG_sys ) ; then
1186        echo "IGCM_sys_ncks :" $@
1187    fi
1188    /applications/nco/bin/ncks $@
1189    if [ $? -gt 0 ] ; then
1190       echo "IGCM_sys_ncks : erreur ${@}."
1191#       IGCM_debug_Exit "ncks"
1192    fi
1193
1194    IGCM_debug_PopStack "IGCM_sys_ncks"
1195}
1196
1197function IGCM_sys_ncpdq {
1198    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1199    if ( $DEBUG_sys ) ; then
1200        echo "IGCM_sys_ncpdq :" $@
1201    fi
1202    /applications/nco/bin/ncpdq $@
1203    if [ $? -gt 0 ] ; then
1204       echo "IGCM_sys_ncpdq : erreur ${@}."
1205#       IGCM_debug_Exit "ncpdq"
1206    fi
1207
1208    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1209}
1210
1211function IGCM_sys_ncra {
1212    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1213    if ( $DEBUG_sys ) ; then
1214        echo "IGCM_sys_ncra :" $@
1215    fi
1216    /applications/nco/bin/ncra $@
1217    if [ $? -gt 0 ] ; then
1218       echo "IGCM_sys_ncra : erreur ${@}."
1219#       IGCM_debug_Exit "ncra"
1220    fi
1221
1222    IGCM_debug_PopStack "IGCM_sys_ncra"
1223}
1224
1225function IGCM_sys_ncrcat {
1226    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1227    if ( $DEBUG_sys ) ; then
1228        echo "IGCM_sys_ncrcat :" $@
1229    fi
1230    /applications/nco/bin/ncrcat $@
1231    if [ $? -gt 0 ] ; then
1232       echo "IGCM_sys_ncrcat : erreur ${@}."
1233#       IGCM_debug_Exit "ncrcat"
1234    fi
1235
1236    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1237}
1238
1239function IGCM_sys_ncrename {
1240    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1241    if ( $DEBUG_sys ) ; then
1242        echo "IGCM_sys_ncrename :" $@
1243    fi
1244    /applications/nco/bin/ncrename $@
1245    if [ $? -gt 0 ] ; then
1246       echo "IGCM_sys_ncrename : erreur ${@}."
1247#       IGCM_debug_Exit "ncrename"
1248    fi
1249
1250    IGCM_debug_PopStack "IGCM_sys_ncrename"
1251}
1252
1253function IGCM_sys_ncwa {
1254    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1255    if ( $DEBUG_sys ) ; then
1256        echo "IGCM_sys_ncwa :" $@
1257    fi
1258    /applications/nco/bin/ncwa $@
1259    if [ $? -gt 0 ] ; then
1260       echo "IGCM_sys_ncwa : erreur ${@}."
1261#       IGCM_debug_Exit "ncwa"
1262    fi
1263
1264    IGCM_debug_PopStack "IGCM_sys_ncwa"
1265}
1266
1267##############################################################
1268# REBUILD OPERATOR
1269
1270function IGCM_sys_rebuild {
1271    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1272    if ( $DEBUG_sys ) ; then
1273        echo "IGCM_sys_rebuild :" $@
1274    fi
1275    /home/cont003/p86ipsl/IA64/bin/rebuild -f -o $@
1276    if [ $? -gt 0 ] ; then
1277       echo "IGCM_sys_rebuild : erreur ${@}."
1278       IGCM_debug_Exit "rebuild"
1279    fi
1280
1281    IGCM_debug_PopStack "IGCM_sys_rebuild"
1282}
1283
1284############################################################
1285# Activate Running Environnment Variables
1286
1287function IGCM_sys_activ_variables {
1288    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1289    if ( $DEBUG_sys ) ; then
1290        echo "IGCM_sys_activ_variables"
1291    fi
1292    ulimit -s 2097152
1293    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1294}
1295
1296############################################################
1297# Desactivate Running Environnment Variables
1298
1299function IGCM_sys_desactiv_variables {
1300    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1301    if ( $DEBUG_sys ) ; then
1302        echo "IGCM_sys_desactiv_variables"
1303    fi
1304    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1305}
1306
1307############################################################
1308# Build run file
1309
1310function IGCM_sys_build_run_file {
1311    IGCM_debug_PushStack "IGCM_sys_build_run_file" $@
1312    if ( $DEBUG_sys ) ; then
1313        echo "IGCM_sys_build_run_file " $@
1314    fi
1315    if [ $1 = MPI1 ]; then
1316        (( nb_tot_m1 = $BATCH_NUM_PROC_TOT  - 1 ))
1317        cat <<EOF > run_file
1318#!/bin/bash
1319if [ \$SLURM_PROCID -eq 0 ]
1320  then ./oasis ;
1321elif ( [ \$SLURM_PROCID -ge 1 ] && [ \$SLURM_PROCID -lt ${nb_tot_m1} ] )
1322  then ./lmdz.x ;
1323else ./opa.xx ;
1324fi
1325EOF
1326        config_UserChoices_JobRunOptions='"-n ${BATCH_NUM_PROC_TOT}"'
1327        IGCM_sys_Chmod u+x run_file
1328    fi
1329    (( NUM_PROC_ATM = $BATCH_NUM_PROC_TOT - 2 ))
1330
1331    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1332 
1333}
Note: See TracBrowser for help on using the repository browser.