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