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

source: utils/CI/sette/all_functions.sh

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

#2673 . Reintegrate sette developments back onto main sette branch. This action closes #2673

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