source: tags/libIGCM_v1_8-old/libIGCM_sys/libIGCM_sys_platine.ksh

Last change on this file was 305, checked in by brocksce, 14 years ago
  • Added cdo sys to libIGCM_sys_cesium
  • Made some cleaning and added a comment to indicate that .atlas_env_* file sources not only ferret/fast/atlas but also nco, cdo operators.
  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

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

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

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

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

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

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

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