source: tags/libIGCM_v1_2/libIGCM_sys/libIGCM_sys_rhodes.ksh @ 234

Last change on this file since 234 was 44, checked in by sdipsl, 15 years ago

SD : - correct bug with post-processing in case of asynchronous rebuild.

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