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

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