/[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.13 - (show annotations) (download)
Thu May 19 13:18:43 2011 UTC (9 years ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63l, checkpoint63m, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint63, checkpoint62z, checkpoint62y
Changes since 1.12: +2 -2 lines
adjust previous modif (logfile name with same prefix as summary "tst_2+2_out.txt")

1 #! /usr/bin/env bash
2
3 # $Header: /u/gcmpack/MITgcm/tools/do_tst_2+2,v 1.12 2011/05/18 14:23:57 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=`date +%Y%m%d`
120 BASE="rs_"$OUTDIR"_"$DATE"_"
121 xx=0
122 DRESULTS="$BASE$xx"
123 while test -e $DRESULTS ; do
124 xx=$(( $xx + 1 ))
125 DRESULTS="$BASE$xx"
126 done
127 mkdir $DRESULTS
128 out=$?
129 if test "x$out" != x0 ; then
130 echo "ERROR: Can't create results directory \"./$DRESULTS\""
131 exit 1
132 fi
133 SUMMARY="$DRESULTS/summary.txt"
134 OPTFILE=
135
136 printf "Start time: " > $SUMMARY
137 date >> $SUMMARY
138 echo 'run:' $CMDLINE >> $SUMMARY
139 if test -f tr_out.txt ; then
140 echo ' using output from:' >> $SUMMARY
141 sed -n '2,/^ OPTFILE=/ p' tr_out.txt >> $SUMMARY
142 echo >> $SUMMARY
143 fi
144 echo 'test 2+2=4 summary :' >> $SUMMARY
145 echo >> $SUMMARY
146 echo 'P. Run Result experiment' >> $SUMMARY
147 echo ' 1 2 3' >> $SUMMARY
148
149 #-- For MPI test:
150 LOC_MFILE='tr_mpi_mfile'
151 RUNOUTP="output.txt"
152 if [ $mpi -ge 1 ] ; then
153 SCRIPT="$SCRIPT -mpi"
154 RUNOUTP="STDOUT.0000"
155 fi
156
157 for xx in $LIST
158 do
159 echo ==============================================================================
160 if [ $mpi -le 0 ] ; then
161 rCommand=$COMMAND
162 else
163 LOC_NPROC=2
164 mpi_size=$xx/build/SIZE.h.mpi
165 if test -f $mpi_size ; then
166 px=`grep '^ & *nPx *=' $mpi_size | sed 's/^ & *nPx *= *//' | sed 's/, *$//'`
167 py=`grep '^ & *nPy *=' $mpi_size | sed 's/^ & *nPy *= *//' | sed 's/, *$//'`
168 pp=`expr $px \* $py` > /dev/null 2>&1 ; out=$?
169 if test "x$out" = x0 ; then LOC_NPROC=$pp ; fi
170 fi
171 rCommand=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"`
172 if test "x$MPI_MFILE" != x ; then
173 #- create new MPI machine-file with the right number of Procs
174 rm -f $LOC_MFILE
175 cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE
176 nl=`wc -l $LOC_MFILE | awk '{print $1}'`
177 if [ $nl -lt $LOC_NPROC ] ; then
178 rm -f $LOC_MFILE
179 cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE
180 fi
181 rCommand=`echo $rCommand | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"`
182 fi
183 fi
184
185 listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )`
186 for yy in $listD
187 do
188 if test -f $xx/$yy/$RUNOUTP ; then
189 if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then
190 comm=`grep '^# OPTFILE=' $xx/build/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
191 echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state
192 sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state
193 echo " $comm" >> $DRESULTS/genmake_state
194 eval $comm
195 gmkLog=$xx/build/genmake.log
196 grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
197 out=$?
198 if test "x$out" = x0 ; then
199 echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
200 sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \
201 | grep -v '^... compiler version ' > tr_vers.tmp_log
202 sed -n '1,/^$/p' tr_vers.tmp_log | sed '/^$/d' | sed 's/^./ &/' \
203 >> $DRESULTS/genmake_state
204 rm -f tr_vers.tmp_log
205 fi
206 fi
207 if test $yy = 'run' ; then nam=$xx
208 else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi
209 echo -n "Entering $xx/$yy :"
210 cd $xx/$yy
211 pwd > $LOGFILE
212 if test "x$COMMAND" = x ; then
213 echo $SCRIPT $scrArg >> $LOGFILE ; echo ' ' >> $LOGFILE
214 $SCRIPT $scrArg >> $LOGFILE 2>&1
215 out=$?
216 else
217 echo "$SCRIPT $scrArg -command \"$rCommand\"" >> $LOGFILE
218 echo ' ' >> $LOGFILE
219 $SCRIPT $scrArg -command "$rCommand" >> $LOGFILE 2>&1
220 out=$?
221 fi
222 case $out in
223 0 ) echo ' pass test 2+2=4'
224 echo "Y Y Y Y pass <- $nam" >> ../../$SUMMARY ;;
225 4|5) echo "Y Y Y Y FAIL ($out) - $nam" >> ../../$SUMMARY ;;
226 3 ) echo "Y Y Y N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
227 2 ) echo "Y Y N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
228 1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
229 * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
230 esac
231 if test $out != '0' ; then
232 echo " test 2+2=4 FAIL (exit $out)"
233 echo " "
234 tail -5 $LOGFILE
235 echo " "
236 cp -p $LOGFILE ../../$DRESULTS/$nam.log
237 elif test $SAVELOG = 1 ; then
238 cp -p $LOGFILE ../../$DRESULTS/$nam.log
239 fi
240 cd $here
241 fi
242 done
243 if test "x$mpi" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi
244 done
245 printf "End time: " >> $SUMMARY
246 date >> $SUMMARY
247
248 # If address was supplied and mpack exist, then send email using mpack.
249 if test "x$ADDRESS" != xNONE -a "x$ADDRESS" != x ; then
250 if test -x $MPACK ; then
251 tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
252 && gzip $DRESULTS".tar" \
253 && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESS
254 out=$?
255 if test "x$out" != x0 ; then
256 echo
257 echo "Warning: The tar, gzip, & mpack step failed. Please send email"
258 echo " to <MITgcm-support@mitgcm.org> for help. You may copy the "
259 echo " summary of results from the directory \"$DRESULTS\"."
260 echo
261 else
262 echo
263 echo "An email containing results was sent to the following address:"
264 echo " \"$ADDRESS\""
265 echo
266 fi
267 test -f $DRESULTS".tar" && rm -f $DRESULTS".tar"
268 test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz"
269 else
270 echo "Warning: $MPACK is not executable => no email was sent"
271 echo
272 fi
273 fi
274
275 # save output and remove output Dir (if no address was provided)
276 # note: to keep the output Dir without sending email, use option "-a NONE"
277 if test -f tst_2+2_out.txt ; then mv -f tst_2+2_out.txt tst_2+2_out.old ; fi
278 cp -p $SUMMARY tst_2+2_out.txt
279 if test "x$ADDRESS" = x ; then
280 rm -rf $DRESULTS
281 fi

  ViewVC Help
Powered by ViewVC 1.1.22