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

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