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