1 |
#!/bin/csh |
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 passaccuracy=7 |
13 |
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' " " Make " " " " Exact "# of" " " " " > summary.txt |
14 |
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 |
15 |
|
16 |
# Pass any arguments |
17 |
foreach arg ($argv) |
18 |
switch ($arg) |
19 |
case -clean: |
20 |
echo Cleaning ... |
21 |
foreach dr ([a-zA-Z01-9]*) |
22 |
if (-d $dr/input) then |
23 |
echo Entering $dr |
24 |
cd $dr/input |
25 |
echo "" |
26 |
make CLEAN |
27 |
\rm -f {*output,*high,*low}.txt *.log |
28 |
\rm -f ?ake* |
29 |
cd ../.. |
30 |
endif |
31 |
end |
32 |
rm -f summary.txt |
33 |
exit 0 |
34 |
breaksw |
35 |
case -nodie: |
36 |
unset on_error_die |
37 |
breaksw |
38 |
default: |
39 |
echo Unknown argument given to $0 |
40 |
exit 1 |
41 |
endsw |
42 |
end |
43 |
|
44 |
foreach dr ([a-zA-Z01-9]*) |
45 |
if (! -d $dr/input ) continue |
46 |
set config=- |
47 |
set makedepend=- |
48 |
set compile=- |
49 |
set execute=- |
50 |
set exactmatch=- |
51 |
set accuracy=- |
52 |
set pass=FAIL |
53 |
echo ============================================================================== |
54 |
echo Entering $dr |
55 |
cd $dr |
56 |
echo "" |
57 |
if (! -r results/output.txt) then |
58 |
echo " ***** No results to compare with *****" |
59 |
if (! $?untested) set untested |
60 |
set untested=($untested $dr) |
61 |
else |
62 |
set config=NO |
63 |
cd input |
64 |
echo -n " generating Makefile ..." |
65 |
../../../tools/genmake -mods=../code >&! make.log |
66 |
if ($status == 0) set config=Yes |
67 |
set makedepend=NO |
68 |
echo " done." |
69 |
echo -n " make depend ..." |
70 |
make cleanlinks depend >>& make.log |
71 |
if ($status == 0) set makedepend=Yes |
72 |
echo " done." |
73 |
echo -n " make ..." |
74 |
make >>& make.log |
75 |
if ($status) then |
76 |
echo " ***** An error occurred during make *****" |
77 |
cat make.log |
78 |
echo The error during compilation occured in \"$dr\" |
79 |
set compile=NO |
80 |
if ($?on_error_die) exit 1 |
81 |
else |
82 |
set compile=Yes |
83 |
set execute=NO |
84 |
endif |
85 |
echo " done." |
86 |
echo -n " running model ..." |
87 |
if ($compile == 'Yes') then |
88 |
./mitgcmuv | & grep "D iters" > output.txt |
89 |
if ($status == 0) then |
90 |
set execute=Yes |
91 |
set exactmatch=NO |
92 |
set accuracy=- |
93 |
echo " done." |
94 |
sed 's/.*D iters, err =//' output.txt \ |
95 |
| grep " 0 " \ |
96 |
> high.txt |
97 |
grep "D iters" ../results/output.txt \ |
98 |
| sed 's/.*D iters, err =//' \ |
99 |
| grep " 0 " \ |
100 |
> oldhigh.txt |
101 |
diff oldhigh.txt high.txt > /dev/null |
102 |
if ($status) then |
103 |
echo " output differs:" |
104 |
diff oldhigh.txt high.txt |
105 |
echo "" |
106 |
@ lvl=0 |
107 |
set accuracy='.' |
108 |
set fail |
109 |
echo -n Trying reduced accuracy |
110 |
while ($lvl <= $passaccuracy) |
111 |
@ lvl+=1 |
112 |
echo -n " " $lvl |
113 |
sed s/{$accuracy}E/E/ high.txt > low.txt |
114 |
sed s/{$accuracy}E/E/ oldhigh.txt > oldlow.txt |
115 |
diff oldlow.txt low.txt > /dev/null |
116 |
if ($status == 0) then |
117 |
unset fail |
118 |
break |
119 |
endif |
120 |
set accuracy=`echo $accuracy | sed 's/\./../'` |
121 |
end |
122 |
echo "" |
123 |
if ($?fail ) then |
124 |
if (! $?fails) set fails |
125 |
set fails=($fails $dr) |
126 |
set pass=FAIL |
127 |
echo " ***** FAIL *****" |
128 |
else |
129 |
if (! $?passes) set passes |
130 |
set passes=($passes $dr) |
131 |
set pass=Pass |
132 |
echo "" |
133 |
echo " ***** PASS (grade $lvl) *****" |
134 |
endif |
135 |
set accuracy=$lvl |
136 |
else |
137 |
set exactmatch=Yes |
138 |
set pass=Pass |
139 |
echo "" |
140 |
echo Model passed at highest accuracy. |
141 |
echo "" |
142 |
echo " ***** PASS *****" |
143 |
if (! $?passes) set passes |
144 |
set passes=($passes $dr) |
145 |
endif |
146 |
else |
147 |
echo " error" |
148 |
echo " ***** An error occured running the model *****" |
149 |
tail output.txt |
150 |
echo The runtime error occured in \"$dr\" |
151 |
if ($?on_error_die) exit 1 |
152 |
set pass=- |
153 |
endif |
154 |
endif |
155 |
cd .. |
156 |
endif |
157 |
echo "" |
158 |
cd .. |
159 |
# Pretty summary |
160 |
printresults: |
161 |
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 |
162 |
end |
163 |
echo ============================================================================== |
164 |
echo "" |
165 |
|
166 |
echo "Summary:" |
167 |
echo "" |
168 |
cat summary.txt |