source: branches/SmoothFiles/libIGCM_sys/libIGCM_sys_rhodes.ksh @ 8

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

MM: Add SmoothFiles? with last commit (r6) corrections.

  • 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
715        #USUAL WAY
716        rcp -r brodie:$1 $2 > out_rsync 2>&1
717        RET=$?
718
719        if [ ${RET} -gt 0 ] ; then
720            echo "IGCM_sys_Get_Master : error."
721            cat out_rsync
722            IGCM_debug_Exit "IGCM_sys_Get_Master"
723        fi
724    else
725        echo "DRYRUN mode = " $DRYRUN >> stack
726    fi
727    IGCM_debug_PopStack "IGCM_sys_Get_Master"
728}
729
730#D-#==================================================
731#D-function IGCM_sys_Put_Out
732#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
733#D-* Examples:
734#D-
735function IGCM_sys_Put_Out {
736    IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
737    if ( $DEBUG_sys ) ; then
738        echo "IGCM_sys_Put_Out :" $@
739    fi
740    if [ $DRYRUN = 0 ]; then
741        if [ ! -f ${1} ] ; then
742            echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
743            IGCM_debug_PopStack "IGCM_sys_Put_Out"
744            return 1
745        fi
746
747        typeset RET
748        #
749        IGCM_sys_Chmod 444 ${1}
750        #
751        # Only if we use rsync
752        #IGCM_sys_TestDirArchive $( dirname $2 )
753        #
754        #USUAL WAY
755        mfput $1 $2 > out_rsync 2>&1
756        RET=$?
757
758#       #RSYNC WITH NETWORK RSH CALL
759#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} > out_rsync 2>&1
760#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${RHOST}:${2} >> out_rsync 2>&1
761
762#       #RSYNC WITH NFS USE
763#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
764#       ${RSYNC_FRONT} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
765
766#       RET=$?
767#       IGCM_sys_Rsync_out $RET
768
769#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
770#       (( RET=RET+$? ))
771
772        if [ ${RET} -gt 0 ] ; then
773            echo "IGCM_sys_Put_Out : error."
774            cat out_rsync
775            IGCM_debug_Exit "IGCM_sys_Put_Out"
776        fi
777    else
778        echo "DRYRUN mode = " $DRYRUN >> stack
779    fi
780    IGCM_debug_PopStack "IGCM_sys_Put_Out"
781    return 0
782}
783
784#D-#==================================================
785#D-function IGCM_sys_Get
786#D-* Purpose: Get a file from ${ARCHIVE}
787#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
788#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
789function IGCM_sys_Get {
790    IGCM_debug_PushStack "IGCM_sys_Get" $@
791
792    typeset DEST RET dm_liste ifile target
793
794    if ( $DEBUG_sys ) ; then
795        echo "IGCM_sys_Get :" $@
796    fi
797    if [ $DRYRUN -le 2 ]; then
798        if [ X${1} = X'/l' ] ; then
799            # test if the first file is present in the old computation :
800            eval set +A dm_liste \${${2}}
801        else
802            dm_liste=${1}
803        fi
804        eval DEST=\${${#}}
805
806        # test if the (first) file is present in the old computation :
807        IGCM_sys_TestFileArchive ${dm_liste[0]}
808        RET=$?
809        if [ ${RET} -gt 0 ] ; then
810            echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
811            IGCM_debug_Exit "IGCM_sys_Get"
812            IGCM_debug_PopStack "IGCM_sys_Get"
813            return
814        fi
815
816        # SD : dm_liste is not suited for computing job
817        #      because we change filename during transfert
818        #      dm_liste is better suited for post-treatment
819        # SD : dm_liste necessary only with RSYNC
820
821        #dm_liste=" "
822        #(( ifile=1 ))
823        #while [ $ifile -lt $# ] ; do
824        #    dm_liste=$( eval echo ${dm_liste[*]} " "\${${ifile}} )
825        #    (( ifile = ifile + 1 ))
826        #done
827        #DEST=$( eval echo \${${#}} )
828
829        #USUAL WAY
830        mfget ${dm_liste[*]} ${DEST} > out_rsync 2>&1
831        RET=$?
832
833#       #RSYNC WITH NETWORK RSH CALL
834#       echo ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
835#       ${RSYNC_FRONT} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RHOST}:"${dm_liste}" ${RHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
836
837#       #RSYNC WITH NFS USE
838#       echo ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
839#       ${RSYNC_FRONT} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
840
841#       RET=$?
842#       IGCM_sys_Rsync_out $RET
843
844#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
845#       (( RET=RET+$? ))
846
847        if [ ${RET} -gt 0 ] ; then
848            echo "IGCM_sys_Get : copy error."
849            cat out_rsync
850            IGCM_debug_Exit "IGCM_sys_Get"
851        fi
852    else
853        echo "DRYRUN mode = " $DRYRUN >> stack
854    fi
855    IGCM_debug_PopStack "IGCM_sys_Get"
856}
857
858#D-#==================================================
859#D-function IGCM_sys_Put_Dods
860#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
861#D-* Examples:
862#D-
863function IGCM_sys_Put_Dods {
864    IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
865    if ( $DEBUG_sys ) ; then
866        echo "IGCM_sys_Put_Dods :" $@
867    fi
868    if [ $DRYRUN = 0 ]; then
869        if [ ! -d ${R_SAVE}/${1} ] ; then
870            echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
871            IGCM_debug_PopStack "IGCM_sys_Put_Dods"
872            return
873        fi
874
875        typeset RET
876        #
877        rsh gaya exec /bin/ksh <<EOF
878        cd ${R_SAVE}
879        /usr/local/bin/dods_rm DODS/pub/${LOGIN}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/${1} > /dev/null 2>&1
880        /sbin/chmod -R u+w ${R_SAVE}/${1}
881        /usr/local/bin/dods_cp ${1} DODS/pub/${LOGIN}/${config_UserChoices_TagName}/${config_UserChoices_JobName} > /dev/null 2>&1
882        /sbin/chmod -R +rX ${R_SAVE}/${1}
883        /sbin/chmod -R u+w ${R_SAVE}/${1}
884EOF
885        RET=$?
886
887        if [ ${RET} -gt 0 ] ; then
888            echo "IGCM_sys_Put_Dods : error."
889            cat out_dods
890            IGCM_debug_Exit "IGCM_sys_Put_Dods"
891        fi
892    else
893        echo "DRYRUN mode = " $DRYRUN >> stack
894    fi
895    IGCM_debug_PopStack "IGCM_sys_Put_Dods"
896}
897
898############################################################## A REVOIR !!
899
900#D-#==================================================
901#D-function IGCM_sys_Rapatrie
902#D-* Purpose: Rapatrie
903#D-* Examples:
904#D-
905function IGCM_sys_Rapatrie {
906    IGCM_debug_PushStack "IGCM_sys_Rapatrie" $@
907    if ( $DEBUG_sys ) ; then
908        echo "IGCM_sys_Rapatrie :" $@
909    fi
910
911    typeset RET=0
912
913    IGCM_sys_Get ${R_STOCKAGE}/$2 $1 ;
914    let $(( RET=RET+$? ))
915    IGCM_sys_Cd $1 ;
916    let $(( RET=RET+$? ))
917    IGCM_sys_UnTar $2 ;
918    let $(( RET=RET+$? ))
919
920    if [ ${RET} -gt 0 ] ; then
921        echo "IGCM_sys_Rapatrie : erreur."
922        IGCM_debug_Exit "IGCM_sys_Rapatrie"
923    fi
924    IGCM_debug_PopStack "IGCM_sys_Rapatrie"
925}
926
927############################################################## A FINIR !!
928
929#D-#==================================================
930#D-function IGCM_sys_GetDate_FichWork
931#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
932#D-* Examples:
933#D-
934function IGCM_sys_GetDate_FichWork {
935    IGCM_debug_PushStack "IGCM_sys_FichWork" $@
936    if ( $DEBUG_sys ) ; then
937        echo "IGCM_sys_GetDate_FichWork :" $@
938    fi
939    # donne la date filesys d'un fichier sur la machine work
940    IGCM_debug_PopStack "IGCM_sys_FichWork"
941}
942
943#D-#==================================================
944#D-function IGCM_sys_GetDate_FichArchive
945#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
946#D-* Examples:
947#D-
948function IGCM_sys_GetDate_FichArchive {
949    IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
950    if ( $DEBUG_sys ) ; then
951        echo "IGCM_sys_GetDate_FichArchive :" $@
952    fi
953    IGCM_debug_PopStack "IGCM_sys_FichArchive"
954}
955
956
957##############################################################
958# NCO OPERATOR
959
960function IGCM_sys_ncap {
961    IGCM_debug_PushStack "IGCM_sys_ncap" -- $@
962    if ( $DEBUG_sys ) ; then
963        echo "IGCM_sys_ncap :" $@
964    fi
965    /usr/local/bin/ncap $@
966    if [ $? -gt 0 ] ; then
967       echo "IGCM_sys_ncap : erreur ${@}."
968       IGCM_debug_Exit "ncap"
969    fi
970
971    IGCM_debug_PopStack "IGCM_sys_ncap"
972}
973
974ncatted=/usr/local/bin/ncatted
975# Problem with ksh and string passed in this function to ncatted !
976# function IGCM_sys_ncatted {
977#     IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
978#     if ( $DEBUG_sys ) ; then
979#       echo "IGCM_sys_ncatted :" $@
980#     fi
981#     /usr/local/bin/ncatted $@
982#     if [ $? -gt 0 ] ; then
983#        echo "IGCM_sys_ncatted : erreur ${@}."
984#        IGCM_debug_Exit "ncatted"
985#     fi
986
987#     IGCM_debug_PopStack "IGCM_sys_ncatted"
988# }
989
990function IGCM_sys_ncbo {
991    IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
992    if ( $DEBUG_sys ) ; then
993        echo "IGCM_sys_ncbo :" $@
994    fi
995    /usr/local/bin/ncbo $@
996    if [ $? -gt 0 ] ; then
997       echo "IGCM_sys_ncbo : erreur ${@}."
998       IGCM_debug_Exit "ncbo"
999    fi
1000
1001    IGCM_debug_PopStack "IGCM_sys_ncbo"
1002}
1003
1004function IGCM_sys_ncdiff {
1005    IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
1006    if ( $DEBUG_sys ) ; then
1007        echo "IGCM_sys_ncdiff :" $@
1008    fi
1009    /usr/local/bin/ncdiff $@
1010    if [ $? -gt 0 ] ; then
1011       echo "IGCM_sys_ncdiff : erreur ${@}."
1012       IGCM_debug_Exit "ncdiff"
1013    fi
1014
1015    IGCM_debug_PopStack "IGCM_sys_ncdiff"
1016}
1017
1018function IGCM_sys_ncea {
1019    IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
1020    if ( $DEBUG_sys ) ; then
1021        echo "IGCM_sys_ncea :" $@
1022    fi
1023    /usr/local/bin/ncea $@
1024    if [ $? -gt 0 ] ; then
1025       echo "IGCM_sys_ncea : erreur ${@}."
1026       IGCM_debug_Exit "ncea"
1027    fi
1028
1029    IGCM_debug_PopStack "IGCM_sys_ncea"
1030}
1031
1032function IGCM_sys_ncecat {
1033    IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
1034    if ( $DEBUG_sys ) ; then
1035        echo "IGCM_sys_ncecat :" $@
1036    fi
1037    /usr/local/bin/ncecat $@
1038    if [ $? -gt 0 ] ; then
1039       echo "IGCM_sys_ncecat : erreur ${@}."
1040       IGCM_debug_Exit "ncecat"
1041    fi
1042
1043    IGCM_debug_PopStack "IGCM_sys_ncecat"
1044}
1045
1046function IGCM_sys_ncflint {
1047    IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
1048    if ( $DEBUG_sys ) ; then
1049        echo "IGCM_sys_ncflint :" $@
1050    fi
1051    /usr/local/bin/ncflint $@
1052    if [ $? -gt 0 ] ; then
1053       echo "IGCM_sys_ncflint : erreur ${@}."
1054       IGCM_debug_Exit "ncflint"
1055    fi
1056
1057    IGCM_debug_PopStack "IGCM_sys_ncflint"
1058}
1059
1060function IGCM_sys_ncks {
1061    IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
1062    if ( $DEBUG_sys ) ; then
1063        echo "IGCM_sys_ncks :" $@
1064    fi
1065    /usr/local/bin/ncks $@
1066    if [ $? -gt 0 ] ; then
1067       echo "IGCM_sys_ncks : erreur ${@}."
1068       IGCM_debug_Exit "ncks"
1069    fi
1070
1071    IGCM_debug_PopStack "IGCM_sys_ncks"
1072}
1073
1074function IGCM_sys_ncpdq {
1075    IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
1076    if ( $DEBUG_sys ) ; then
1077        echo "IGCM_sys_ncpdq :" $@
1078    fi
1079    /usr/local/bin/ncpdq $@
1080    if [ $? -gt 0 ] ; then
1081       echo "IGCM_sys_ncpdq : erreur ${@}."
1082       IGCM_debug_Exit "ncpdq"
1083    fi
1084
1085    IGCM_debug_PopStack "IGCM_sys_ncpdq"
1086}
1087
1088function IGCM_sys_ncra {
1089    IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
1090    if ( $DEBUG_sys ) ; then
1091        echo "IGCM_sys_ncra :" $@
1092    fi
1093    /usr/local/bin/ncra $@
1094    if [ $? -gt 0 ] ; then
1095       echo "IGCM_sys_ncra : erreur ${@}."
1096       IGCM_debug_Exit "ncra"
1097    fi
1098
1099    IGCM_debug_PopStack "IGCM_sys_ncra"
1100}
1101
1102function IGCM_sys_ncrcat {
1103    IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
1104    if ( $DEBUG_sys ) ; then
1105        echo "IGCM_sys_ncrcat :" $@
1106    fi
1107    /usr/local/bin/ncrcat $@
1108    if [ $? -gt 0 ] ; then
1109       echo "IGCM_sys_ncrcat : erreur ${@}."
1110       IGCM_debug_Exit "ncrcat"
1111    fi
1112
1113    IGCM_debug_PopStack "IGCM_sys_ncrcat"
1114}
1115
1116function IGCM_sys_ncrename {
1117    IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
1118    if ( $DEBUG_sys ) ; then
1119        echo "IGCM_sys_ncrename :" $@
1120    fi
1121    /usr/local/bin/ncrename $@
1122    if [ $? -gt 0 ] ; then
1123       echo "IGCM_sys_ncrename : erreur ${@}."
1124       IGCM_debug_Exit "ncrename"
1125    fi
1126
1127    IGCM_debug_PopStack "IGCM_sys_ncrename"
1128}
1129
1130function IGCM_sys_ncwa {
1131    IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
1132    if ( $DEBUG_sys ) ; then
1133        echo "IGCM_sys_ncwa :" $@
1134    fi
1135    /usr/local/bin/ncwa $@
1136    if [ $? -gt 0 ] ; then
1137       echo "IGCM_sys_ncwa : erreur ${@}."
1138       IGCM_debug_Exit "ncwa"
1139    fi
1140
1141    IGCM_debug_PopStack "IGCM_sys_ncwa"
1142}
1143
1144############################################################
1145# Activate Running Environnment Variables
1146
1147function IGCM_sys_activ_variables {
1148    IGCM_debug_PushStack "IGCM_sys_activ_variables"
1149    if ( $DEBUG_sys ) ; then
1150        echo "IGCM_sys_activ_variables"
1151    fi
1152    IGCM_debug_PopStack "IGCM_sys_activ_variables"
1153}
1154
1155############################################################
1156# Desactivate Running Environnment Variables
1157
1158function IGCM_sys_desactiv_variables {
1159    IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1160    if ( $DEBUG_sys ) ; then
1161        echo "IGCM_sys_desactiv_variables"
1162    fi
1163    IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1164}
1165
1166############################################################
1167# Build run file
1168
1169function IGCM_sys_build_run_file {
1170    IGCM_debug_PushStack "IGCM_sys_build_run_file"
1171    if ( $DEBUG_sys ) ; then
1172        echo "IGCM_sys_build_run_file "
1173    fi
1174    IGCM_debug_PopStack "IGCM_sys_build_run_file "
1175}
Note: See TracBrowser for help on using the repository browser.