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

Last change on this file since 173 was 173, checked in by mafoipsl, 15 years ago

Add DRYRUN capability in Sys_Mv for all systems supported.

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

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

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

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

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

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

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

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