source: tags/libIGCM_v1_3/libIGCM_sys/libIGCM_sys_rhodes.ksh @ 803

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