source: tags/libIGCM_v1_1/libIGCM_sys/libIGCM_sys_rhodes.ksh @ 1137

Last change on this file since 1137 was 17, checked in by mmaipsl, 16 years ago

MM: Correct platine lib.

Update trunk from tag libIGCM_v1.

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