1 |
#! /usr/bin/env bash |
2 |
|
3 |
# $Header: /u/gcmpack/mitgcm.org/front_content/make_summary,v 1.74 2012/09/04 20:29:22 jmc Exp $ |
4 |
# |
5 |
# The purpose of this script is to create HTML summaries of the |
6 |
# directories produced by the "parse_emails" script. |
7 |
|
8 |
|
9 |
usage() |
10 |
{ |
11 |
echo |
12 |
echo "Usage: $0 [OPTIONS]" |
13 |
echo |
14 |
echo "where possible OPTIONS are:" |
15 |
echo " (-help|-h) print usage" |
16 |
echo " (-date |-d )PERIOD run for PERIOD=\"YYYY_MM\"" |
17 |
echo " [def=\"$PERIOD\"]" |
18 |
echo |
19 |
exit 1 |
20 |
} |
21 |
|
22 |
export LC_ALL="en_US.UTF-8" |
23 |
CURR_PER=`date +%Y`"_"`date +%m` |
24 |
# defaults |
25 |
PERIOD=$CURR_PER |
26 |
|
27 |
# Parse options |
28 |
ac_prev= |
29 |
for ac_option ; do |
30 |
|
31 |
# If the previous option needs an argument, assign it. |
32 |
if test -n "$ac_prev"; then |
33 |
eval "$ac_prev=\$ac_option" |
34 |
ac_prev= |
35 |
continue |
36 |
fi |
37 |
|
38 |
ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` |
39 |
|
40 |
case $ac_option in |
41 |
|
42 |
-help | --help | -h | --h) |
43 |
usage ;; |
44 |
|
45 |
-date | --date | -d | --d) |
46 |
ac_prev=PERIOD ;; |
47 |
--date=* | -date=*) |
48 |
PERIOD=$ac_optarg ;; |
49 |
|
50 |
*) |
51 |
echo "Error: don't understand argument \"$ac_option\"" |
52 |
usage |
53 |
;; |
54 |
|
55 |
esac |
56 |
|
57 |
done |
58 |
|
59 |
#INDIR="/net/orwell/export/export-9/mitgcm-testing/results/$PERIOD" |
60 |
#OUTDIR="/home/jmc/mitgcm/test_web/summary" |
61 |
INDIR="/u/u0/httpd/html/testing/results/$PERIOD" |
62 |
OUTDIR="/u/u0/httpd/html/testing/summary" |
63 |
|
64 |
OUTFILE=$OUTDIR"/output_"$PERIOD".html" |
65 |
res_url="http://mitgcm.org/testing/" |
66 |
|
67 |
# Create the links in $OUTFILE : |
68 |
echo "Creating the \"latest\" file for each machine: " |
69 |
the_date=`date` |
70 |
|
71 |
sed "s/_PERIOD/$PERIOD/" summary_head > $OUTFILE |
72 |
cat <<EOF >>$OUTFILE |
73 |
<table align="center" cellpadding="0" cellspacing="0" border="0" width="95%"> |
74 |
<tr bgcolor="#00cccc"> |
75 |
<td height="0"> <b>Nickname</b> </td> |
76 |
<td> <b>OPTFILE Name</b> </td> |
77 |
<td> <b>Type</b> </td> |
78 |
<td> <b>Date</b> </td> |
79 |
<td> <b>Summary</b> </td> |
80 |
<td> <b>Ratio</b> </td> |
81 |
</tr> |
82 |
|
83 |
EOF |
84 |
|
85 |
color="#bbffdd" |
86 |
ncolor="#bbddff" |
87 |
|
88 |
MACHINES="faulks meander aces- acesgrid baudelaire dickens danton beagle harbor" |
89 |
MACHINES="$MACHINES pleiades iblade rays solasrv sx8" |
90 |
MACHINES="$MACHINES trane dodongo dokdo stomp bigred" |
91 |
|
92 |
( cd $INDIR ; ls -1 -t */summary.txt | sed 's/\/summary.txt//' ) > ./dir_all |
93 |
|
94 |
MALL=`cat ./dir_all | sed -e 's|_| |g' | awk '{print $2}' | sort | uniq` |
95 |
for madd in $MALL ; do |
96 |
present=0 |
97 |
for m in $MACHINES ; do |
98 |
echo $madd | grep $m > /dev/null 2>&1 |
99 |
RETVAL=$? |
100 |
test $RETVAL = 0 && present=1 |
101 |
continue |
102 |
done |
103 |
test $present = 0 && MACHINES="$MACHINES $madd" |
104 |
done |
105 |
#MACHINES="baudelaire" |
106 |
|
107 |
for mname in $MACHINES ; do |
108 |
|
109 |
echo " $mname" |
110 |
|
111 |
dir_list=`grep $mname ./dir_all` |
112 |
echo -n "" > ./mlist |
113 |
|
114 |
for i in $dir_list ; do |
115 |
|
116 |
dir=$INDIR"/"$i |
117 |
OPTFILE= |
118 |
if test -r $dir/summary.txt ; then |
119 |
comm=`grep 'OPTFILE=' $dir/summary.txt` |
120 |
eval $comm |
121 |
OPTFILE=${OPTFILE##*/} |
122 |
fi |
123 |
if test "x$OPTFILE" = x -a -r "$dir/genmake_state" ; then |
124 |
comm=`grep 'OPTFILE=' $dir/genmake_state 2>/dev/null` |
125 |
eval $comm |
126 |
OPTFILE=${OPTFILE##*/} |
127 |
fi |
128 |
if test "x$OPTFILE" = x ; then |
129 |
comm=`grep '^# OPTFILE=' $dir/*/Makefile* 2>/dev/null | head -1` |
130 |
comm=${comm##*#} |
131 |
eval $comm |
132 |
OPTFILE=${OPTFILE##*/} |
133 |
fi |
134 |
if test "x$OPTFILE" = x ; then |
135 |
OPTFILE="not_explicitly_specified" |
136 |
fi |
137 |
|
138 |
# EXTRA = non-standard list of experiment |
139 |
ADJOINT= |
140 |
TANGLIN= |
141 |
RESTART=0 |
142 |
EXTRA= |
143 |
FAST=0 |
144 |
DVLP=0 |
145 |
MPI=0 |
146 |
MTH=0 |
147 |
UR4=0 |
148 |
if test -r $dir/summary.txt ; then |
149 |
comm=`grep 'ADJOINT=true' $dir/summary.txt 2>/dev/null` |
150 |
eval $comm |
151 |
comm=`grep 'TANGLIN=true' $dir/summary.txt 2>/dev/null` |
152 |
eval $comm |
153 |
RESTART=`grep -c 'test 2+2=4 summary' $dir/summary.txt` |
154 |
comm=`grep '^run: .*testreport.* ' $dir/summary.txt` |
155 |
EXTRA=`echo "$comm" | grep " -*-tdir\>" | sed -e "s/^.* -*-tdir\>//" -e "s/ -.*$//"` |
156 |
if test "x$EXTRA" = x ; then |
157 |
EXTRA=`echo "$comm" | grep " -*-t\>" | sed -e "s/^.*-*-t\>//" -e "s/ -.*$//"` |
158 |
fi |
159 |
if test "x$EXTRA" = x ; then EXTRA=0 ; else |
160 |
#echo -n "EXTRA=$EXTRA" |
161 |
nn0=`echo $EXTRA | sed "s/ *' *//g" | wc -w` |
162 |
nn1=`echo $EXTRA | sed "s/ *' *//g" | tr ' ' '\n' | grep -c "\<monod_"` |
163 |
nn2=`echo $EXTRA | sed "s/ *' *//g" | tr ' ' '\n' | grep -c "\<darwin_"` |
164 |
EXTRA=1 |
165 |
if [ $nn1 -ge 2 ] ; then EXTRA=2 ; fi |
166 |
if [ $nn2 -ge 2 ] ; then EXTRA=3 ; fi |
167 |
#echo " : nn0=$nn0 ; nn1=$nn1 ; nn2=$nn2" |
168 |
fi |
169 |
FAST=`echo "$comm" | grep -c " -*-fast\>"` |
170 |
if test "x$FAST" = x0 ; then |
171 |
FAST=`echo "$comm" | grep -c " '*-noieee'*"` |
172 |
fi |
173 |
DVLP=`echo "$comm" | grep -c " -*-devel\>"` |
174 |
MPI=`echo "$comm" | grep -c " -*-mpi\>"` |
175 |
if test "x$MPI" = x0 ; then |
176 |
MPI=`echo "$comm" | grep -c " -*-MPI\>"` |
177 |
fi |
178 |
MTH=`echo "$comm" | grep -c " -*-mth\>"` |
179 |
UR4=`echo "$comm" | grep -c " -*-use_r4\>"` |
180 |
if test "x$UR4" = x0 ; then |
181 |
UR4=`echo "$comm" | grep -c " -*-ur4\>"` |
182 |
fi |
183 |
fi |
184 |
if test "x$ADJOINT" = xtrue ; then |
185 |
kind="adjoint" ; order=0 |
186 |
elif test "x$TANGLIN" = xtrue ; then |
187 |
kind="tanglin" ; order=1 |
188 |
elif test "x$RESTART" = x0 ; then |
189 |
kind="forward" ; order=2 |
190 |
else |
191 |
kind="restart" ; order=3 |
192 |
fi |
193 |
order=`expr $order + 10 \* $EXTRA` |
194 |
order=`printf '%3.3i' $order` |
195 |
if test "x$UR4" = x1 ; then |
196 |
OPTFILE="${OPTFILE}.use_r4" |
197 |
fi |
198 |
if test "x$MPI" = x1 ; then |
199 |
yy=`echo $OPTFILE | grep -c '+mpi'` |
200 |
if test $yy = 0 ; then OPTFILE="${OPTFILE}+mpi" ; fi |
201 |
fi |
202 |
if test "x$MTH" = x1 ; then |
203 |
yy=`echo $OPTFILE | grep -c '+mth$'` |
204 |
if test $yy = 0 ; then OPTFILE="${OPTFILE}+mth" ; fi |
205 |
fi |
206 |
if test "x$FAST" = x1 ; then |
207 |
OPTFILE="${OPTFILE}.fast" |
208 |
fi |
209 |
if test "x$DVLP" = x1 ; then |
210 |
OPTFILE="${OPTFILE}.dvlp" |
211 |
fi |
212 |
|
213 |
t_pass="--" |
214 |
t_tot="--" |
215 |
if test -r $dir/summary.txt ; then |
216 |
grep '^[YN] [YN] [YN] [YN]' $dir/summary.txt > ./all_tests 2>/dev/null |
217 |
t_tot=`cat ./all_tests | wc -l | sed -e 's| ||g'` |
218 |
t_pass=`grep '^Y Y Y Y' ./all_tests | grep 'pass ' | wc -l | sed -e 's| ||g'` |
219 |
fi |
220 |
rm -f ./all_tests |
221 |
# echo "${dir##*/} : $t_pass out of $t_tot" |
222 |
|
223 |
tokens=`echo $i | sed -e 's|_| |g'` |
224 |
echo "" > ./ms_tmp |
225 |
for tok in $tokens ; do |
226 |
echo $tok >> ./ms_tmp |
227 |
done |
228 |
DAY=`cat ./ms_tmp | awk '(length($1)==8 && substr($1,0,2)=="20")'` |
229 |
rm -f ./ms_tmp |
230 |
|
231 |
echo "$OPTFILE$order $DAY $OPTFILE $kind $i $t_pass:$t_tot" >> ./mlist |
232 |
|
233 |
done |
234 |
|
235 |
# helpful for debugging |
236 |
# cat ./mlist |
237 |
|
238 |
# Do we have any data? If so, create the latest pointer. |
239 |
num=`wc -l ./mlist | awk '{print $1}'` |
240 |
if test $num -gt 0 ; then |
241 |
|
242 |
# swap colors |
243 |
ctmp=$color |
244 |
color=$ncolor |
245 |
ncolor=$ctmp |
246 |
|
247 |
keys=`cat ./mlist | cut -d " " -f 1 | sort | uniq` |
248 |
|
249 |
for key in $keys ; do |
250 |
tline=`grep "^$key " ./mlist | head -1` |
251 |
ratio=`echo $tline | cut -d " " -f 6` |
252 |
ldir=`echo $tline | cut -d " " -f 5` |
253 |
kind=`echo $tline | cut -d " " -f 4` |
254 |
optf=`echo $tline | cut -d " " -f 3` |
255 |
DAY=`echo $tline | cut -d " " -f 2` |
256 |
URL="results/$PERIOD/$ldir" |
257 |
#-- machine name to print: |
258 |
sname=`echo $mname | sed 's/-$//'` |
259 |
alt=`echo $key | sed "s/$optf//"` |
260 |
#if [ $alt -ge 30 ] ; then sname="${sname}.darwin" |
261 |
#elif [ $alt -ge 20 ] ; then sname="${sname}.monod" ; fi |
262 |
cat <<EOF >>$OUTFILE |
263 |
<tr bgcolor="$color"> |
264 |
<td height="0"> $sname </td> |
265 |
<td> $optf </td> |
266 |
<td> $kind </td> |
267 |
<td> <a href="$res_url$URL">$DAY</a> </td> |
268 |
<td> <a href="$res_url$URL/summary.txt"> summary.txt </a> </td> |
269 |
<td> $ratio </td> |
270 |
</tr> |
271 |
EOF |
272 |
done |
273 |
fi |
274 |
|
275 |
done |
276 |
|
277 |
cat >> $OUTFILE << EOF |
278 |
<tr bgcolor="#00cccc"> |
279 |
<td height="0" colspan="6" align="center" >This table generated on: $the_date</td> |
280 |
</tr> |
281 |
|
282 |
</table> |
283 |
|
284 |
<p>Examples of the scripts used for these testing runs can be obtained from: <a |
285 |
href="http://mitgcm.org/viewvc/MITgcm/MITgcm/tools/example_scripts/"> |
286 |
MITgcm/tools/example_scripts</a>.</p> |
287 |
|
288 |
|
289 |
</body> |
290 |
</html> |
291 |
|
292 |
EOF |
293 |
|
294 |
rm -f ./dir_all ./mlist |
295 |
|
296 |
#- put the file in place |
297 |
chgrp gcmpack $OUTFILE |
298 |
chmod 664 $OUTFILE |
299 |
LATEST=$OUTDIR"/latest_"$PERIOD".html" |
300 |
mv -f $OUTFILE $LATEST |
301 |
|
302 |
if test "x$PERIOD" = "x$CURR_PER" ; then |
303 |
cp $LATEST ./testing.xml |
304 |
( |
305 |
cd $OUTDIR |
306 |
rm -f latest.html |
307 |
ln -s $LATEST latest.html |
308 |
) |
309 |
fi |