/[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.7 - (show annotations) (download)
Thu Dec 16 20:15:21 2010 UTC (9 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62q, checkpoint62p
Changes since 1.6: +13 -2 lines
incorporate the part of testreport that deals with compiler version

1 #! /usr/bin/env bash
2
3 # $Header: /u/gcmpack/MITgcm/tools/do_tst_2+2,v 1.6 2010/03/25 23:09:29 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 listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )`
149 for yy in $listD
150 do
151 if test -f $xx/$yy/$RUNOUTP ; then
152 if test "x$OPTFILE" = x -a -f $xx/build/Makefile ; then
153 comm=`grep '^# OPTFILE=' $xx/build/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
154 echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state
155 sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state
156 echo " $comm" >> $DRESULTS/genmake_state
157 eval $comm
158 gmkLog=$xx/build/genmake.log
159 grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
160 out=$?
161 if test "x$out" = x0 ; then
162 echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
163 sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \
164 | grep -v '^... compiler version ' > tr_vers.tmp_log
165 sed -n '1,/^$/p' tr_vers.tmp_log | sed '/^$/d' | sed 's/^./ &/' \
166 >> $DRESULTS/genmake_state
167 rm -f tr_vers.tmp_log
168 fi
169 fi
170 if test $yy = 'run' ; then nam=$xx
171 else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi
172 echo -n "Entering $xx/$yy :"
173 cd $xx/$yy
174 pwd > outp.tst_2+2.log
175 if test "x$COMMAND" = x ; then
176 echo $SCRIPT $scrArg >> outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log
177 $SCRIPT $scrArg >> outp.tst_2+2.log 2>&1
178 out=$?
179 else
180 echo "$SCRIPT $scrArg -command \"$COMMAND\"" >> outp.tst_2+2.log
181 echo ' ' >> outp.tst_2+2.log
182 $SCRIPT $scrArg -command "$COMMAND" >> outp.tst_2+2.log 2>&1
183 out=$?
184 fi
185 case $out in
186 0 ) echo ' pass test 2+2=4'
187 echo "Y Y Y Y pass <- $nam" >> ../../$SUMMARY ;;
188 4|5) echo "Y Y Y Y FAIL ($out) - $nam" >> ../../$SUMMARY ;;
189 3 ) echo "Y Y Y N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
190 2 ) echo "Y Y N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
191 1 ) echo "Y N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
192 * ) echo "N N N N FAIL ($out) - $nam" >> ../../$SUMMARY ;;
193 esac
194 if test $out != '0' ; then
195 echo " test 2+2=4 FAIL (exit $out)"
196 echo " "
197 tail -5 outp.tst_2+2.log
198 echo " "
199 cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log
200 elif test $SAVELOG = 1 ; then
201 cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log
202 fi
203 cd $here
204 fi
205 done
206 done
207 printf "End time: " >> $SUMMARY
208 date >> $SUMMARY
209
210 # If address was supplied and mpack exist, then send email using mpack.
211 if test "x$ADDRESS" != xNONE -a "x$ADDRESS" != x ; then
212 if test -x $MPACK ; then
213 tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
214 && gzip $DRESULTS".tar" \
215 && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESS
216 out=$?
217 if test "x$out" != x0 ; then
218 echo
219 echo "Warning: The tar, gzip, & mpack step failed. Please send email"
220 echo " to <MITgcm-support@mitgcm.org> for help. You may copy the "
221 echo " summary of results from the directory \"$DRESULTS\"."
222 echo
223 else
224 echo
225 echo "An email containing results was sent to the following address:"
226 echo " \"$ADDRESS\""
227 echo
228 fi
229 test -f $DRESULTS".tar" && rm -f $DRESULTS".tar"
230 test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz"
231 else
232 echo "Warning: $MPACK is not executable => no email was sent"
233 echo
234 fi
235 fi
236
237 # save output and remove output Dir (if no address was provided)
238 # note: to keep the output Dir without sending email, use option "-a NONE"
239 if test -f tst_2+2_out.txt ; then mv -f tst_2+2_out.txt tst_2+2_out.old ; fi
240 cp -p $SUMMARY tst_2+2_out.txt
241 if test "x$ADDRESS" = x ; then
242 rm -rf $DRESULTS
243 fi

  ViewVC Help
Powered by ViewVC 1.1.22