/[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.6 - (show annotations) (download)
Thu Mar 25 23:09:29 2010 UTC (14 years ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l
Changes since 1.5: +2 -1 lines
add more information to genmake_state

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

  ViewVC Help
Powered by ViewVC 1.1.22