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