source: tags/libIGCM_v1_6/libIGCM_sys/libIGCM_sys_platine.ksh @ 566

Last change on this file since 566 was 288, checked in by mafoipsl, 14 years ago

Add SUBLIT_DIR in messgae snt at the end of each simulation. Complete messages in clean_month.

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

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

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

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

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

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

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

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