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

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