1 |
#!/bin/csh -f |
2 |
|
3 |
# Run this script from the verification directory |
4 |
# It will automatically configure, compile, run and verify all experiments |
5 |
# in the verification directory for whcih there is an results/output.txt |
6 |
# file. |
7 |
|
8 |
# This is the number of least-significant digits allows to be |
9 |
# in error before the test is classified as a "fail". |
10 |
|
11 |
set on_error_die |
12 |
set digitsOfAccuracy=8 |
13 |
set SKIP=( ) |
14 |
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' " " Make " " " " Exact "# of" " " " " > summary.txt |
15 |
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' Config Depend Compile Execute Match Digits Status Experiment >> summary.txt |
16 |
|
17 |
# Pass any arguments |
18 |
foreach arg ($argv) |
19 |
switch ($arg) |
20 |
case -clean: |
21 |
echo Cleaning ... |
22 |
foreach dr ([a-zA-Z01-9]*) |
23 |
if (-d $dr/input) then |
24 |
echo Entering $dr |
25 |
cd $dr/input |
26 |
echo "" |
27 |
make CLEAN |
28 |
\rm -f {*output,*high,*low}.txt *.log |
29 |
\rm -f ?ake* |
30 |
cd ../.. |
31 |
endif |
32 |
end |
33 |
rm -f summary.txt |
34 |
exit 0 |
35 |
breaksw |
36 |
case -nodie: |
37 |
unset on_error_die |
38 |
breaksw |
39 |
case -skip=*: |
40 |
set SKIP = ( $SKIP `echo $arg | sed 's/-skip=//' | sed 's/,/ /g' `) |
41 |
breaksw |
42 |
default: |
43 |
echo Unknown argument given to $0 |
44 |
exit 1 |
45 |
endsw |
46 |
end |
47 |
|
48 |
# Need to make sure we don't meet non-model problems ... |
49 |
unlimit |
50 |
|
51 |
foreach dr ([a-zA-Z01-9]*) |
52 |
|
53 |
if (! -d $dr/input ) continue |
54 |
foreach skip ($SKIP) |
55 |
if ( `echo $dr | sed s/$skip.'*'//` == '' ) continue;continue |
56 |
end |
57 |
set config=- |
58 |
set makedepend=- |
59 |
set compile=- |
60 |
set execute=- |
61 |
set exactmatch=- |
62 |
set accuracy=- |
63 |
set pass=FAIL |
64 |
echo ============================================================================== |
65 |
echo Entering $dr |
66 |
cd $dr |
67 |
echo "" |
68 |
if (! -r results/output.txt) then |
69 |
echo " ***** No results to compare with *****" |
70 |
if (! $?untested) set untested |
71 |
set untested=($untested $dr) |
72 |
else |
73 |
set config=NO |
74 |
cd input |
75 |
echo -n " generating Makefile ..." |
76 |
../../../tools/genmake -mods=../code >&! make.log |
77 |
if ($status == 0) set config=Yes |
78 |
set makedepend=NO |
79 |
echo " done." |
80 |
echo -n " make depend ..." |
81 |
make cleanlinks depend >>& make.log |
82 |
if ($status == 0) set makedepend=Yes |
83 |
echo " done." |
84 |
echo -n " make ..." |
85 |
make >>& make.log |
86 |
if ($status) then |
87 |
echo " ***** An error occurred during make *****" |
88 |
cat make.log |
89 |
echo The error during compilation occured in \"$dr\" |
90 |
set compile=NO |
91 |
if ($?on_error_die) exit 1 |
92 |
else |
93 |
set compile=Yes |
94 |
set execute=NO |
95 |
endif |
96 |
echo " done." |
97 |
echo -n " running model ..." |
98 |
if ($compile == 'Yes') then |
99 |
./mitgcmuv > & output.txt |
100 |
if ($status == 0) then |
101 |
set execute=Yes |
102 |
set exactmatch=NO |
103 |
set accuracy=- |
104 |
echo " done." |
105 |
|
106 |
# Compare output based on cg2d residual |
107 |
grep "cg2d_init_res" output.txt | sed 's/.*=//' | nl > high.txt |
108 |
grep "cg2d_init_res" ../results/output.txt | sed 's/.*=//' | nl > oldhigh.txt |
109 |
join high.txt oldhigh.txt > low.txt |
110 |
set nlines=`wc -l low.txt | awk '{print $1}'` |
111 |
echo " comparing $nlines lines of output" |
112 |
@ line = 1 |
113 |
set bestacc=99; |
114 |
set worstline='Exact match' |
115 |
while ($line <= $nlines) |
116 |
set vals=(`grep "^$line" low.txt | awk '{print $2,$3}'`) |
117 |
@ line += 1 |
118 |
unset acc |
119 |
foreach dp (14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) |
120 |
set cmp=(`printf '%23.'$dp'e %23.'$dp'e\n' $vals[1] $vals[2]`) |
121 |
if ($cmp[1] =~ $cmp[2]) then |
122 |
if (! $?acc) then |
123 |
set acc=$dp |
124 |
break |
125 |
endif |
126 |
endif |
127 |
end |
128 |
if (! $?acc) set acc=0 |
129 |
if ($acc < $bestacc) then |
130 |
set worstline=($line $vals[1] $vals[2] `printf '%23.'$acc'e' $vals[1]` $acc) |
131 |
set bestacc=$acc |
132 |
endif |
133 |
# echo $line $vals[1] $vals[2] `printf '%23.'$acc'e' $vals[1]` $acc |
134 |
end |
135 |
if ($nlines == 0) then |
136 |
set bestacc=0 |
137 |
set worstline="Could find no lines in output.txt to compare" |
138 |
endif |
139 |
if ($bestacc == 14 & $?exactmatch) then |
140 |
set exactmatch=Yes |
141 |
echo " " |
142 |
echo " ***** EXACT MATCH *****" |
143 |
endif |
144 |
if ($bestacc > $digitsOfAccuracy) then |
145 |
set pass=Pass |
146 |
echo " " |
147 |
echo " ***** PASS (digits=$bestacc) *****" |
148 |
echo " " |
149 |
echo " worstline: " $worstline |
150 |
else |
151 |
echo " " |
152 |
echo " ***** FAIL (digits=$bestacc) *****" |
153 |
echo " " |
154 |
echo " worstline: " $worstline |
155 |
endif |
156 |
set accuracy=$bestacc |
157 |
else |
158 |
echo " error" |
159 |
echo " ***** An error occured running the model *****" |
160 |
tail output.txt |
161 |
echo The runtime error occured in \"$dr\" |
162 |
if ($?on_error_die) exit 1 |
163 |
set pass=- |
164 |
endif |
165 |
rm -f high.txt oldhigh.txt low.txt oldlow.txt output.txt make.log |
166 |
endif |
167 |
cd .. |
168 |
endif |
169 |
echo "" |
170 |
cd .. |
171 |
# Pretty summary |
172 |
printresults: |
173 |
printf ' %s\t %s\t %s\t %s\t %s\t %s\t %s\t%s\n' $config $makedepend $compile $execute $exactmatch $accuracy $pass $dr >> summary.txt |
174 |
end |
175 |
echo ============================================================================== |
176 |
echo "" |
177 |
|
178 |
echo "Summary:" |
179 |
echo "" |
180 |
cat summary.txt |