New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
all_functions.sh in utils/CI/sette_ticket2304 – NEMO

source: utils/CI/sette_ticket2304/all_functions.sh @ 12541

Last change on this file since 12541 was 12541, checked in by mathiot, 5 years ago

ticket #2304 : add description of -s and -c in the README, set verbosity of rsync to normal and update text output from sette

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 21.2 KB
Line 
1######################################################
2# Author : Simona Flavoni for NEMO
3# Contact : sflod@locean-ipsl.upmc.fr
4#
5# ----------------------------------------------------------------------
6# NEMO/SETTE , NEMO Consortium (2010)
7# Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
8# ----------------------------------------------------------------------
9#
10# Some scripts called by sette.sh
11# all_functions.sh   : all functions used by sette.sh 
12######################################################
13#set -x
14#set -o posix
15#set -u
16#set -e
17#+
18#
19# ================
20# all_functions.sh
21# ================
22#
23# ----------------------------------------------
24# Set of functions used by sette.sh (NEMO tests)
25# ----------------------------------------------
26#
27# SYNOPSIS
28# ========
29#
30# ::
31#
32#  $ ./set_namelist INPUT_NAMELIST VARIABLE VALUE
33#  $ post_test_tidyup
34#
35#
36# DESCRIPTION
37# ===========
38#
39# function superegrep
40#   input variable value
41#
42# function set_namelist
43#   input namelist_name variable value
44#   output namelist
45#
46# function post_test_tidyup
47#   creates nemo_validation tree, and save output & debug files
48#   this function creates tree of validation in NEMO_VALIDATION_DIR as follows :
49#
50# NEMO_VALIDATION_DIR/WCONFIG_NAME/WCOMPILER_NAME/REVISION_NUMBER(or DATE)/TEST_NAME
51#
52# NEMO_VALIDATION_DIR           : is choosen in param.cfg
53#
54# WCONFIG_NAME                  : set by makenemo at the moment of compilation
55#
56# WCOMPILER_NAME                : set by makenemo at the moment of compilation
57#
58# REVISION_NUMBER(or DATE)      : revision number by svn info, if problems with svn date is taken
59#
60# TEST_NAME                     : set in sette.sh for each configuration to be tested (directory TEST_NAME is created under ${NEW_CONF} directory )
61#
62# EXAMPLES
63# ========
64#
65# ::
66#
67#  $ ./set_namelist namelist          nn_itend        75
68#  $ ./set_namelist namelist_ice      cn_icerst_in  \"00101231_restart_ice\"
69#  $ post_test_tidyup
70#
71#
72# TODO
73# ====
74#
75# option debug
76#
77#
78# EVOLUTIONS
79# ==========
80#
81# $Id$
82#
83#   * creation
84#-
85# function to find namelists parameters
86supergrep () {
87            grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
88    }
89
90usage=" Usage : set_namelist input_namelist variable_name value"
91usage=" if value is a string ths is neede syntax : ./set_namelist namelist_name var_name \"new_value\" "
92
93# sync MYSRC files (input CFG and CFG_ST)
94sync_config() {
95   if [ ${SYNC_CONFIGS} == "yes" ]; then
96
97      lREF=$3/$1    # reference
98      lCFG=$3/$2    # target
99
100      echo '-------------------------------------------------------------------------------'
101      echo '                    SOURCE AND CONFIG FILES SYNCHRONISATION                    '
102      echo ''
103      echo "configuration $lCFG/MY_SRC will be synchronised with $lREF/MY_SRC"
104      echo ''
105      # synchronise MY_SRC if $lCFG directory exist
106      if [ -d $lREF/MY_SRC ] && [ -d $lCFG ] ; then
107
108         if [ -d $lCFG/MY_SRC ] ; then
109
110            # Manage case number of file in MY_SRC changes
111            # find number of file only in $lCFG/MY_SRC
112            FCFG=`diff -r $lREF/MY_SRC $lCFG/MY_SRC | grep "Only in $lCFG/MY_SRC" | awk '{print $4}'`
113
114            # if more than 0, trigger a cleaning as Makenemo do not properly manage this case.
115            if [ ! -z "$FCFG" ]; then
116               echo ''
117               echo "$lCFG contains a different file list than $lREF :"
118               diff -r $lREF/MY_SRC $lCFG/MY_SRC | grep "Only in $lCFG/MY_SRC" | awk '{print $4}'
119               echo "Synchronisation is not enough because Makenemo does not handle well case where a file in MY_SRC is removed"
120               echo "Therefore, we need to clean $lCFG before starting runing it"
121               echo ''
122               CLEAN_CONFIGS="yes"
123            fi
124         fi
125
126         # synchronisation $lREF/MY_SRC directory (and delete file in target location if needed)
127         rsync -a --delete $lREF/MY_SRC/ $lCFG/MY_SRC
128
129         # rsync keep preserve the modification time stamp.
130         # To avoid case where a file in MY_SRC is replace by an older file, we touch the file
131         touch $lCFG/MY_SRC/*
132      fi
133
134      echo ''
135      echo "configuration $lCFG/EXP00 will be synchronised with $lREF/EXPREF"
136      echo "(links are skipped)"
137      echo ''
138      # synchronize EXPREF
139      if [ -d $lREF/EXPREF ] && [ -d $lCFG/EXP00 ] ; then
140         rsync -a --no-links $lREF/EXPREF/ $lCFG/EXP00/.
141      fi
142      echo '-------------------------------------------------------------------------------'
143   fi
144}
145
146# clean _ST config (input CFG CFG_ST TYPE (test or ref))
147clean_config() {
148   if [ ${CLEAN_CONFIGS} == "yes" ]; then
149      lREF=$1
150      lCFG=$2
151      lTYP=$3
152      echo ''
153      echo '-------------------------------------------------------------------------------'
154      echo '                         CLEANING CONFIGURATION                                '
155      echo ''
156      echo "./makenemo -n $lCFG -a/-r $lREF clean"
157      echo ''
158      if [ ${lTYP} == 'tests' ]; then
159         ./makenemo -n $lCFG -a $lREF clean
160      elif [ ${lTYP} == 'cfgs' ]; then
161         ./makenemo -n $lCFG -r $lREF clean
162      else
163         echo 'ERROR in the cleaning process'; exit 42
164      fi
165      echo ''
166      echo "$lCFG configuration has been cleaned"
167      echo ''
168      echo '-------------------------------------------------------------------------------'
169   fi
170}
171
172# define validation dir
173set_valid_dir () {
174    LANG=en_US
175    REVISION_NB=`LC_MESSAGES=${LANG} ${SVN_CMD} info ${SETTE_DIR}/.. | grep "Last Changed Rev" | awk '{print $NF}'`
176    if [ ${#REVISION_NB} -eq 0 ]
177    then
178        echo "some problems with ${SVN_CMD} info command"
179        echo "some problems with ${SVN_CMD} info command" >> ${SETTE_DIR}/output.sette
180        REVISION_NB=`date +%Y%m%d`
181        echo "put in ${REVISION_NB} date"
182        echo "put in ${REVISION_NB} date" >> ${SETTE_DIR}/output.sette
183    else
184    echo "value of revision number of NEMOGCM: ${REVISION_NB}"
185    fi
186    [ `${SVN_CMD} status -q ${SETTE_DIR}/../{cfg,tests,src} | wc -l` -ge 1 ] && REVISION_NB=${REVISION_NB}+
187    NEMO_VALID=${NEMO_VALIDATION_DIR}/W${NEW_CONF}/${CMP_NAM}/${REVISION_NB}/${TEST_NAME}
188}
189
190# clean valid dir (move old ocean_output/run.stat and tracer to avoid checking them in case something wrong happen.
191clean_valid_dir () {
192#   set_valid_dir # already done in sette_ref/sette_test
193   echo "validation directory is : $NEMO_VALID"
194   if [ -d $NEMO_VALID ] ; then
195      [ -f ${NEMO_VALID}/ocean.output ] && mv ${NEMO_VALID}/ocean.output ${NEMO_VALID}/ocean.output_old
196      [ -f ${NEMO_VALID}/run.stat ]     && mv ${NEMO_VALID}/run.stat     ${NEMO_VALID}/run.stat_old
197      [ -f ${NEMO_VALID}/tracer.stat ]  && mv ${NEMO_VALID}/tracer.stat  ${NEMO_VALID}/tracer.stat_old
198   fi
199}
200
201# function to set namelists parameters
202set_namelist () {
203   minargcount=3
204   if [ ${#} -lt ${minargcount} ]
205   then
206      echo "not enough arguments for set_namelist"
207      echo "${usage}"
208      exit 1
209   fi
210   unset minargcount
211   if [  ! -f ${SETTE_DIR}/output.sette ] ; then
212                touch ${SETTE_DIR}/output.sette
213        fi
214
215        echo "executing script : set_namelist $@" >> ${SETTE_DIR}/output.sette
216        echo "################" >> ${SETTE_DIR}/output.sette
217     
218   VAR_NAME=$( supergrep $2 ${EXE_DIR}/$1 )
219   if [ ${#VAR_NAME} -eq 0 ] 
220   then
221      echo "doing \"set_namelist $@\". "  >> ${SETTE_DIR}/output.sette
222      echo "variable: \"$2\" not found in \"${EXE_DIR}/$1\" "  >> ${SETTE_DIR}/output.sette
223                NAMREF=$( basename $1 _cfg )_ref
224      echo "doing more : search in ${EXE_DIR}/$NAMREF " >> ${SETTE_DIR}/output.sette
225                VAR_NAME=$( supergrep $2 ${EXE_DIR}/$NAMREF )
226           if [ ${#VAR_NAME} -eq 0 ] 
227           then
228                    echo " variable $VAR_NAME not found in ${EXE_DIR}/$1 nor in ${EXE_DIR}/$NAMREF "
229                    echo " check your variable name "
230            echo "exit"
231            echo "error in executing script : set_namelist $@" >> ${SETTE_DIR}/output.sette
232            echo "....." >> ${SETTE_DIR}/output.sette
233            exit 1
234                fi
235                LINEVAR=$( grep -s -n "$VAR_NAME" ${EXE_DIR}/$NAMREF | awk -F: '{ { print $1} }' )
236                echo " $VAR_NAME found in ${EXE_DIR}/$NAMREF at line $LINEVAR " >> ${SETTE_DIR}/output.sette
237
238#   search for namelist group name
239                NAMGRP=$( head -n$LINEVAR ${EXE_DIR}/$NAMREF | grep --line-buffered "^&nam" | tail -1 | awk -F" " '{ { print $1} }' ) 
240                echo " variable $VAR_NAME will be added in $NAMGRP namelist-group of namelist file ${EXE_DIR}/$1 " >> ${SETTE_DIR}/output.sette
241
242# check if namelist group present in namelist_cfg
243# if missing group is added at the end of namelist_cfg
244                NGRP=$(grep ${NAMGRP} ${EXE_DIR}/$1 | wc -l )
245                if [ ${NGRP} -eq 0 ]; then
246                   echo ''                                                                          >> ${SETTE_DIR}/output.sette
247                   echo "+++++ Group ${NAMGRP} containing ${2} is missing in ${EXE_DIR}/$1 +++++ "  >> ${SETTE_DIR}/output.sette
248                   echo "+++++ Group ${NAMGRP}                 is added   in ${EXE_DIR}/$1 +++++ "  >> ${SETTE_DIR}/output.sette
249                   echo ''                                                                          >> ${SETTE_DIR}/output.sette
250                   echo "&${NAMGRP}" >> ${EXE_DIR}/$1
251                   echo "/"          >> ${EXE_DIR}/$1
252                fi
253
254# Add $VARNAME in namelist file ${EXE_DIR}/$1 in namelist group $NAMGRP
255# on mac osx, replace sed --posix by gsed (available with mac port)
256                sed --posix "/${NAMGRP} /a\ ${VAR_NAME} " ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp || gsed --posix "/${NAMGRP} /a\ ${VAR_NAME} " ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
257
258# if file not empty replace ${EXE_DIR}/$1
259               if [ -s ${EXE_DIR}/$1.tmp ] ; then
260                   mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1 
261                else
262                echo "file ${EXE_DIR}/$1.tmp is empty. sed command went wrong "; exit 200
263                fi
264   fi
265
266        ARGS_LST="${@:3}"
267        sed -e "s;${VAR_NAME}.*;${VAR_NAME};" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
268        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
269        sed -e "s;${VAR_NAME};$2=${ARGS_LST};"  ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
270        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
271
272        echo "finished script : set_namelist $@" >> ${SETTE_DIR}/output.sette
273        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
274        echo "                " >> ${SETTE_DIR}/output.sette
275}
276
277
278# function to tidy up after each test and populate the NEMO_VALIDATION store
279post_test_tidyup () {
280# Save current exit status of caller script
281    RUN_STATUS=$? 
282    echo "Exit status: ${RUN_STATUS}" 
283#
284# requires the following variables defined and exported from the calling script:
285#  SETTE_DIR
286#  INPUT_DIR
287#  EXE_DIR
288#  CONFIG_DIR
289#  NEMO_VALIDATION_DIR
290#  NEW_CONF
291#  CMP_NAM
292#  TEST_NAME
293echo "SETTE directory is : ${SETTE_DIR}"
294echo "INPUT directory is : ${INPUT_DIR}"
295echo "EXECUTION directory is : ${EXE_DIR}"
296echo "CONFIG directory is : ${CONFIG_DIR}"
297echo "VALIDATION directory is : ${NEMO_VALID}"
298echo "NEW CONFIGURATION is : ${NEW_CONF}"
299echo "COMPILER is : ${CMP_NAM}"
300echo "TEST is : ${TEST_NAME}"
301echo "TOOLS directory is : ${TOOLS_DIR}"
302################################################################
303# SMALL DEBUG
304    EXIT_STATUS=${RUN_STATUS}
305    if [ ! -r ${EXE_DIR}/ocean.output ]
306        then
307        grep "E R R O R" ${EXE_DIR}/ocean.output && echo "Some ERRORS at execution time, see ${EXE_DIR}/ocean.output"
308        EXIT_STATUS=2
309        # exit 2 Error now catch in the report
310    fi
311
312    if [ ! -r ${EXE_DIR}/time.step ]
313        then
314        echo "file time.step does not exist"   >> ${SETTE_DIR}/output.sette
315        echo "some problems during execution of model"  >> ${SETTE_DIR}/output.sette
316        EXIT_STATUS=1
317        # exit 1 Error now catch in the report
318    else
319        echo "file time.step exists"  >> ${SETTE_DIR}/output.sette
320        echo "execution of model time step loop started"   >> ${SETTE_DIR}/output.sette
321    fi
322
323################################################################
324
325################################################################
326#
327# Creation of NEMO_VALIDATION tree
328#    set_valid_dir already done in sette_reference_config
329    mkdir -p ${NEMO_VALIDATION_DIR}
330    if [ -d ${NEMO_VALIDATION_DIR} ] ; then
331   echo "created ${NEMO_VALIDATION_DIR} directory"   >> ${SETTE_DIR}/output.sette
332    else
333   echo "problems in creating ${NEMO_VALIDATION_DIR} directory"   >> ${SETTE_DIR}/output.sette
334   echo "EXIT,"
335   exit 1
336    fi
337#
338# Exit before populating validation directory if the model run has
339# returned a non-zero exit status
340# On CRAY NEMO exit is not the expected 999 or 123456 (let this bloc in case useful later on).
341#    case ${EXIT_STATUS} in
342#        0|123456|999) echo " NEMO finished with exit code $EXIT_STATUS " ; post_test_tidyup ;;
343#        *) echo " NEMO abort on an unexpected error (segmentation fault or whatever) $EXIT_STATUS "
344#    esac
345
346    [ ${EXIT_STATUS} -ne 0 ] && exit ${EXIT_STATUS} 
347#
348# Save output & debug files in NEMO_VALIDATION tree
349    echo "saving ocean & ice output, run.stat, tracer.stat files ...." >> ${SETTE_DIR}/output.sette
350    echo "            " >> ${SETTE_DIR}/output.sette
351    [ -f ${EXE_DIR}/ocean.output ] && cp ${EXE_DIR}/*ocean.output ${NEMO_VALIDATION_DIR}/.
352    [ -f ${EXE_DIR}/run.stat ] && cp ${EXE_DIR}/*run.stat ${NEMO_VALIDATION_DIR}/.
353    [ -f ${EXE_DIR}/output.namelist.dyn ] && cp ${EXE_DIR}/*output.nam* ${NEMO_VALIDATION_DIR}/.
354    [ -f ${EXE_DIR}/tracer.stat ] && cp ${EXE_DIR}/*tracer.stat ${NEMO_VALIDATION_DIR}/.
355
356    if [ -n "$(ls ${NEMO_VALIDATION_DIR}/*run*)" ] ; then
357   echo "moved run.stat in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
358   echo "moved run.stat in ${NEMO_VALIDATION_DIR} directory" 
359    else
360   echo "problem in looking for run.stat file in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
361   echo "run.stat IS NOT in ${NEMO_VALIDATION_DIR} directory" 
362    fi
363    if [ -n "$(ls ${NEMO_VALIDATION_DIR}/*ocean.output*)" ] ; then
364   echo "moved ocean.output in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
365   echo "moved ocean.output in ${NEMO_VALIDATION_DIR} directory" 
366    else
367   echo "problem in looking for ocean.output file in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
368   echo "ocean.output IS NOT in ${NEMO_VALIDATION_DIR} directory" 
369    fi
370    if [ -n "$(ls ${NEMO_VALIDATION_DIR}/*tracer.stat*)" ] ; then
371        echo "moved tracer.stat in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
372        echo "moved tracer.stat in ${NEMO_VALIDATION_DIR} directory"
373    else
374        echo "problem in looking for tracer.stat file in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
375        echo "tracer.stat IS NOT in ${NEMO_VALIDATION_DIR} directory"
376    fi
377}
378
379#############################################################
380# extra functions to manipulate settings in the iodef.xml file
381#
382# Examples:
383#   set_xio_file_type    iodef.xml one_file
384#   set_xio_using_server iodef.xml true
385#   set_xio_buffer_size  iodef.xml 50000000
386#   set_xio_field_defs   iodef.xml
387#
388#############################################################
389
390usage2=" Usage : set_xio_file_type input_iodef.xml one_file||multiple_file"
391usage3=" Usage : set_xio_using_server input_iodef.xml true||false"
392usage4=" Usage : set_xio_buffer_size input_iodef.xml int_buffer_size"
393usage5=" Usage : set_xio_field_defs input_iodef.xml"
394
395set_xio_file_type () {
396        minargcount=2
397        if [ ${#} -lt ${minargcount} ]
398        then
399                echo "not enough arguments for set_xio_file_type"
400                echo "${usage2}"
401                exit 1
402        fi
403        if [ $2 != "one_file" ] && [ $2 != "multiple_file" ]
404        then
405                echo "unrecognised argument for set_xio_file_type"
406                echo "${usage2}"
407                echo $2
408                exit 1
409        fi
410        unset minargcount
411        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
412                touch ${SETTE_DIR}/output.sette
413        fi
414
415        echo "executing script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
416        echo "################" >> ${SETTE_DIR}/output.sette
417
418        VAR_NAME=$( grep "^.*<.*file_definition.*type.*=" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
419        if [ ${#VAR_NAME} -eq 0 ]
420        then
421                echo "doing \"set_xio_file_type $@\". "
422                echo "xml_tag: file_definition with variable: type is empty"
423                echo "confirm that an appropriate file_definition is in \"${EXE_DIR}/$1\" "
424                echo "exit"
425                echo "error in executing script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
426                echo "....." >> ${SETTE_DIR}/output.sette
427                exit 1
428        fi
429        if [ $2 == "one_file" ] 
430        then
431           sed -e "s:multiple_file:one_file:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
432        else
433           sed -e "s:one_file:multiple_file:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
434        fi
435        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
436
437        echo "finished script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
438        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
439        echo "                " >> ${SETTE_DIR}/output.sette
440}
441
442set_xio_using_server () {
443        minargcount=2
444        if [ ${#} -lt ${minargcount} ]
445        then
446                echo "not enough arguments for set_xio_using_server"
447                echo "${usage2}"
448                exit 1
449        fi
450        if [ $2 != "true" ] && [ $2 != "false" ]
451        then
452                echo "unrecognised argument for set_xio_using_server"
453                echo "${usage2}"
454                echo $2
455                exit 1
456        fi
457        unset minargcount
458        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
459                touch ${SETTE_DIR}/output.sette
460        fi
461
462        echo "executing script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
463        echo "################" >> ${SETTE_DIR}/output.sette
464
465        VAR_NAME=$( grep "^.*<.*variable id.*=.*using_server.*=.*bool" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
466        if [ ${#VAR_NAME} -eq 0 ]
467        then
468                echo "doing \"set_xio_using_server $@\". "
469                echo "xml_tag: "variable id=using_server" with variable: bool is empty"
470                echo "confirm that an appropriate variable id is in \"${EXE_DIR}/$1\" "
471                echo "exit"
472                echo "error in executing script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
473                echo "....." >> ${SETTE_DIR}/output.sette
474                exit 1
475        fi
476        if [ $2 == "false" ]
477        then
478           sed -e "/using_server/s:true:false:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
479           export USING_MPMD=no
480        else
481           sed -e "/using_server/s:false:true:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
482           export USING_MPMD=yes
483        fi
484        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
485
486        echo "finished script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
487        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
488        echo "                " >> ${SETTE_DIR}/output.sette
489}
490
491set_xio_buffer_size () {
492        minargcount=2
493        if [ ${#} -lt ${minargcount} ]
494        then
495                echo "not enough arguments for set_xio_buffer_size"
496                echo "${usage4}"
497                exit 1
498        fi
499        unset minargcount
500        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
501                touch ${SETTE_DIR}/output.sette
502        fi
503
504        echo "executing script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
505        echo "################" >> ${SETTE_DIR}/output.sette
506
507        VAR_NAME=$( grep "^.*<.*variable id.*=.*buffer_size.*=.*integer" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
508        if [ ${#VAR_NAME} -eq 0 ]
509        then
510                echo "doing \"set_xio_buffer_size $@\". "
511                echo "xml_tag: "variable id=buffer_size" with variable: integer is empty"
512                echo "confirm that an appropriate variable id is in \"${EXE_DIR}/$1\" "
513                echo "exit"
514                echo "error in executing script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
515                echo "....." >> ${SETTE_DIR}/output.sette
516                exit 1
517        fi
518        sed -e "/buffer_size/s:>.*<:>$2<:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
519        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
520
521        echo "finished script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
522        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
523        echo "                " >> ${SETTE_DIR}/output.sette
524}
525
526set_xio_field_defs () {
527        minargcount=1
528        if [ ${#} -lt ${minargcount} ]
529        then
530                echo "not enough arguments for set_xio_field_defs"
531                echo "${usage5}"
532                exit 1
533        fi
534        unset minargcount
535        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
536                touch ${SETTE_DIR}/output.sette
537        fi
538
539        echo "executing script : set_xio_field_defs $@" >> ${SETTE_DIR}/output.sette
540        echo "################" >> ${SETTE_DIR}/output.sette
541
542
543        [ -f ${EXE_DIR}/field_def_nemo-oce.xml ] || sed -i '/field_def_nemo-oce/d' $1
544        [ -f ${EXE_DIR}/field_def_nemo-ice.xml ] || sed -i '/field_def_nemo-ice/d' $1
545        [ -f ${EXE_DIR}/field_def_nemo-pisces.xml ] || sed -i '/field_def_nemo-pisces/d' $1
546
547        echo "finished script : set_xio_field_defs $@" >> ${SETTE_DIR}/output.sette
548        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
549        echo "                " >> ${SETTE_DIR}/output.sette
550}
Note: See TracBrowser for help on using the repository browser.