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_ticket2673 – NEMO

source: utils/CI/sette_ticket2673/all_functions.sh @ 14870

Last change on this file since 14870 was 14870, checked in by acc, 3 years ago

Branch: sette_ticket2673. More tweaks. Added a few more features and aligned the utility scripts with the new directory structure. Each experiment directory in the NEMO_VALIDATION_DIR now gets a sette_config file recording the settings used to run the test. They now also get copies of the *namelist*_cfg files which can be useful for cross-checking. sette_list_avail_rev.sh now accepts the -v subdir option.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 22.6 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 --no-create $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    REVISION_NB=`${SVN_CMD} info ${SETTE_DIR}/.. | grep "Last Changed Rev" | awk '{print $NF}'`
175    if [ ${#REVISION_NB} -eq 0 ]
176    then
177        echo "some problems with ${SVN_CMD} info command"
178        echo "some problems with ${SVN_CMD} info command" >> ${SETTE_DIR}/output.sette
179        REVISION_NB=`date +%Y%m%d`
180        echo "put in ${REVISION_NB} date"
181        echo "put in ${REVISION_NB} date" >> ${SETTE_DIR}/output.sette
182    else
183    echo "value of revision number of NEMOGCM: ${REVISION_NB}"
184    fi
185    [ `${SVN_CMD} status -q ${SETTE_DIR}/../{cfgs,tests,src} | wc -l` -ge 1 ] && REVISION_NB=${REVISION_NB}+
186    export NEMO_VALID=${NEMO_VALIDATION_DIR}/${CMP_NAM}/${REVISION_NB}/${NEW_CONF/%_ST/}/${TEST_NAME}
187}
188
189# clean valid dir (move old ocean_output/run.stat and tracer to avoid checking them in case something wrong happen.
190clean_valid_dir () {
191#   set_valid_dir # already done in sette_ref/sette_test
192   echo "validation directory is : $NEMO_VALID"
193   if [ -d $NEMO_VALID ] ; then
194      [ -f ${NEMO_VALID}/ocean.output ] && mv ${NEMO_VALID}/ocean.output ${NEMO_VALID}/ocean.output_old
195      [ -f ${NEMO_VALID}/run.stat ]     && mv ${NEMO_VALID}/run.stat     ${NEMO_VALID}/run.stat_old
196      [ -f ${NEMO_VALID}/tracer.stat ]  && mv ${NEMO_VALID}/tracer.stat  ${NEMO_VALID}/tracer.stat_old
197   fi
198}
199
200# set_namelist_opt: function to set namelists parameters based on a yes/no selection
201# Mandatory arguments are, in order:
202# 1. namelist to be edited
203# 2. variable to be set
204# 3. yes or no switch setting
205# 4. value to set variable to if switch is yes
206# 5. value to set variable to if switch is no
207set_namelist_opt () {
208   minargcount=5
209   if [ ${#} -lt ${minargcount} ]
210   then
211      echo "not enough arguments for set_namelist_opt" >> ${SETTE_DIR}/output.sette
212      echo "Usage: set_namelist_opt namelist varname yes_or_no value_if_yes value_if_no" >> ${SETTE_DIR}/output.sette
213      exit 1
214   fi
215   unset minargcount
216        if [ $3 != 'yes' ] && [ $3 != 'no' ] ; then
217                echo 'option switch must be "yes" or "no"' >> ${SETTE_DIR}/output.sette
218                echo "${usage}" >> ${SETTE_DIR}/output.sette
219                exit 1
220        fi
221        if [ $3 == 'yes' ] ; then
222                set_namelist $1 $2 $4
223        else
224                set_namelist $1 $2 $5
225        fi
226}
227       
228# set_namelist: function to set namelists parameters
229set_namelist () {
230   minargcount=3
231   if [ ${#} -lt ${minargcount} ]
232   then
233      echo "not enough arguments for set_namelist"
234      echo "${usage}"
235      exit 1
236   fi
237   unset minargcount
238   if [  ! -f ${SETTE_DIR}/output.sette ] ; then
239                touch ${SETTE_DIR}/output.sette
240        fi
241
242        echo "executing script : set_namelist $@" >> ${SETTE_DIR}/output.sette
243        echo "################" >> ${SETTE_DIR}/output.sette
244     
245   VAR_NAME=$( supergrep $2 ${EXE_DIR}/$1 )
246   if [ ${#VAR_NAME} -eq 0 ] 
247   then
248      echo "doing \"set_namelist $@\". "  >> ${SETTE_DIR}/output.sette
249      echo "variable: \"$2\" not found in \"${EXE_DIR}/$1\" "  >> ${SETTE_DIR}/output.sette
250                NAMREF=$( basename $1 _cfg )_ref
251      echo "doing more : search in ${EXE_DIR}/$NAMREF " >> ${SETTE_DIR}/output.sette
252                VAR_NAME=$( supergrep $2 ${EXE_DIR}/$NAMREF )
253           if [ ${#VAR_NAME} -eq 0 ] 
254           then
255                    echo " variable $VAR_NAME not found in ${EXE_DIR}/$1 nor in ${EXE_DIR}/$NAMREF "
256                    echo " check your variable name "
257            echo "exit"
258            echo "error in executing script : set_namelist $@" >> ${SETTE_DIR}/output.sette
259            echo "....." >> ${SETTE_DIR}/output.sette
260            exit 1
261                fi
262                LINEVAR=$( grep -s -n "$VAR_NAME" ${EXE_DIR}/$NAMREF | awk -F: '{ { print $1} }' )
263                echo " $VAR_NAME found in ${EXE_DIR}/$NAMREF at line $LINEVAR " >> ${SETTE_DIR}/output.sette
264
265#   search for namelist group name
266                NAMGRP=$( head -n$LINEVAR ${EXE_DIR}/$NAMREF | grep --line-buffered "^&nam" | tail -1 | awk -F" " '{ { print $1} }' ) 
267                echo " variable $VAR_NAME will be added in $NAMGRP namelist-group of namelist file ${EXE_DIR}/$1 " >> ${SETTE_DIR}/output.sette
268
269# check if namelist group present in namelist_cfg
270# if missing group is added at the end of namelist_cfg
271                NGRP=$(grep ${NAMGRP} ${EXE_DIR}/$1 | wc -l )
272                if [ ${NGRP} -eq 0 ]; then
273                   echo ''                                                                          >> ${SETTE_DIR}/output.sette
274                   echo "+++++ Group ${NAMGRP} containing ${2} is missing in ${EXE_DIR}/$1 +++++ "  >> ${SETTE_DIR}/output.sette
275                   echo "+++++ Group ${NAMGRP}                 is added   in ${EXE_DIR}/$1 +++++ "  >> ${SETTE_DIR}/output.sette
276                   echo ''                                                                          >> ${SETTE_DIR}/output.sette
277                   echo "${NAMGRP}" >> ${EXE_DIR}/$1
278                   echo "/"         >> ${EXE_DIR}/$1
279                fi
280
281# Add $VARNAME in namelist file ${EXE_DIR}/$1 in namelist group $NAMGRP
282# on mac osx, replace sed --posix by gsed (available with mac port)
283                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
284
285# if file not empty replace ${EXE_DIR}/$1
286               if [ -s ${EXE_DIR}/$1.tmp ] ; then
287                   mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1 
288                else
289                echo "file ${EXE_DIR}/$1.tmp is empty. sed command went wrong "; exit 200
290                fi
291   fi
292
293        ARGS_LST="${@:3}"
294        sed -e "s;${VAR_NAME}.*;${VAR_NAME};" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
295        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
296        sed -e "s;${VAR_NAME};$2=${ARGS_LST};"  ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
297        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
298
299        echo "finished script : set_namelist $@" >> ${SETTE_DIR}/output.sette
300        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
301        echo "                " >> ${SETTE_DIR}/output.sette
302}
303
304
305# function to tidy up after each test and populate the NEMO_VALIDATION store
306post_test_tidyup () {
307# Save current exit status of caller script
308    RUN_STATUS=$? 
309    echo "Exit status: ${RUN_STATUS}" 
310#
311# requires the following variables defined and exported from the calling script:
312#  SETTE_DIR
313#  INPUT_DIR
314#  EXE_DIR
315#  CONFIG_DIR
316#  NEMO_VALIDATION_DIR
317#  NEW_CONF
318#  CMP_NAM
319#  TEST_NAME
320echo "SETTE directory is : ${SETTE_DIR}"
321echo "INPUT directory is : ${INPUT_DIR}"
322echo "EXECUTION directory is : ${EXE_DIR}"
323echo "CONFIG directory is : ${CONFIG_DIR}"
324echo "VALIDATION directory is : ${NEMO_VALID}"
325echo "NEW CONFIGURATION is : ${NEW_CONF}"
326echo "COMPILER is : ${CMP_NAM}"
327echo "TEST is : ${TEST_NAME}"
328echo "TOOLS directory is : ${TOOLS_DIR}"
329################################################################
330# SMALL DEBUG
331    EXIT_STATUS=${RUN_STATUS}
332    if [ ! -r ${EXE_DIR}/ocean.output ]
333        then
334        grep "E R R O R" ${EXE_DIR}/ocean.output && echo "Some ERRORS at execution time, see ${EXE_DIR}/ocean.output"
335        EXIT_STATUS=2
336        # exit 2 Error now catch in the report
337    fi
338
339    if [ ! -r ${EXE_DIR}/time.step ]
340        then
341        echo "file time.step does not exist"   >> ${SETTE_DIR}/output.sette
342        echo "some problems during execution of model"  >> ${SETTE_DIR}/output.sette
343        EXIT_STATUS=1
344        # exit 1 Error now catch in the report
345    else
346        echo "file time.step exists"  >> ${SETTE_DIR}/output.sette
347        echo "execution of model time step loop started"   >> ${SETTE_DIR}/output.sette
348    fi
349
350################################################################
351
352################################################################
353#
354# Creation of NEMO_VALIDATION tree
355#    set_valid_dir already done in sette_reference_config
356    mkdir -p ${NEMO_VALIDATION_DIR}
357    if [ -d ${NEMO_VALIDATION_DIR} ] ; then
358   echo "created ${NEMO_VALIDATION_DIR} directory"   >> ${SETTE_DIR}/output.sette
359    else
360   echo "problems in creating ${NEMO_VALIDATION_DIR} directory"   >> ${SETTE_DIR}/output.sette
361   echo "EXIT,"
362   exit 1
363    fi
364#
365# Exit before populating validation directory if the model run has
366# returned a non-zero exit status
367# On CRAY NEMO exit is not the expected 999 or 123456 (let this bloc in case useful later on).
368#    case ${EXIT_STATUS} in
369#        0|123456|999) echo " NEMO finished with exit code $EXIT_STATUS " ; post_test_tidyup ;;
370#        *) echo " NEMO abort on an unexpected error (segmentation fault or whatever) $EXIT_STATUS "
371#    esac
372
373    [ ${EXIT_STATUS} -ne 0 ] && exit ${EXIT_STATUS} 
374#
375# Save output & debug files in NEMO_VALIDATION tree
376    echo "saving ocean & ice output, run.stat, tracer.stat files ...." >> ${SETTE_DIR}/output.sette
377    echo "            " >> ${SETTE_DIR}/output.sette
378    [ -f ${EXE_DIR}/ocean.output ] && cp ${EXE_DIR}/*ocean.output ${NEMO_VALIDATION_DIR}/.
379    [ -f ${EXE_DIR}/run.stat ] && cp ${EXE_DIR}/*run.stat ${NEMO_VALIDATION_DIR}/.
380    [ -f ${EXE_DIR}/output.namelist.dyn ] && cp ${EXE_DIR}/*output.nam* ${NEMO_VALIDATION_DIR}/.
381    [ -f ${EXE_DIR}/namelist_cfg ] && cp ${EXE_DIR}/*nam*_cfg ${NEMO_VALIDATION_DIR}/.
382    [ -f ${EXE_DIR}/tracer.stat ] && cp ${EXE_DIR}/*tracer.stat ${NEMO_VALIDATION_DIR}/.
383    [ -f ${EXE_DIR}/timing.output ] && cp ${EXE_DIR}/*timing.output ${NEMO_VALIDATION_DIR}/.
384    [ -f ${EXE_DIR}/sette_config ] && cp ${EXE_DIR}/sette_config ${NEMO_VALIDATION_DIR}/.
385
386    if [ -n "$(ls ${NEMO_VALIDATION_DIR}/*run*)" ] ; then
387   echo "moved run.stat in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
388   echo "moved run.stat in ${NEMO_VALIDATION_DIR} directory" 
389    else
390   echo "problem in looking for run.stat file in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
391   echo "run.stat IS NOT in ${NEMO_VALIDATION_DIR} directory" 
392    fi
393    if [ -n "$(ls ${NEMO_VALIDATION_DIR}/*ocean.output*)" ] ; then
394   echo "moved ocean.output in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
395   echo "moved ocean.output in ${NEMO_VALIDATION_DIR} directory" 
396    else
397   echo "problem in looking for ocean.output file in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
398   echo "ocean.output IS NOT in ${NEMO_VALIDATION_DIR} directory" 
399    fi
400    if [ -n "$(ls ${NEMO_VALIDATION_DIR}/*tracer.stat*)" ] ; then
401        echo "moved tracer.stat in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
402        echo "moved tracer.stat in ${NEMO_VALIDATION_DIR} directory"
403    else
404        echo "problem in looking for tracer.stat file in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
405        echo "tracer.stat IS NOT in ${NEMO_VALIDATION_DIR} directory"
406    fi
407}
408
409#############################################################
410# extra functions to manipulate settings in the iodef.xml file
411#
412# Examples:
413#   set_xio_file_type    iodef.xml one_file
414#   set_xio_using_server iodef.xml true
415#   set_xio_buffer_size  iodef.xml 50000000
416#   set_xio_field_defs   iodef.xml
417#
418#############################################################
419
420usage2=" Usage : set_xio_file_type input_iodef.xml one_file||multiple_file"
421usage3=" Usage : set_xio_using_server input_iodef.xml true||false"
422usage4=" Usage : set_xio_buffer_size input_iodef.xml int_buffer_size"
423usage5=" Usage : set_xio_field_defs input_iodef.xml"
424
425set_xio_file_type () {
426        minargcount=2
427        if [ ${#} -lt ${minargcount} ]
428        then
429                echo "not enough arguments for set_xio_file_type"
430                echo "${usage2}"
431                exit 1
432        fi
433        if [ $2 != "one_file" ] && [ $2 != "multiple_file" ]
434        then
435                echo "unrecognised argument for set_xio_file_type"
436                echo "${usage2}"
437                echo $2
438                exit 1
439        fi
440        unset minargcount
441        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
442                touch ${SETTE_DIR}/output.sette
443        fi
444
445        echo "executing script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
446        echo "################" >> ${SETTE_DIR}/output.sette
447
448        VAR_NAME=$( grep "^.*<.*file_definition.*type.*=" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
449        if [ ${#VAR_NAME} -eq 0 ]
450        then
451                echo "doing \"set_xio_file_type $@\". "
452                echo "xml_tag: file_definition with variable: type is empty"
453                echo "confirm that an appropriate file_definition is in \"${EXE_DIR}/$1\" "
454                echo "exit"
455                echo "error in executing script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
456                echo "....." >> ${SETTE_DIR}/output.sette
457                exit 1
458        fi
459        if [ $2 == "one_file" ] 
460        then
461           sed -e "s:multiple_file:one_file:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
462        else
463           sed -e "s:one_file:multiple_file:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
464        fi
465        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
466
467        echo "finished script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
468        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
469        echo "                " >> ${SETTE_DIR}/output.sette
470}
471
472set_xio_using_server () {
473        minargcount=2
474        if [ ${#} -lt ${minargcount} ]
475        then
476                echo "not enough arguments for set_xio_using_server"
477                echo "${usage2}"
478                exit 1
479        fi
480        inarg=$2
481        if [ ${inarg} == "yes" ] ; then inarg="true" ; fi
482        if [ ${inarg} == "no" ]  ; then inarg="false" ; fi
483        if [ ${inarg} != "true" ] && [ ${inarg} != "false" ]
484        then
485                echo "unrecognised argument for set_xio_using_server"
486                echo "${usage2}"
487                echo ${inarg}
488                exit 1
489        fi
490        unset minargcount
491        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
492                touch ${SETTE_DIR}/output.sette
493        fi
494
495        echo "executing script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
496        echo "################" >> ${SETTE_DIR}/output.sette
497
498        VAR_NAME=$( grep "^.*<.*variable id.*=.*using_server.*=.*bool" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
499        if [ ${#VAR_NAME} -eq 0 ]
500        then
501                echo "doing \"set_xio_using_server $@\". "
502                echo "xml_tag: "variable id=using_server" with variable: bool is empty"
503                echo "confirm that an appropriate variable id is in \"${EXE_DIR}/$1\" "
504                echo "exit"
505                echo "error in executing script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
506                echo "....." >> ${SETTE_DIR}/output.sette
507                exit 1
508        fi
509        if [ ${inarg} == "false" ]
510        then
511           sed -e "/using_server/s:true:false:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
512           export USING_MPMD=no
513        else
514           sed -e "/using_server/s:false:true:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
515           export USING_MPMD=yes
516        fi
517        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
518
519        echo "finished script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
520        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
521        echo "                " >> ${SETTE_DIR}/output.sette
522}
523
524set_xio_buffer_size () {
525        minargcount=2
526        if [ ${#} -lt ${minargcount} ]
527        then
528                echo "not enough arguments for set_xio_buffer_size"
529                echo "${usage4}"
530                exit 1
531        fi
532        unset minargcount
533        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
534                touch ${SETTE_DIR}/output.sette
535        fi
536
537        echo "executing script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
538        echo "################" >> ${SETTE_DIR}/output.sette
539
540        VAR_NAME=$( grep "^.*<.*variable id.*=.*buffer_size.*=.*integer" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
541        if [ ${#VAR_NAME} -eq 0 ]
542        then
543                echo "doing \"set_xio_buffer_size $@\". "
544                echo "xml_tag: "variable id=buffer_size" with variable: integer is empty"
545                echo "confirm that an appropriate variable id is in \"${EXE_DIR}/$1\" "
546                echo "exit"
547                echo "error in executing script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
548                echo "....." >> ${SETTE_DIR}/output.sette
549                exit 1
550        fi
551        sed -e "/buffer_size/s:>.*<:>$2<:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
552        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
553
554        echo "finished script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
555        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
556        echo "                " >> ${SETTE_DIR}/output.sette
557}
558
559set_xio_field_defs () {
560        minargcount=1
561        if [ ${#} -lt ${minargcount} ]
562        then
563                echo "not enough arguments for set_xio_field_defs"
564                echo "${usage5}"
565                exit 1
566        fi
567        unset minargcount
568        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
569                touch ${SETTE_DIR}/output.sette
570        fi
571
572        echo "executing script : set_xio_field_defs $@" >> ${SETTE_DIR}/output.sette
573        echo "################" >> ${SETTE_DIR}/output.sette
574
575
576        [ -f ${EXE_DIR}/field_def_nemo-oce.xml ] || sed -i '/field_def_nemo-oce/d' $1
577        [ -f ${EXE_DIR}/field_def_nemo-ice.xml ] || sed -i '/field_def_nemo-ice/d' $1
578        [ -f ${EXE_DIR}/field_def_nemo-pisces.xml ] || sed -i '/field_def_nemo-pisces/d' $1
579
580        echo "finished script : set_xio_field_defs $@" >> ${SETTE_DIR}/output.sette
581        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
582        echo "                " >> ${SETTE_DIR}/output.sette
583}
Note: See TracBrowser for help on using the repository browser.