source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercureTX.ksh @ 192

Last change on this file since 192 was 192, checked in by sdipsl, 15 years ago
  • Cesium will post-process SX9 simulation
  • Big clean in libIGCM_sys
  • Testing only for now
  • 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: 32.8 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 Mercure TX
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
72#D-
73#D-#==================================================
74#D-Program used in libIGCM
75#D-#==================================================
76
77# rsync with path
78typeset -r RSYNC=/usr/bin/rsync
79# RSYNC_opt args to rsync
80typeset -r RSYNC_opt="-va"
81# ie storage filesystem
82typeset -r RHOST=mercure
83
84#====================================================
85# Source Ferret
86. /home/cont003/p86ipsl/.atlas_env_mercure_ksh
87
88#====================================================
89# Specific for ocean additionnal diagnostic
90export FER_GO="$FER_GO /home/cont003/p86denv/IGCM_POST_UTIL/JNL /home/cont003/p86denv/GRAF /home/cont003/p86denv/GRAF/GO"
91export FER_PALETTE="$FER_PALETTE /home/cont003/p86denv/GRAF/PALET"
92
93#====================================================
94# Host specific DIRECTORIES
95#====================================================
96
97#====================================================
98#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
99typeset -r R_EXE="${MODIPSL}/bin"
100
101#====================================================
102# For interactive jobs on mercure
103PBS_O_WORKDIR=${PBS_O_WORKDIR:=$(pwd)}
104
105#====================================================
106#- SUBMIT_DIR : submission dir
107typeset SUBMIT_DIR=${SUBMIT_DIR:=${PBS_O_WORKDIR}}
108
109#====================================================
110#- ARCHIVE
111typeset -r ARCHIVE=${DMFDIR}
112
113#====================================================
114#- IN
115typeset -r R_IN=${R_IN:=/dmnfs/cont003/p86ipsl/IGCM}
116
117#====================================================
118#- OUT
119typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
120
121#====================================================
122#- OUT_SCR (ONLY FOR double copy an scratch)
123typeset -r R_OUT_SCR=${SCRATCHDIR}/IGCM_OUT
124
125#====================================================
126#- OUT_POST
127typeset -r R_OUT_POST=${SCRATCHDIR}/IGCM_OUT
128
129#====================================================
130#- RUN_DIR_PATH : Temporary working directory (=> TMP)
131typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${TMPDIR}}
132
133#====================================================
134#- Max number of arguments passed to nco operator or demigration command
135UNIX_MAX_LIMIT=360
136
137#D-#==================================================
138#D-function IGCM_sys_RshMaster
139#D-* Purpose: Just a fake command to wrapp
140#D-           IGCM_card call in post-treatment
141#D-           Ulam do not see brodie filesystem
142#D-           Cesium do not see all mercure filesystem
143#D-           That's why we need this hack.
144#D-* Examples:
145#D-
146function IGCM_sys_RshMaster {
147    #set -vx
148    IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
149    /bin/ksh <<-EOF
150    export libIGCM=${libIGCM}
151    export DEBUG_debug=${DEBUG_debug}
152    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
153    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
154    ${@}
155EOF
156    if [ $? -gt 0 ] ; then
157        echo "IGCM_sys_RshMaster : erreur."
158        IGCM_debug_Exit "IGCM_sys_RshMaster"
159    fi
160    IGCM_debug_PopStack "IGCM_sys_RshMaster"
161}
162
163#D-#==================================================
164#D-function IGCM_sys_RshArchive
165#D-* Purpose: Archive rsh command
166#D-* Examples:
167#D-
168function IGCM_sys_RshArchive {
169    IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
170    /bin/ksh <<-EOF
171    ${@}
172EOF
173    if [ $? -gt 0 ] ; then
174        echo "IGCM_sys_RshArchive : erreur."
175        IGCM_debug_Exit "IGCM_sys_RshArchive"
176    fi
177    IGCM_debug_PopStack "IGCM_sys_RshArchive"
178}
179
180#D-#==================================================
181#D-function IGCM_sys_RshPost
182#D-* Purpose: Master rsh command
183#D-* Examples:
184#D-
185function IGCM_sys_RshPost {
186    IGCM_debug_PushStack "IGCM_sys_RshPost" $@
187    if ( $DEBUG_sys ) ; then
188        echo "IGCM_sys_RshPost :" $@
189    fi
190    /bin/ksh ${@}
191    if [ $? -gt 0 ] ; then
192        echo "IGCM_sys_RshPost : erreur."
193        IGCM_debug_Exit "IGCM_sys_RshPost"
194    fi
195    IGCM_debug_PopStack "IGCM_sys_RshPost"
196}
197
198#D-#==================================================
199#D-function IGCM_sys_Mkdir
200#D-* Purpose: Master locale mkdir command
201#D-* Examples:
202#D-
203function IGCM_sys_Mkdir {
204    IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
205    if ( $DEBUG_sys ) ; then
206        echo "IGCM_sys_Mkdir :" $@
207    fi
208    if [ ! -d ${1} ]; then
209        \mkdir -p $1
210        if [ $? -gt 0 ] ; then
211            echo "IGCM_sys_Mkdir : erreur."
212            IGCM_debug_Exit "IGCM_sys_Mkdir"
213        fi
214    fi
215    # vérification :
216    if [ ! -d ${1} ] ; then
217        echo "IGCM_sys_Mkdir : erreur."
218        IGCM_debug_Exit "IGCM_sys_Mkdir"
219    fi
220    IGCM_debug_PopStack "IGCM_sys_Mkdir"
221}
222
223#D-#==================================================
224#D-function IGCM_sys_MkdirArchive
225#D-* Purpose: Mkdir on Archive
226#D-* Examples:
227#D-
228function IGCM_sys_MkdirArchive {
229    IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
230    if ( $DEBUG_sys ) ; then
231        echo "IGCM_sys_MkdirArchive :" $@
232    fi
233    #- creation de repertoire sur le serveur fichier
234    if [ ! -d ${1} ]; then 
235        \mkdir -p $1
236        if [ $? -gt 0 ] ; then
237            echo "IGCM_sys_MkdirArchive : erreur."
238            IGCM_debug_Exit "IGCM_sys_MkdirArchive"
239        fi
240    fi
241    IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
242}
243
244#D-#==================================================
245#D-function IGCM_sys_MkdirWork
246#D-* Purpose: Mkdir on Work
247#D-* Examples:
248#D-
249function IGCM_sys_MkdirWork {
250    IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
251    if ( $DEBUG_sys ) ; then
252        echo "IGCM_sys_MkdirWork :" $@
253    fi
254    #- creation de repertoire sur le serveur fichier
255    if [ ! -d ${1} ]; then 
256        \mkdir -p $1
257        if [ $? -gt 0 ] ; then
258            echo "IGCM_sys_MkdirWork : erreur."
259            IGCM_debug_Exit "IGCM_sys_MkdirWork"
260        fi
261    fi
262    IGCM_debug_PopStack "IGCM_sys_MkdirWork"
263}
264
265#D-#==================================================
266#D-function IGCM_sys_Cd
267#D-* Purpose: master cd command
268#D-* Examples:
269#D-
270function IGCM_sys_Cd {
271    IGCM_debug_PushStack "IGCM_sys_Cd" $@
272    if ( $DEBUG_sys ) ; then
273        echo "IGCM_sys_Cd :" $@
274    fi
275    \cd $1
276    if [ $? -gt 0 ] ; then
277        echo "IGCM_sys_Cd : erreur."
278        IGCM_debug_Exit "IGCM_sys_Cd"
279    fi
280    IGCM_debug_PopStack "IGCM_sys_Cd"
281}
282
283#D-#==================================================
284#D-function IGCM_sys_Chmod
285#D-* Purpose: Chmod
286#D-* Examples:
287#D-
288function IGCM_sys_Chmod {
289    IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
290    if ( $DEBUG_sys ) ; then
291        echo "IGCM_sys_Chmod :" $@
292    fi
293    if [ $DRYRUN -le 1 ]; then
294        \chmod $@
295        if [ $? -gt 0 ] ; then
296            echo "IGCM_sys_Chmod : erreur."
297            IGCM_debug_Exit "IGCM_sys_Chmod"
298        fi
299    else
300        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
301    fi
302    IGCM_debug_PopStack "IGCM_sys_Chmod"
303}
304
305#D-#==================================================
306#D-function IGCM_sys_FileSize
307#D-* Purpose: Filesize
308#D-* Examples:
309#D-
310function IGCM_sys_FileSize {
311    IGCM_debug_PushStack "IGCM_sys_FileSize" $@
312
313    typeset sizeF
314    set +A sizeF -- $( ls -la ${1} )
315    if [ $? -gt 0 ] ; then
316        IGCM_debug_Exit "IGCM_sys_FileSize"
317    fi
318    eval ${2}=${sizeF[4]}
319
320    IGCM_debug_PopStack "IGCM_sys_FileSize"
321}
322
323#D-#==================================================
324#D-function IGCM_sys_TestDir
325#D-* Purpose: Test Directory that must exists
326#D-* Examples:
327#D-
328function IGCM_sys_TestDir {
329    IGCM_debug_PushStack "IGCM_sys_TestDir" $@
330    if ( $DEBUG_sys ) ; then
331        echo "IGCM_sys_TestDir :" $@
332    fi
333    typeset ExistFlag
334    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
335    IGCM_debug_PopStack "IGCM_sys_TestDir"
336
337    return ${ExistFlag}
338}
339
340#D-#==================================================
341#D-function IGCM_sys_TestDirArchive
342#D-* Purpose: Test Directory that must exists on Archive
343#D-* Examples:
344#D-
345function IGCM_sys_TestDirArchive {
346    IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
347    if ( $DEBUG_sys ) ; then
348        echo "IGCM_sys_TestDirArchive :" $@
349    fi
350    typeset ExistFlag
351    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
352    IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
353
354    return ${ExistFlag}
355}
356
357#D-#==================================================
358#D-function IGCM_sys_TestFileArchive
359#D-* Purpose: Test file that must NOT EXISTS on Archive
360#D-* Examples:
361#D-
362function IGCM_sys_TestFileArchive {
363    IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
364    if ( $DEBUG_sys ) ; then
365        echo "IGCM_sys_TestFileArchive :" $@
366    fi
367    typeset ExistFlag
368    ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
369    IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
370
371    return ${ExistFlag}
372}
373
374#D-#==================================================
375#D-function IGCM_sys_CountFileArchive
376#D-* Purpose: Count files on Archive filesystem
377#D-* Examples:
378#D-
379function IGCM_sys_CountFileArchive {
380    IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
381    ls ${@} 2>/dev/null | wc -l
382    if [ $? -gt 0 ] ; then
383        echo "IGCM_sys_CountFileArchive : erreur."
384    fi
385    IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
386}
387
388#D-#==================================================
389#D-function IGCM_sys_Tree
390#D-* Purpose: Tree directories with files on ${ARCHIVE}
391#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
392#D-
393function IGCM_sys_Tree {
394    IGCM_debug_PushStack "IGCM_sys_Tree" $@
395    if ( $DEBUG_sys ) ; then
396        echo "IGCM_sys_Tree :" $@
397    fi
398
399    \tree -f $@
400
401    IGCM_debug_PopStack "IGCM_sys_Tree"
402}
403
404#D-#==================================================
405#D-function IGCM_sys_Tar
406#D-* Purpose: master un-tar command
407#D-* Examples:
408#D-
409function IGCM_sys_Tar {
410    IGCM_debug_PushStack "IGCM_sys_Tar" $@
411    if ( $DEBUG_sys ) ; then
412        echo "IGCM_sys_Tar :" $@
413    fi
414    \tar cvf $@
415    if [ $? -gt 0 ] ; then
416        echo "IGCM_sys_Tar : erreur."
417        IGCM_debug_Exit "IGCM_sys_Tar"
418    fi
419    \tar tvf $1
420
421    IGCM_debug_PopStack "IGCM_sys_Tar"
422}
423
424#D-#==================================================
425#D-function IGCM_sys_UnTar
426#D-* Purpose: master un-tar command
427#D-* Examples:
428#D-
429function IGCM_sys_UnTar {
430    IGCM_debug_PushStack "IGCM_sys_UnTar" $@
431    if ( $DEBUG_sys ) ; then
432        echo "IGCM_sys_UnTar :" $@
433    fi
434    \tar xvf $1
435    if [ $? -gt 0 ] ; then
436        echo "IGCM_sys_UnTar : erreur."
437        IGCM_debug_Exit "IGCM_sys_UnTar"
438    fi
439    IGCM_debug_PopStack "IGCM_sys_UnTar"
440}
441
442#D-#==================================================
443#D-function IGCM_sys_QsubPost
444#D-* Purpose: Qsub new job on scalaire
445#D-* Examples:
446#D-
447function IGCM_sys_QsubPost {
448    IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
449    if ( $DEBUG_sys ) ; then
450        echo "IGCM_sys_QsubPost :" $@
451    fi
452    /usr/bin/nqsII/qsub -q scalaire -o ${POST_DIR}/$1.${PeriodDateEnd}.${TsTask}.${CompToRead}.${FlagToRead}.out ${libIGCM}/$1.job -v ${listVarEnv}
453    if [ $? -gt 0 ] ; then
454        echo "IGCM_sys_QsubPost : erreur " $@
455        IGCM_debug_Exit "IGCM_sys_QsubPost"
456    fi
457    IGCM_debug_PopStack "IGCM_sys_QsubPost"
458}
459
460#D-*************************
461#D- File transfer functions
462#D-*************************
463#D-
464
465#D-#==================================================
466#D-function IGCM_sys_Rsync_out
467#D-* Purpose: treat return val of rsync
468#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
469#D-  Error values and explanations can depend on your system version.
470function IGCM_sys_Rsync_out {
471    RET=$1
472    if [ ! $RET ] ; then
473        echo "rsync error !"
474    fi
475
476    if [ $MYLANG = "fr" ]; then
477        case $RET in
478            0)  return ;;
479            1)  echo "Erreur de rsync ; RERR_SYNTAX : "
480                echo "Erreur de syntaxe ou d'utilisation."
481                return;;
482            2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
483                echo "Incompatibilité de protocole."
484                return;;
485            3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
486                echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
487                echo "répertoires"
488                return;;
489            4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
490                echo "Action demandée non supportée : une tentative de manipulation de"
491                echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
492                echo "été faite ; ou une option qui est supportée par le  client  mais"
493                echo "pas par le serveur a été spécifiée."
494                return;;
495            10) echo "Erreur de rsync ; RERR_SOCKETIO"
496                echo "Erreur dans le socket d'entrée sortie"
497                return;;
498            11) echo "Erreur de rsync ; RERR_FILEIO"
499                echo "Erreur d'entrée sortie fichier"
500                return;;
501            12) echo "Erreur de rsync ; RERR_STREAMIO"
502                echo "Erreur dans flux de donnée du protocole rsync"
503                return;;
504            13) echo "Erreur de rsync ; RERR_MESSAGEIO"
505                echo "Erreur avec les diagnostics du programme"
506                return;;
507            14) echo "Erreur de rsync ; RERR_IPC"
508                echo "Erreur dans le code IPC"
509                return;;
510            20) echo "Erreur de rsync ; RERR_SIGNAL"
511                echo "SIGUSR1 ou SIGINT reçu"
512                return;;
513            21) echo "Erreur de rsync ; RERR_WAITCHILD"
514                echo "Une erreur retournée par waitpid()"
515                return;;
516            22) echo "Erreur de rsync ; RERR_MALLOC"
517                echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
518                return;;
519            23) echo ""
520                echo "Erreur fichier inexistant"
521                return;;
522            30) echo "Erreur de rsync ; RERR_TIMEOUT"
523                echo "Temps d'attente écoulé dans l'envoi/réception de données"
524                return;;
525            *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
526                return;;
527        esac
528    elif [ $MYLANG = "en" ] ; then
529        case $RET in
530            0)  return;;               
531            1)  echo "rsync error : Syntax or usage error "
532                return;;
533            2)  echo "rsync error : Protocol incompatibility "
534                return;;
535            3)  echo "rsync error : Errors selecting input/output files, dirs"
536                return;;
537            4)  echo "rsync error : Requested action not supported: an attempt"
538                echo "was made to manipulate 64-bit files on a platform that cannot support"
539                echo "them; or an option was specified that is supported by the client and"
540                echo "not by the server."
541                return;;
542            5)  echo "rsync error : Error starting client-server protocol"
543                return;;
544            10) echo "rsync error : Error in socket I/O "
545                return;;
546            11) echo "rsync error : Error in file I/O "
547                return;;
548            12) echo "rsync error : Error in rsync protocol data stream "
549                return;;
550            13) echo "rsync error : Errors with program diagnostics "
551                return;;
552            14) echo "rsync error : Error in IPC code "
553                return;;
554            20) echo "rsync error : Received SIGUSR1 or SIGINT "
555                return;;
556            21) echo "rsync error : Some error returned by waitpid() "
557                return;;
558            22) echo "rsync error : Error allocating core memory buffers "
559                return;;
560            23) echo "rsync error : Partial transfer due to error"
561                return;;
562            24) echo "rsync error : Partial transfer due to vanished source files"
563                return;;
564            30) echo "rsync error : Timeout in data send/receive "
565                return;;
566            *)  echo "rsync error : return code of rsync unknown :" $RET
567                return;;
568        esac
569    else
570        echo "unknown language $MYLANG."
571        return
572    fi
573}
574   
575#D-#==================================================
576#D-function IGCM_sys_Cp
577#D-* Purpose: generic cp
578#D-* Examples:
579#D-
580function IGCM_sys_Cp {
581    IGCM_debug_PushStack "IGCM_sys_Cp" $@
582    if ( $DEBUG_sys ) ; then
583        echo "IGCM_sys_Cp :" $@
584    fi
585
586    typeset RET
587
588    echo cp $@ > out_rsync 2>&1
589    \cp $@ >> out_rsync 2>&1
590    RET=$?
591
592    if [ ${RET} -gt 0 ] ; then
593        echo "IGCM_sys_Cp : error."
594        cat out_rsync
595        IGCM_debug_Exit "IGCM_sys_Cp"
596    fi
597    IGCM_debug_PopStack "IGCM_sys_Cp"
598}
599
600#D-#==================================================
601#D-function IGCM_sys_Rm
602#D-* Purpose: generic rm
603#D-* Examples:
604#D-
605function IGCM_sys_Rm {
606    IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
607    if ( $DEBUG_sys ) ; then
608        echo "IGCM_sys_Rm :" $@
609    fi
610
611    typeset RET
612
613    echo rm $@ > out_rsync 2>&1
614    \rm $@ >> out_rsync 2>&1
615    RET=$?
616
617    if [ ${RET} -gt 0 ] ; then
618        echo "IGCM_sys_Rm : error."
619        cat out_rsync
620        IGCM_debug_Exit "IGCM_sys_Rm"
621    fi
622    IGCM_debug_PopStack "IGCM_sys_Rm"
623}
624
625#D-#==================================================
626#D-function IGCM_sys_Mv
627#D-* Purpose: generic move
628#D-* Examples:
629#D-
630function IGCM_sys_Mv {
631    IGCM_debug_PushStack "IGCM_sys_Mv" $@
632    if ( $DEBUG_sys ) ; then
633        echo "IGCM_sys_Mv :" $@
634    fi
635
636    if [ $DRYRUN = 0 ]; then
637
638        typeset RET
639           
640        echo mv $@ > out_rsync 2>&1
641        \mv $@ >> out_rsync 2>&1
642        RET=$?
643   
644        if [ ${RET} -gt 0 ] ; then
645            echo "IGCM_sys_Mv : error in mv."
646            cat out_rsync
647            IGCM_debug_Exit "IGCM_sys_Mv"
648        fi
649    else
650        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
651    fi
652
653    IGCM_debug_PopStack "IGCM_sys_Mv"
654}
655
656#D-#==================================================
657#D-function IGCM_sys_Put_Dir
658#D-* Purpose: Copy a complete directory on $(ARCHIVE)
659#D-* Examples:
660#D-
661function IGCM_sys_Put_Dir {
662    IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
663    if ( $DEBUG_sys ) ; then
664        echo "IGCM_sys_Put_Dir :" $@
665    fi
666    if [ $DRYRUN = 0 ]; then
667        if [ ! -d ${1} ] ; then
668            echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
669            IGCM_debug_PopStack "IGCM_sys_Put_Dir"
670            return
671        fi
672
673        typeset RET
674
675        # Only if we use rsync
676        #IGCM_sys_TestDirArchive $( dirname $2 )
677        #
678        #USUAL WAY
679        \cp -r $1 $2 > out_rsync 2>&1
680        RET=$?
681
682        if [ ${RET} -gt 0 ] ; then
683            echo "IGCM_sys_Put_Dir : error."
684            cat out_rsync
685            IGCM_debug_Exit "IGCM_sys_Put_Dir"
686        fi
687    else
688        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
689    fi
690    IGCM_debug_PopStack "IGCM_sys_Put_Dir"
691}
692
693#D-#==================================================
694#D-function IGCM_sys_Get_Dir
695#D-* Purpose: Copy a complete directory from $(ARCHIVE)
696#D-* Examples:
697#D-
698function IGCM_sys_Get_Dir {
699    IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
700    if ( $DEBUG_sys ) ; then
701        echo "IGCM_sys_Get_Dir :" $@
702    fi
703    if [ $DRYRUN = 0 ]; then
704#       if [ ! -d ${1} ] ; then
705#           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
706#           IGCM_debug_PopStack "IGCM_sys_Get_Dir"
707#           return
708#       fi
709
710        typeset RET
711
712        # Only if we use rsync
713        #IGCM_sys_TestDirArchive $( dirname $2 )
714        #
715        #USUAL WAY
716        \cp -r $1 $2 > out_rsync 2>&1
717        RET=$?
718
719        if [ ${RET} -gt 0 ] ; then
720            echo "IGCM_sys_Get_Dir : error."
721            cat out_rsync
722            IGCM_debug_Exit "IGCM_sys_Get_Dir"
723        fi
724    else
725        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
726    fi
727    IGCM_debug_PopStack "IGCM_sys_Get_Dir"
728}
729
730#D-#==================================================
731#D-function IGCM_sys_Get_Master
732#D-* Purpose: Copy a complete directory from MASTER filesystem
733#D-* Examples:
734#D-
735function IGCM_sys_Get_Master {
736    IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
737    if ( $DEBUG_sys ) ; then
738        echo "IGCM_sys_Get_Master :" $@
739    fi
740    if [ $DRYRUN = 0 ]; then
741        if [ ! -d ${1} ] ; then
742            echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
743            IGCM_debug_PopStack "IGCM_sys_Get_Master"
744            return
745        fi
746
747        typeset RET
748        sleep 60
749
750        #USUAL WAY
751        \cp -r $1 $2 > out_rsync 2>&1
752        RET=$?
753
754        if [ ${RET} -gt 0 ] ; then
755            echo "IGCM_sys_Get_Master : error."
756            cat out_rsync
757            IGCM_debug_Exit "IGCM_sys_Get_Master"
758        fi
759    else
760        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
761    fi
762    IGCM_debug_PopStack "IGCM_sys_Get_Master"
763}
764
765#D-#==================================================
766#D-function IGCM_sys_Put_Out
767#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
768#D-* Examples:
769#D-
770function IGCM_sys_Put_Out {
771    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
772    if ( $DEBUG_sys ) ; then
773        echo "IGCM_sys_Put_Out :" $@
774    fi
775    if [ $DRYRUN = 0 ]; then
776        if [ ! -f ${1} ] ; then
777            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
778            IGCM_debug_PopStack "IGCM_sys_Put_Out"
779            return 1
780        fi
781        #
782        IGCM_sys_MkdirArchive $( dirname $2 )
783        #
784        typeset RET
785        #
786        if [ X${JobType} = XRUN ] ; then
787            IGCM_sys_Chmod 444 ${1}
788        fi
789        #
790        # USUAL WAY
791        putfer $1 $2 > out_rsync 2>&1
792        RET=$?
793
794#       #RSYNC WITH NETWORK RSH CALL
795#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
796#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
797
798#       #RSYNC WITH NFS USE
799#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
800#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
801
802#       RET=$?
803#       IGCM_sys_Rsync_out $RET
804
805#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
806#       (( RET=RET+$? ))
807
808        if [ ${RET} -gt 0 ] ; then
809            echo "IGCM_sys_Put_Out : error."
810            cat out_rsync
811            IGCM_debug_Exit "IGCM_sys_Put_Out"
812        fi
813    else
814        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
815    fi
816    IGCM_debug_PopStack "IGCM_sys_Put_Out"
817    return 0
818}
819
820#D-#==================================================
821#D-function IGCM_sys_Get
822#D-* Purpose: Get a file from ${ARCHIVE}
823#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
824#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
825function IGCM_sys_Get {
826    IGCM_debug_PushStack "IGCM_sys_Get" $@
827
828    typeset DEST RET dm_liste ifile target file_work
829
830    if ( $DEBUG_sys ) ; then
831        echo "IGCM_sys_Get :" $@
832    fi
833    if [ $DRYRUN -le 2 ]; then
834        if [ X${1} = X'/l' ] ; then
835            # test if the first file is present in the old computation :
836            eval set +A dm_liste \${${2}}
837        else
838            eval set +A dm_liste ${1}
839        fi
840        eval DEST=\${${#}}
841
842        #=====================================================
843        #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
844        #=====================================================
845
846        # Is it an R_OUT file (not R_IN) ?
847        #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
848        #if [ $? -eq 0 ] ; then
849        #    # Yes  ? then we try to get it in SCRATCHDIR
850        #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_OUT_SCR}|g" )
851        #    if [ -f ${file_work[0]} ] ; then
852        #       IGCM_sys_Cp ${file_work[*]} ${DEST}
853        #       IGCM_debug_PopStack "IGCM_sys_Get"
854        #       return
855        #    fi
856        #fi
857
858        # test if the (first) file is present in the old computation :
859        IGCM_sys_TestFileArchive ${dm_liste[0]}
860        RET=$?
861        if [ ${RET} -gt 0 ] ; then
862            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
863            IGCM_debug_Exit "IGCM_sys_Get"
864            #IGCM_debug_PopStack "IGCM_sys_Get"
865            #return
866        fi
867
868        dmget ${dm_liste[*]} > out_rsync 2>&1
869        RET=$?
870        if [ ${RET} -gt 0 ] ; then
871            echo "WARNING IGCM_sys_Get : demigration error."
872            cat out_rsync
873            #IGCM_debug_Exit "IGCM_sys_Get"
874            #IGCM_debug_PopStack "IGCM_sys_Get"
875            #return
876        fi
877
878        #USUAL WAY
879        (( RET=0 ))
880        if [ X${1} = X'/l' ] ; then
881            (( RET=0 ))
882            for target in ${dm_liste[*]} ; do
883                local_file=$( basename ${target} )
884                \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
885                (( RET = RET + $? ))
886            done
887        else
888            \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
889            RET=$?
890        fi
891
892#       #RSYNC WITH NETWORK RSH CALL
893#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
894#       ${RSYNC} ${RSYNC_opt} -e ssh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
895
896#       #RSYNC WITH NFS USE
897#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
898#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
899
900#       RET=$?
901#       IGCM_sys_Rsync_out $RET
902
903#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
904#       (( RET=RET+$? ))
905
906    else
907        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
908    fi
909    IGCM_debug_PopStack "IGCM_sys_Get"
910}
911
912#D-#==================================================
913#D-function IGCM_sys_Put_Dods
914#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
915#D-* Examples:
916#D-
917function IGCM_sys_Put_Dods {
918    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
919    if ( $DEBUG_sys ) ; then
920        echo "IGCM_sys_Put_Dods :" $@
921    fi
922    if [ $DRYRUN = 0 ]; then
923        if [ ! -d ${R_SAVE}/${1} ] ; then
924            echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
925            IGCM_debug_PopStack "IGCM_sys_Put_Dods"
926            return
927        fi
928
929        typeset RET
930        #
931        cd ${R_SAVE}
932        dods_rm public/${LOGIN}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/${1} > /dev/null 2>&1
933        #/bin/chmod -R u+w  ${R_SAVE}/${1}
934        dods_cp ${1} public/${LOGIN}/${config_UserChoices_TagName}/${config_UserChoices_JobName} > /dev/null 2>&1
935        #/bin/chmod -R +rX ${R_SAVE}/${1}
936        #/bin/chmod -R a+rX /dmnfs/cont003/dods/public/${LOGIN}/${config_UserChoices_TagName}
937        #RET=$?
938        RET=0
939       
940        if [ ${RET} -gt 0 ] ; then
941            echo "IGCM_sys_Put_Dods : error."
942            IGCM_debug_Exit "IGCM_sys_Put_Dods"
943        fi
944    else
945        ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
946    fi
947    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
948}
949
950############################################################## A FINIR !!
951
952#D-#==================================================
953#D-function IGCM_sys_GetDate_FichWork
954#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
955#D-* Examples:
956#D-
957function IGCM_sys_GetDate_FichWork {
958    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
959    if ( $DEBUG_sys ) ; then
960        echo "IGCM_sys_GetDate_FichWork :" $@
961    fi
962    # donne la date filesys d'un fichier sur la machine work
963    IGCM_debug_PopStack "IGCM_sys_FichWork"
964}
965
966#D-#==================================================
967#D-function IGCM_sys_GetDate_FichArchive
968#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
969#D-* Examples:
970#D-
971function IGCM_sys_GetDate_FichArchive {
972    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
973    if ( $DEBUG_sys ) ; then
974        echo "IGCM_sys_GetDate_FichArchive :" $@
975    fi
976    IGCM_debug_PopStack "IGCM_sys_FichArchive"
977}
978
979##############################################################
980# REBUILD OPERATOR
981
982function IGCM_sys_rebuild {
983    IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
984    if ( $DEBUG_sys ) ; then
985        echo "IGCM_sys_rebuild :" $@
986    fi
987    /home/cont003/p86ipsl/TX7/bin/rebuild -f -o $@
988    if [ $? -gt 0 ] ; then
989       echo "IGCM_sys_rebuild : erreur ${@}."
990       IGCM_debug_Exit "rebuild"
991    fi
992
993    IGCM_debug_PopStack "IGCM_sys_rebuild"
994}
995
996##############################################################
997# NCO OPERATOR
998
999function IGCM_sys_ncap {
1000    IGCM_debug_PushStack "IGCM_sys_ncap" -- $@
1001    if ( $DEBUG_sys ) ; then
1002        echo "IGCM_sys_ncap :" $@
1003    fi
1004    ncap $@
1005    if [ $? -gt 0 ] ; then
1006       echo "IGCM_sys_ncap : erreur ${@}."
1007#       IGCM_debug_Exit "ncap"
1008    fi
1009
1010    IGCM_debug_PopStack "IGCM_sys_ncap"
1011}
1012
1013ncatted=ncatted
1014# Problem with ksh and string passed in this function to ncatted !
1015# function IGCM_sys_ncatted {
1016#     IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
1017#     if ( $DEBUG_sys ) ; then
1018#       echo "IGCM_sys_ncatted :" $@
1019#     fi
1020#     ncatted $@
1021#     if [ $? -gt 0 ] ; then
1022#        echo "IGCM_sys_ncatted : erreur ${@}."
1023#        IGCM_debug_Exit "ncatted"
1024#     fi
1025
1026#     IGCM_debug_PopStack "IGCM_sys_ncatted"
1027# }
1028
1029function IGCM_sys_ncbo {
1030    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
1031    if ( $DEBUG_sys ) ; then
1032        echo "IGCM_sys_ncbo :" $@
1033    fi
1034    ncbo $@
1035    if [ $? -gt 0 ] ; then
1036       echo "IGCM_sys_ncbo : erreur ${@}."
1037#       IGCM_debug_Exit "ncbo"
1038    fi
1039
1040    IGCM_debug_PopStack "IGCM_sys_ncbo"
1041}
1042
1043function IGCM_sys_ncdiff {
1044    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1045    if ( $DEBUG_sys ) ; then
1046        echo "IGCM_sys_ncdiff :" $@
1047    fi
1048    ncdiff $@
1049    if [ $? -gt 0 ] ; then
1050       echo "IGCM_sys_ncdiff : erreur ${@}."
1051#       IGCM_debug_Exit "ncdiff"
1052    fi
1053
1054    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1055}
1056
1057function IGCM_sys_ncea {
1058    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1059    if ( $DEBUG_sys ) ; then
1060        echo "IGCM_sys_ncea :" $@
1061    fi
1062    ncea $@
1063    if [ $? -gt 0 ] ; then
1064       echo "IGCM_sys_ncea : erreur ${@}."
1065#       IGCM_debug_Exit "ncea"
1066    fi
1067
1068    IGCM_debug_PopStack "IGCM_sys_ncea"
1069}
1070
1071function IGCM_sys_ncecat {
1072    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1073    if ( $DEBUG_sys ) ; then
1074        echo "IGCM_sys_ncecat :" $@
1075    fi
1076    ncecat $@
1077    if [ $? -gt 0 ] ; then
1078       echo "IGCM_sys_ncecat : erreur ${@}."
1079#       IGCM_debug_Exit "ncecat"
1080    fi
1081
1082    IGCM_debug_PopStack "IGCM_sys_ncecat"
1083}
1084
1085function IGCM_sys_ncflint {
1086    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1087    if ( $DEBUG_sys ) ; then
1088        echo "IGCM_sys_ncflint :" $@
1089    fi
1090    ncflint $@
1091    if [ $? -gt 0 ] ; then
1092       echo "IGCM_sys_ncflint : erreur ${@}."
1093#       IGCM_debug_Exit "ncflint"
1094    fi
1095
1096    IGCM_debug_PopStack "IGCM_sys_ncflint"
1097}
1098
1099function IGCM_sys_ncks {
1100    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1101    if ( $DEBUG_sys ) ; then
1102        echo "IGCM_sys_ncks :" $@
1103    fi
1104    ncks $@
1105    if [ $? -gt 0 ] ; then
1106       echo "IGCM_sys_ncks : erreur ${@}."
1107#       IGCM_debug_Exit "ncks"
1108    fi
1109
1110    IGCM_debug_PopStack "IGCM_sys_ncks"
1111}
1112
1113function IGCM_sys_ncpdq {
1114    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1115    if ( $DEBUG_sys ) ; then
1116        echo "IGCM_sys_ncpdq :" $@
1117    fi
1118    ncpdq $@
1119    if [ $? -gt 0 ] ; then
1120       echo "IGCM_sys_ncpdq : erreur ${@}."
1121#       IGCM_debug_Exit "ncpdq"
1122    fi
1123
1124    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1125}
1126
1127function IGCM_sys_ncra {
1128    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1129    if ( $DEBUG_sys ) ; then
1130        echo "IGCM_sys_ncra :" $@
1131    fi
1132    ncra $@
1133    if [ $? -gt 0 ] ; then
1134       echo "IGCM_sys_ncra : erreur ${@}."
1135#       IGCM_debug_Exit "ncra"
1136    fi
1137
1138    IGCM_debug_PopStack "IGCM_sys_ncra"
1139}
1140
1141function IGCM_sys_ncrcat {
1142    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1143    if ( $DEBUG_sys ) ; then
1144        echo "IGCM_sys_ncrcat :" $@
1145    fi
1146    ncrcat $@
1147    if [ $? -gt 0 ] ; then
1148       echo "IGCM_sys_ncrcat : erreur ${@}."
1149#       IGCM_debug_Exit "ncrcat"
1150    fi
1151
1152    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1153}
1154
1155function IGCM_sys_ncrename {
1156    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1157    if ( $DEBUG_sys ) ; then
1158        echo "IGCM_sys_ncrename :" $@
1159    fi
1160    ncrename $@
1161    if [ $? -gt 0 ] ; then
1162       echo "IGCM_sys_ncrename : erreur ${@}."
1163#       IGCM_debug_Exit "ncrename"
1164    fi
1165
1166    IGCM_debug_PopStack "IGCM_sys_ncrename"
1167}
1168
1169function IGCM_sys_ncwa {
1170    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1171    if ( $DEBUG_sys ) ; then
1172        echo "IGCM_sys_ncwa :" $@
1173    fi
1174    ncwa $@
1175    if [ $? -gt 0 ] ; then
1176       echo "IGCM_sys_ncwa : erreur ${@}."
1177#       IGCM_debug_Exit "ncwa"
1178    fi
1179
1180    IGCM_debug_PopStack "IGCM_sys_ncwa"
1181}
1182
1183############################################################
1184# Activate Running Environnment Variables
1185
1186function IGCM_sys_activ_variables {
1187    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1188    if ( $DEBUG_sys ) ; then
1189        echo "IGCM_sys_activ_variables"
1190    fi
1191    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1192}
1193
1194############################################################
1195# Desactivate Running Environnment Variables
1196
1197function IGCM_sys_desactiv_variables {
1198    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1199    if ( $DEBUG_sys ) ; then
1200        echo "IGCM_sys_desactiv_variables"
1201    fi
1202    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1203}
1204
1205############################################################
1206# Build run file
1207
1208function IGCM_sys_build_run_file {
1209    IGCM_debug_PushStack "IGCM_sys_build_run_file"
1210    if ( $DEBUG_sys ) ; then
1211        echo "IGCM_sys_build_run_file"
1212    fi
1213    IGCM_debug_PopStack "IGCM_sys_build_run_file"
1214}
Note: See TracBrowser for help on using the repository browser.