/[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.9 - (show annotations) (download)
Wed Jan 19 23:43:13 2011 UTC (13 years, 2 months ago) by jmc
Branch: MAIN
Changes since 1.8: +2 -2 lines
updated after changing testreport (replace TR_NPROC instead of XX in MPI command)

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

  ViewVC Help
Powered by ViewVC 1.1.22