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 @ 14869

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

Branch: sette_ticket2673. Added missing export for NEMO_VALID. Also tidied up scripts with new set_namelist_opt function and adapting set_xio_using_server function to accept yes/no as well as true/false

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 22.4 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}/tracer.stat ] && cp ${EXE_DIR}/*tracer.stat ${NEMO_VALIDATION_DIR}/.
382    [ -f ${EXE_DIR}/timing.output ] && cp ${EXE_DIR}/*timing.output ${NEMO_VALIDATION_DIR}/.
383
384    if [ -n "$(ls ${NEMO_VALIDATION_DIR}/*run*)" ] ; then
385   echo "moved run.stat in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
386   echo "moved run.stat in ${NEMO_VALIDATION_DIR} directory" 
387    else
388   echo "problem in looking for run.stat file in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
389   echo "run.stat IS NOT in ${NEMO_VALIDATION_DIR} directory" 
390    fi
391    if [ -n "$(ls ${NEMO_VALIDATION_DIR}/*ocean.output*)" ] ; then
392   echo "moved ocean.output in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
393   echo "moved ocean.output in ${NEMO_VALIDATION_DIR} directory" 
394    else
395   echo "problem in looking for ocean.output file in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
396   echo "ocean.output IS NOT in ${NEMO_VALIDATION_DIR} directory" 
397    fi
398    if [ -n "$(ls ${NEMO_VALIDATION_DIR}/*tracer.stat*)" ] ; then
399        echo "moved tracer.stat in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
400        echo "moved tracer.stat in ${NEMO_VALIDATION_DIR} directory"
401    else
402        echo "problem in looking for tracer.stat file in ${NEMO_VALIDATION_DIR} directory"  >> ${SETTE_DIR}/output.sette
403        echo "tracer.stat IS NOT in ${NEMO_VALIDATION_DIR} directory"
404    fi
405}
406
407#############################################################
408# extra functions to manipulate settings in the iodef.xml file
409#
410# Examples:
411#   set_xio_file_type    iodef.xml one_file
412#   set_xio_using_server iodef.xml true
413#   set_xio_buffer_size  iodef.xml 50000000
414#   set_xio_field_defs   iodef.xml
415#
416#############################################################
417
418usage2=" Usage : set_xio_file_type input_iodef.xml one_file||multiple_file"
419usage3=" Usage : set_xio_using_server input_iodef.xml true||false"
420usage4=" Usage : set_xio_buffer_size input_iodef.xml int_buffer_size"
421usage5=" Usage : set_xio_field_defs input_iodef.xml"
422
423set_xio_file_type () {
424        minargcount=2
425        if [ ${#} -lt ${minargcount} ]
426        then
427                echo "not enough arguments for set_xio_file_type"
428                echo "${usage2}"
429                exit 1
430        fi
431        if [ $2 != "one_file" ] && [ $2 != "multiple_file" ]
432        then
433                echo "unrecognised argument for set_xio_file_type"
434                echo "${usage2}"
435                echo $2
436                exit 1
437        fi
438        unset minargcount
439        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
440                touch ${SETTE_DIR}/output.sette
441        fi
442
443        echo "executing script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
444        echo "################" >> ${SETTE_DIR}/output.sette
445
446        VAR_NAME=$( grep "^.*<.*file_definition.*type.*=" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
447        if [ ${#VAR_NAME} -eq 0 ]
448        then
449                echo "doing \"set_xio_file_type $@\". "
450                echo "xml_tag: file_definition with variable: type is empty"
451                echo "confirm that an appropriate file_definition is in \"${EXE_DIR}/$1\" "
452                echo "exit"
453                echo "error in executing script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
454                echo "....." >> ${SETTE_DIR}/output.sette
455                exit 1
456        fi
457        if [ $2 == "one_file" ] 
458        then
459           sed -e "s:multiple_file:one_file:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
460        else
461           sed -e "s:one_file:multiple_file:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
462        fi
463        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
464
465        echo "finished script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
466        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
467        echo "                " >> ${SETTE_DIR}/output.sette
468}
469
470set_xio_using_server () {
471        minargcount=2
472        if [ ${#} -lt ${minargcount} ]
473        then
474                echo "not enough arguments for set_xio_using_server"
475                echo "${usage2}"
476                exit 1
477        fi
478        inarg=$2
479        if [ ${inarg} == "yes" ] ; then inarg="true" ; fi
480        if [ ${inarg} == "no" ]  ; then inarg="false" ; fi
481        if [ ${inarg} != "true" ] && [ ${inarg} != "false" ]
482        then
483                echo "unrecognised argument for set_xio_using_server"
484                echo "${usage2}"
485                echo ${inarg}
486                exit 1
487        fi
488        unset minargcount
489        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
490                touch ${SETTE_DIR}/output.sette
491        fi
492
493        echo "executing script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
494        echo "################" >> ${SETTE_DIR}/output.sette
495
496        VAR_NAME=$( grep "^.*<.*variable id.*=.*using_server.*=.*bool" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
497        if [ ${#VAR_NAME} -eq 0 ]
498        then
499                echo "doing \"set_xio_using_server $@\". "
500                echo "xml_tag: "variable id=using_server" with variable: bool is empty"
501                echo "confirm that an appropriate variable id is in \"${EXE_DIR}/$1\" "
502                echo "exit"
503                echo "error in executing script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
504                echo "....." >> ${SETTE_DIR}/output.sette
505                exit 1
506        fi
507        if [ ${inarg} == "false" ]
508        then
509           sed -e "/using_server/s:true:false:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
510           export USING_MPMD=no
511        else
512           sed -e "/using_server/s:false:true:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
513           export USING_MPMD=yes
514        fi
515        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
516
517        echo "finished script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
518        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
519        echo "                " >> ${SETTE_DIR}/output.sette
520}
521
522set_xio_buffer_size () {
523        minargcount=2
524        if [ ${#} -lt ${minargcount} ]
525        then
526                echo "not enough arguments for set_xio_buffer_size"
527                echo "${usage4}"
528                exit 1
529        fi
530        unset minargcount
531        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
532                touch ${SETTE_DIR}/output.sette
533        fi
534
535        echo "executing script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
536        echo "################" >> ${SETTE_DIR}/output.sette
537
538        VAR_NAME=$( grep "^.*<.*variable id.*=.*buffer_size.*=.*integer" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
539        if [ ${#VAR_NAME} -eq 0 ]
540        then
541                echo "doing \"set_xio_buffer_size $@\". "
542                echo "xml_tag: "variable id=buffer_size" with variable: integer is empty"
543                echo "confirm that an appropriate variable id is in \"${EXE_DIR}/$1\" "
544                echo "exit"
545                echo "error in executing script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
546                echo "....." >> ${SETTE_DIR}/output.sette
547                exit 1
548        fi
549        sed -e "/buffer_size/s:>.*<:>$2<:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
550        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
551
552        echo "finished script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
553        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
554        echo "                " >> ${SETTE_DIR}/output.sette
555}
556
557set_xio_field_defs () {
558        minargcount=1
559        if [ ${#} -lt ${minargcount} ]
560        then
561                echo "not enough arguments for set_xio_field_defs"
562                echo "${usage5}"
563                exit 1
564        fi
565        unset minargcount
566        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
567                touch ${SETTE_DIR}/output.sette
568        fi
569
570        echo "executing script : set_xio_field_defs $@" >> ${SETTE_DIR}/output.sette
571        echo "################" >> ${SETTE_DIR}/output.sette
572
573
574        [ -f ${EXE_DIR}/field_def_nemo-oce.xml ] || sed -i '/field_def_nemo-oce/d' $1
575        [ -f ${EXE_DIR}/field_def_nemo-ice.xml ] || sed -i '/field_def_nemo-ice/d' $1
576        [ -f ${EXE_DIR}/field_def_nemo-pisces.xml ] || sed -i '/field_def_nemo-pisces/d' $1
577
578        echo "finished script : set_xio_field_defs $@" >> ${SETTE_DIR}/output.sette
579        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
580        echo "                " >> ${SETTE_DIR}/output.sette
581}
Note: See TracBrowser for help on using the repository browser.