/[MITgcm]/MITgcm/verification/testscript
ViewVC logotype

Contents of /MITgcm/verification/testscript

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.20 - (show annotations) (download)
Thu Dec 6 15:26:16 2001 UTC (22 years, 3 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint44e_post, release1-branch_tutorials, chkpt44c_post, checkpoint43a-release1mods, chkpt44a_pre, release1-branch-end, release1_final_v1, checkpoint44, chkpt44d_post, chkpt44a_post, checkpoint44b_pre, checkpoint44e_pre, chkpt44c_pre, release1-branch_branchpoint, checkpoint44b_post
Branch point for: release1_final, release1-branch
Changes since 1.19: +3 -3 lines
Switched default output to "long" so that the higher statistics
don't get ignored. Certain changes have been made that did
change these in the past...

1 #!/bin/sh
2
3 compare_lines()
4 {
5 # use codelet to compare lines
6 if [ $verbose -gt 1 ]; then
7 cat tmp3.txt 1>&2
8 fi
9 return `./a.out < tmp3.txt`
10 }
11
12 testoutput_for_prop()
13 {
14 # testoutput_for_prop dir s1 label
15 #
16 # compares files in $dir/input/output.txt and $dir/results.output.txt
17 # using search strings s1 and text label
18
19 if [ $debug -gt 0 ]; then
20 echo testoutput_for_prop: grep "$2" $1/input/output.txt 1>&2
21 fi
22 if [ -r $1/input/output.txt ]; then
23 grep "$2" $1/input/output.txt | sed 's/.*=//' | nl > tmp1.txt
24 else
25 echo testoutput_for_prop: output.txt from model run was not readable 1>&2
26 return 99
27 fi
28 if [ $debug -gt 0 ]; then
29 echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2
30 fi
31 grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt
32 if [ $debug -gt 0 ]; then
33 echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2
34 fi
35 join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt
36 if [ $debug -gt 0 ]; then
37 echo testoutput_for_prop: compare_lines 1>&2
38 fi
39 compare_lines
40 digits_of_similarity=$?
41 if [ $digits_of_similarity -eq 99 ]; then
42 if [ $verbose -gt 0 ]; then
43 echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2
44 fi
45 digits_of_similarity=99
46 else
47 if [ $verbose -gt 0 ]; then
48 echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2
49 fi
50 fi
51 rm tmp1.txt tmp2.txt tmp3.txt
52
53 return $digits_of_similarity
54 }
55
56 dashnum()
57 {
58 # dashnum n1 n2 n3 ...
59 #
60 # print numbers using %3i format or "--" if number = 99
61 for num in $@
62 do
63 if [ $num = 99 ]; then
64 printf ' --'
65 else
66 printf '%3i' $num
67 fi
68 done
69 }
70
71 testoutput()
72 {
73 # testoutput diretory
74 #
75 # test output in "directory"
76
77 if [ $debug -gt 0 ]; then
78 echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
79 fi
80 testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual"; cg2dres=$?
81 if [ $debug -gt 0 ]; then
82 echo testoutput: cg2dres=$cg2dres 1>&2
83 fi
84
85 if [ $longtest -gt 0 ]; then
86 testoutput_for_prop $1 "dynstat_theta_min" "theta minimum"; tmin=$?
87 testoutput_for_prop $1 "dynstat_theta_max" "theta maximum"; tmax=$?
88 testoutput_for_prop $1 "dynstat_theta_mean" "theta mean"; tmean=$?
89 testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d."; tsd=$?
90 testoutput_for_prop $1 "dynstat_salt_min" "salt minimum"; smin=$?
91 testoutput_for_prop $1 "dynstat_salt_max" "salt maximum"; smax=$?
92 testoutput_for_prop $1 "dynstat_salt_mean" "salt mean"; smean=$?
93 testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d."; ssd=$?
94 testoutput_for_prop $1 "dynstat_uvel_min" "U minimum"; umin=$?
95 testoutput_for_prop $1 "dynstat_uvel_max" "U maximum"; umax=$?
96 testoutput_for_prop $1 "dynstat_uvel_mean" "U mean"; umean=$?
97 testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d."; usd=$?
98 testoutput_for_prop $1 "dynstat_vvel_min" "V minimum"; vmin=$?
99 testoutput_for_prop $1 "dynstat_vvel_max" "V maximum"; vmax=$?
100 testoutput_for_prop $1 "dynstat_vvel_mean" "V mean"; vmean=$?
101 testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d."; vsd=$?
102 else
103 testoutput_for_prop $1 "dynstat_theta_min" "theta minimum"; tmin=$?
104 testoutput_for_prop $1 "dynstat_theta_max" "theta maximum"; tmax=$?
105 testoutput_for_prop $1 "dynstat_salt_min" "salt minimum"; smin=$?
106 testoutput_for_prop $1 "dynstat_salt_max" "salt maximum"; smax=$?
107 testoutput_for_prop $1 "dynstat_uvel_min" "U minimum"; umin=$?
108 testoutput_for_prop $1 "dynstat_uvel_max" "U maximum"; umax=$?
109 testoutput_for_prop $1 "dynstat_vvel_min" "V minimum"; vmin=$?
110 testoutput_for_prop $1 "dynstat_vvel_max" "V maximum"; vmax=$?
111 fi
112
113 dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \
114 $umin $umax $umean $usd $vmin $vmax $vmean $vsd
115 #printf '%3i' $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \
116 # $umin $umax $umean $usd $vmin $vmax $vmean $vsd
117 }
118
119 genmakemodel()
120 {
121 # genmakemodel directory
122 ( cd $1;
123 if [ $quick -eq 0 -o ! -r Makefile ]; then
124 printf 'genmake ... ' 1>&2
125 if [ $ieee -eq 0 ]; then
126 ../../../tools/genmake -mods=../code > make.log 2>&1
127 else
128 ../../../tools/genmake -ieee -mods=../code > make.log 2>&1
129 fi
130 if [ $? -ne 0 ]; then
131 tail make.log
132 echo genmakemodel: genmake failed 1>&2
133 return 1
134 else
135 echo succesful 1>&2
136 fi
137 fi
138 )
139 }
140
141 makecleancompile()
142 {
143 # makecleancompile directory
144 ( cd $1;
145 if [ $force -gt 0 ]; then
146 rm -f output.txt
147 printf 'make clean ... ' 2>&1
148 make CLEAN >> make.log 2>&1
149 if [ $? -ne 0 ]; then
150 tail make.log
151 echo makecleancompile: make clean failed 1>&2
152 return 1
153 else
154 echo succesful 1>&2
155 fi
156 fi
157 )
158 }
159
160 makecleanupafter()
161 {
162 # makeupafter directory
163 ( cd $1;
164 if [ $clean -gt 0 ]; then
165 rm -f output.txt
166 printf 'make clean ... ' 2>&1
167 make CLEAN >> make.log 2>&1
168 if [ $? -ne 0 ]; then
169 tail make.log
170 echo makeupafter: make clean failed 1>&2
171 return 1
172 else
173 echo succesful 1>&2
174 fi
175 fi
176 )
177 }
178
179 makedependmodel()
180 {
181 # makedependmodel directory
182 ( cd $1;
183 if [ $quick -eq 0 -o ! -r Makefile ]; then
184 printf 'make depend ... ' 1>&2
185 make cleanlinks >> make.log 2>&1
186 make depend >> make.log 2>&1
187 if [ $? -ne 0 ]; then
188 tail make.log
189 echo makemodel: make depend failed 1>&2
190 return 1
191 else
192 echo succesful 1>&2
193 fi
194 fi
195 )
196 }
197
198 makemodel()
199 {
200 # makemodel directory
201 ( cd $1;
202 if [ -r Makefile ]; then
203 printf 'make ... ' 1>&2
204 make >> make.log 2>&1
205 if [ $? -ne 0 ]; then
206 tail make.log
207 echo failed 1>&2
208 return 1
209 else
210 echo succesful 1>&2
211 fi
212 fi
213 )
214 }
215
216 runmodel()
217 {
218 # runmodel directory exe
219 #
220 # runs the model "exe" in "directory" (exe is relative to directory)
221
222 ( cd $1
223 if [ -x $2 ]; then
224 if [ $quick -eq 0 ]; then
225 rm -f output.txt
226 fi
227 printf 'runmodel: ' 1>&2
228 make output.txt && return 0
229 # if [ ! -r output.txt -o $quick -eq 0 ]; then
230 # echo runmodel: running... 1>&2
231 # ( ./$2 > output.txt 2>&1 ) && return 0
232 # rm -f output.txt
233 # ( make output.txt ) && return 0
234 # return 1
235 # else
236 # echo runmodel: output.txt is newer than executable 1>&2
237 # ( make output.txt ) && return 0
238 # return 0
239 # fi
240 # else
241 # echo runmodel: executable \"$1/$2\" is missing 1>&2
242 # return 1
243 fi
244 )
245 }
246
247 createcodelet()
248 {
249 # create codelet for comparing model output
250 cat > tmp_cmpnum.f <<EOFA
251 program cmpnum
252 implicit none
253 real*8 a,b,diff
254 integer linnum,best
255 best=-16
256 99 read(*,*,end=70,err=60) linnum,a,b
257 diff=0.5*(abs(a)+abs(b))
258 c print *,a,b,diff,abs(a-b)/diff
259 if (diff.gt.1.e-12) then
260 diff=abs(a-b)/diff
261 if (diff.gt.0.) then
262 c print *,int(log10(diff)),diff
263 linnum=int(log10(diff))
264 best=max(best,linnum)
265 endif
266 else
267 if (best.eq.-16.and.diff.ne.0.) best=-22
268 endif
269 goto 99
270 60 stop 'cmpnum: An error occured reading a,b'
271 70 print *,-best
272 end
273 EOFA
274 f77 tmp_cmpnum.f
275 if [ -x ./a.out ]; then
276 return 0
277 else
278 echo createcodelet: failed to compile codelet 1>&2
279 exit 1
280 fi
281 }
282
283 formatresults()
284 {
285 # formatresults expt genmake depend make run results*
286
287 nm=$1
288 printf '%s %s %s %s' $2 $3 $4 $5
289 shift; shift; shift; shift; shift;
290 printf '%3s' $@
291
292 if [ $1 = '--' ]; then
293 printf ' N/O '
294 else
295 if [ $1 -gt 12 ]; then
296 printf ' pass'
297 else
298 printf ' FAIL'
299 fi
300 fi
301 printf ' %s' $nm
302 printf '\n'
303
304 }
305
306 show_help()
307 {
308 cat - << EOF
309 $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
310 -help Show this help message
311 -quick Skip "genmake" and "make depend" if the Makefile exists
312 -quiet Reduce the amount of output
313 -verbose Produce copious amounts of output
314 -debug Produce even more output which will mean nothing to most
315 -force Do "make CLEAN" before compiling. This forces a complete rebuild.
316 -clean Do "make CLEAN" after compiling and testing.
317 -shorttest Don't compare numeric output for mean and s.d. of variables.
318 -noieee By default, $0 uses the -ieee option for genmake. This turns it off.
319
320 Normal usage:
321 $0 * Configure, compile, run and analyze in all experiment directories
322 EOF
323 }
324
325 scandirs()
326 {
327 if [ $# -eq 0 ]; then
328 for arg in *
329 do
330 test -d $arg/input && echo $arg
331 done
332 else
333 echo $*
334 fi
335 }
336
337 ###############################################################################
338
339 # Main function
340
341 # Default properties
342 debug=0
343 verbose=1
344 quick=0
345 force=0
346 clean=0
347 ieee=1
348 longtest=1
349 expts=''
350
351 # Process arguments
352 for arg in $@
353 do
354 case $arg in
355 -quick) quick=1;;
356 -verbose) verbose=2;;
357 -debug) debug=1;;
358 -force) force=1;;
359 -clean) clean=1;;
360 -noieee) ieee=0;;
361 -shorttest) longtest=0;;
362 -quiet) verbose=0;;
363 -help) show_help; exit 0;;
364 -*) echo Unrecognized option:$arg; exit 9;;
365 *) test -d $arg && expts=`echo $expts $arg`;;
366 esac
367 done
368
369 if [ $force -gt 0 -a $quick -gt 0 ]; then
370 echo You specified -quick and -force together which conflict.
371 echo Please specify either -quick or -force or neither but not both.
372 exit 1
373 fi
374
375 #if [ ${#expts} -eq 0 ]; then
376 # echo Scanning all directories
377 # for arg in *
378 # do
379 # test -d $arg && expts=`echo $expts $arg`
380 # done
381 #fi
382 expts=`scandirs $expts`
383
384 createcodelet
385
386 if [ $longtest -gt 0 ]; then
387 cat << EOF > summary.txt
388 T S U V
389 C D M c m s m s m s m s
390 n p a R g m m e . m m e . m m e . m m e .
391 f n k u 2 i a a d i a a d i a a d i a a d
392 g d e n d n x n . n x n . n x n . n x n .
393
394 EOF
395 else
396 cat << EOF > summary.txt
397 T S U V
398 C D M c
399 n p a R g m m m m m m m m
400 f n k u 2 i a i a i a i a
401 g d e n d n x n x n x n x
402
403 EOF
404 fi
405
406 # Now configue, make, run and test in each directory
407 for dir in $expts
408 do
409 if [ -r $dir/results/output.txt ]; then
410 echo -------------------------------------------------------------------------------
411 echo
412 echo Experiment: $dir
413 echo
414 unset genmake makedepend make run
415 if [ $longtest -gt 0 ]; then
416 results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
417 else
418 results='-- -- -- -- -- -- -- -- --'
419 fi
420 genmakemodel $dir/input && genmake=Y \
421 && makecleancompile $dir/input \
422 && makedependmodel $dir/input && makedepend=Y \
423 && makemodel $dir/input && make=Y \
424 && runmodel $dir/input mitgcmuv && run=Y \
425 && results=`testoutput $dir` \
426 && makecleanupafter $dir/input
427 echo
428 formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results
429 echo
430 formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results >> summary.txt
431 fi
432 done
433
434 rm tmp_cmpnum.f a.out
435
436 echo -------------------------------------------------------------------------------
437 echo
438 cat summary.txt

  ViewVC Help
Powered by ViewVC 1.1.22