source: tags/libIGCM_v1_9/libIGCM_sys/libIGCM_sys_platine.ksh @ 1435

Last change on this file since 1435 was 345, checked in by mmaipsl, 14 years ago

I have forget a 'rm' command, sorry.

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