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

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