/[MITgcm]/MITgcm/tools/do_tst_2+2
ViewVC logotype

Contents of /MITgcm/tools/do_tst_2+2

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.14 - (show annotations) (download)
Sun Apr 29 22:11:17 2012 UTC (11 years, 11 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63n, checkpoint63o
Changes since 1.13: +9 -2 lines
use date corresponding to "Start-time" of previous testreport output
 (if any, otherwise use current date) for result directory name.

1 #! /usr/bin/env bash
2
3 # $Header: /u/gcmpack/MITgcm/tools/do_tst_2+2,v 1.13 2011/05/19 13:18:43 jmc Exp $
4 # $Name: $
5
6 usage()
7 {
8 echo "Usage: `basename $0` [OPTIONS]"
9 echo " -> perform test 2+2=4 for several experiments"
10 echo ""
11 echo "where possible OPTIONS are:"
12 echo " -help : print usage"
13 echo " -t LIST_EXP : only check experiments in LIST_EXP"
14 echo " -skd LIST_EXP : skip experiments in LIST_EXP"
15 echo " -exe COMMAND : use COMMAND to run the tests"
16 echo " -mpi : run the tests using MPI"
17 echo " -mf STRING :(MPI) file with list of possible machines to run on"
18 echo " -o STRING : used to build output directory name"
19 echo " (DEF=\"hostname\")"
20 echo " -a,-A STRING : email address to send output to"
21 echo " (DEF=\"\" no email is sent)"
22 echo " (-A: + save each log file)"
23 echo " -clean : clean output & reset"
24 exit
25 }
26
27 CLEAN=0
28 TESTDIRS=
29 SKIPDIRS=
30 SCRIPT='../tools/tst_2+2'
31 LOGFILE='tst_2+2_out.log'
32 scrArg='All'
33 COMMAND=
34 mpi=0
35 MPI_MFILE=
36 OUTDIR=`hostname | sed 's/\..*$//'`
37 SAVELOG=0
38 ADDRESS=
39 MPACK="../tools/mpack-1.6/mpack"
40 here=`pwd`
41 yy=
42 for xx
43 do
44 if test -n "$yy"; then
45 eval "$yy=\$xx"
46 yy=
47 else
48 case $xx in
49 -help ) usage ;;
50 -clean) CLEAN=1 ;;
51 -t ) yy=TESTDIRS ;;
52 -skd ) yy=SKIPDIRS ;;
53 -exe ) yy=COMMAND ;;
54 -mpi ) mpi=1 ;;
55 -mf ) yy=MPI_MFILE ;;
56 -a ) yy=ADDRESS ;;
57 -A ) yy=ADDRESS ; SAVELOG=1 ;;
58 -o ) yy=OUTDIR ;;
59 *) echo "Error: unrecognized option: "$xx ; usage ; exit ;;
60 esac
61 fi
62 done
63 #------------------------
64
65 if test "x$TESTDIRS" = x ; then TESTDIRS=`ls ` ; fi
66 LIST=""
67 for xx in $TESTDIRS
68 do
69 yy=`echo $SKIPDIRS | grep -c $xx`
70 if test $yy = 0 ; then
71 if test -f $xx/results/output.txt ; then
72 LIST=${LIST}" "$xx
73 # else
74 # echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
75 fi
76 # else
77 # echo ""; echo -n " -- skip \"$xx\" (excluded)"
78 fi
79 done
80
81 if test -x $SCRIPT ; then
82 echo "run script '$SCRIPT' for experiment in:"
83 echo " $LIST"
84 yy=`echo $SCRIPT | grep -c '^\/'`
85 if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi
86 else
87 echo "ERROR: script '$SCRIPT' not found or not executable"
88 exit
89 fi
90 echo ""
91 #------------------------
92
93 if test $CLEAN = 1 ; then
94 for xx in $LIST
95 do
96 listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )`
97 for yy in $listD
98 do
99 if test -r $xx/$yy/data.tst ; then
100 echo "clean dir:" $xx/$yy
101 cd $xx/$yy
102 echo ' ' >> $LOGFILE
103 echo $SCRIPT 4 >> $LOGFILE
104 $SCRIPT 4 >> $LOGFILE 2>&1
105 cd $here
106 fi
107 done
108 done
109 exit
110 fi
111 #------------------------
112 # Create a uniquely named directory to store results
113 CMDLINE=$0
114 for xx in "$@" ; do nw=`echo $xx | wc -w`
115 if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
116 else CMDLINE="$CMDLINE '$xx'" ; fi
117 done
118 #for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done
119 DATE=''
120 if test -f tr_out.txt ; then
121 # try to use the date corresponding to 'Start time:' in file "tr_out.txt" :
122 sTime=`grep '^Start time: ' tr_out.txt 2>/dev/null | sed 's/Start time: //'`
123 if test "x$sTime" != x ; then DATE=`date -d "$sTime" "+%Y%m%d" 2>/dev/null` ; fi
124 fi
125 # otherwise, use current date:
126 if test "x$DATE" = x ; then DATE=`date +%Y%m%d`; fi
127 BASE="rs_"$OUTDIR"_"$DATE"_"
128 xx=0
129 DRESULTS="$BASE$xx"
130 while test -e $DRESULTS ; do
131 xx=$(( $xx + 1 ))
132 DRESULTS="$BASE$xx"
133 done
134 mkdir $DRESULTS
135 out=$?
136 if test "x$out" != x0 ; then
137 echo "ERROR: Can't create results directory \"./$DRESULTS\""
138 exit 1
139 fi
140 SUMMARY="$DRESULTS/summary.txt"
141 OPTFILE=
142
143 printf "Start time: " > $SUMMARY
144 date >> $SUMMARY
145 echo 'run:' $CMDLINE >> $SUMMARY
146 if test -f tr_out.txt ; then
147 echo ' using output from:' >> $SUMMARY
148 sed -n '2,/^ OPTFILE=/ p' tr_out.txt >> $SUMMARY
149 echo >> $SUMMARY
150 fi
151 echo 'test 2+2=4 summary :' >> $SUMMARY
152 echo >> $SUMMARY
153 echo 'P. Run Result experiment' >> $SUMMARY
154 echo ' 1 2 3' >> $SUMMARY
155
156 #-- For MPI test:
157 LOC_MFILE='tr_mpi_mfile'
158 RUNOUTP="output.txt"
159 if [ $mpi -ge 1 ] ; then
160 SCRIPT="$SCRIPT -mpi"
161 RUNOUTP="STDOUT.0000"
162 fi
163
164 for xx in $LIST
165 do
166 echo ==============================================================================
167 if [ $mpi -le 0 ] ; then
168 rCommand=$COMMAND
169 else
170 LOC_NPROC=2
171 mpi_size=$xx/build/SIZE.h.mpi
172 if test -f $mpi_size ; then
173 px=`grep '^ & *nPx *=' $mpi_size | sed 's/^ & *nPx *= *//' | sed 's/, *$//'`
174 py=`grep '^ & *nPy *=' $mpi_size | sed 's/^ & *nPy *= *//' | sed 's/, *$//'`
175 pp=`expr $px \* $py` > /dev/null 2>&1 ; out=$?
176 if test "x$out" = x0 ; then LOC_NPROC=$pp ; fi
177 fi
178 rCommand=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"`
179 if test "x$MPI_MFILE" != x ; then
180 #- create new MPI machine-file with the right number of Procs
181 rm -f $LOC_MFILE
182 cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE
183 nl=`wc -l $LOC_MFILE | awk '{print $1}'`
184 if [ $nl -lt $LOC_NPROC ] ; then
185 rm -f $LOC_MFILE
186 cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE
187 fi
188 rCommand=`echo $rCommand | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"`
189 fi
190 fi
191
192 listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )`
193 for yy in $listD
194 do
195 if test -f $xx/$yy/$RUNOUTP ; then
196 if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then
197 comm=`grep '^# OPTFILE=' $xx/build/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
198 echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state
199 sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state
200 echo " $comm" >> $DRESULTS/genmake_state
201 eval $comm
202 gmkLog=$xx/build/genmake.log
203 grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
204 out=$?
205 if test "x$out" = x0 ; then
206 echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
207 sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \
208 | grep -v '^... compiler version ' > tr_vers.tmp_log
209 sed -n '1,/^$/p' tr_vers.tmp_log | sed '/^$/d' | sed 's/^./ &/' \
210 >> $DRESULTS/genmake_state
211 rm -f tr_vers.tmp_log
212 fi
213 fi
214 if test $yy = 'run' ; then nam=$xx
215 else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi
216 echo -n "Entering $xx/$yy :"
217 cd $xx/$yy
218 pwd > $LOGFILE
219 if test "x$COMMAND" = x ; then
220 echo $SCRIPT $scrArg >> $LOGFILE ; echo ' ' >> $LOGFILE
221 $SCRIPT $scrArg >> $LOGFILE 2>&1
222 out=$?
223 else
224 echo "$SCRIPT $scrArg -command \"$rCommand\"" >> $LOGFILE
225 echo ' ' >> $LOGFILE
226 $SCRIPT $scrArg -command "$rCommand" >> $LOGFILE 2>&1
227 out=$?
228 fi
229 case $out in
230 0 ) echo ' pass test 2+2=4'
231 echo "Y Y Y Y pass <- $nam" >> ../../$SUMMARY ;;
232 4|5) echo "Y Y Y Y FAIL ($out) - $nam" >> ../../$SUMMARY ;;
233 3 ) echo "Y Y Y N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
234 2 ) echo "Y Y N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
235 1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
236 * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
237 esac
238 if test $out != '0' ; then
239 echo " test 2+2=4 FAIL (exit $out)"
240 echo " "
241 tail -5 $LOGFILE
242 echo " "
243 cp -p $LOGFILE ../../$DRESULTS/$nam.log
244 elif test $SAVELOG = 1 ; then
245 cp -p $LOGFILE ../../$DRESULTS/$nam.log
246 fi
247 cd $here
248 fi
249 done
250 if test "x$mpi" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi
251 done
252 printf "End time: " >> $SUMMARY
253 date >> $SUMMARY
254
255 # If address was supplied and mpack exist, then send email using mpack.
256 if test "x$ADDRESS" != xNONE -a "x$ADDRESS" != x ; then
257 if test -x $MPACK ; then
258 tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
259 && gzip $DRESULTS".tar" \
260 && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESS
261 out=$?
262 if test "x$out" != x0 ; then
263 echo
264 echo "Warning: The tar, gzip, & mpack step failed. Please send email"
265 echo " to <MITgcm-support@mitgcm.org> for help. You may copy the "
266 echo " summary of results from the directory \"$DRESULTS\"."
267 echo
268 else
269 echo
270 echo "An email containing results was sent to the following address:"
271 echo " \"$ADDRESS\""
272 echo
273 fi
274 test -f $DRESULTS".tar" && rm -f $DRESULTS".tar"
275 test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz"
276 else
277 echo "Warning: $MPACK is not executable => no email was sent"
278 echo
279 fi
280 fi
281
282 # save output and remove output Dir (if no address was provided)
283 # note: to keep the output Dir without sending email, use option "-a NONE"
284 if test -f tst_2+2_out.txt ; then mv -f tst_2+2_out.txt tst_2+2_out.old ; fi
285 cp -p $SUMMARY tst_2+2_out.txt
286 if test "x$ADDRESS" = x ; then
287 rm -rf $DRESULTS
288 fi

  ViewVC Help
Powered by ViewVC 1.1.22