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

Annotation of /MITgcm/tools/do_tst_2+2

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


Revision 1.9 - (hide annotations) (download)
Wed Jan 19 23:43:13 2011 UTC (10 years, 3 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 jmc 1.2 #! /usr/bin/env bash
2 jmc 1.1
3 jmc 1.9 # $Header: /u/gcmpack/MITgcm/tools/do_tst_2+2,v 1.8 2011/01/15 19:16:32 jmc Exp $
4 jmc 1.1 # $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 jmc 1.3 echo " -exe COMMAND : use COMMAND to run the tests"
16     echo " -mpi : run the tests using MPI"
17 jmc 1.2 echo " -o STRING : used to build output directory name"
18 jmc 1.1 echo " (DEF=\"hostname\")"
19 jmc 1.2 echo " -a,-A STRING : email address to send output to"
20 jmc 1.1 echo " (DEF=\"\" no email is sent)"
21 jmc 1.2 echo " (-A: + save each log file)"
22 jmc 1.1 echo " -clean : clean output & reset"
23     exit
24     }
25    
26     CLEAN=0
27     TESTDIRS=
28     SKIPDIRS=
29 jmc 1.3 SCRIPT='../tools/tst_2+2'
30 jmc 1.5 scrArg='All'
31 jmc 1.3 COMMAND=
32     mpi=0
33 jmc 1.4 OUTDIR=`hostname | sed 's/\..*$//'`
34 jmc 1.2 SAVELOG=0
35 jmc 1.1 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 jmc 1.3 -exe ) yy=COMMAND ;;
51     -mpi ) mpi=1 ;;
52 jmc 1.1 -a ) yy=ADDRESS ;;
53 jmc 1.2 -A ) yy=ADDRESS ; SAVELOG=1 ;;
54 jmc 1.1 -o ) yy=OUTDIR ;;
55     *) echo "Error: unrecognized option: "$xx ; usage ; exit ;;
56     esac
57     fi
58     done
59     #------------------------
60    
61 jmc 1.2 if test "x$TESTDIRS" = x ; then TESTDIRS=`ls ` ; fi
62 jmc 1.1 LIST=""
63     for xx in $TESTDIRS
64     do
65     yy=`echo $SKIPDIRS | grep -c $xx`
66     if test $yy = 0 ; then
67 jmc 1.2 if test -f $xx/results/output.txt ; then
68 jmc 1.1 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 jmc 1.2 yy=`echo $SCRIPT | grep -c '^\/'`
81 jmc 1.1 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 jmc 1.2 if test -r $xx/$yy/data.tst ; then
96 jmc 1.1 echo "clean dir:" $xx/$yy
97 jmc 1.2 cd $xx/$yy
98 jmc 1.1 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 jmc 1.3 #-- 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 jmc 1.1 for xx in $LIST
146     do
147     echo ==============================================================================
148 jmc 1.8 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 jmc 1.9 rCommand=`echo $COMMAND | sed "s/ TR_NPROC / $NP_MPI /"`
158 jmc 1.8 else
159     rCommand=$COMMAND
160     fi
161 jmc 1.1 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 jmc 1.3 if test -f $xx/$yy/$RUNOUTP ; then
165 jmc 1.1 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 jmc 1.6 sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state
169 jmc 1.7 echo " $comm" >> $DRESULTS/genmake_state
170 jmc 1.1 eval $comm
171 jmc 1.7 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 jmc 1.1 fi
183 jmc 1.2 if test $yy = 'run' ; then nam=$xx
184 jmc 1.1 else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi
185     echo -n "Entering $xx/$yy :"
186     cd $xx/$yy
187 jmc 1.2 pwd > outp.tst_2+2.log
188 jmc 1.3 if test "x$COMMAND" = x ; then
189 jmc 1.5 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 jmc 1.3 out=$?
192     else
193 jmc 1.8 echo "$SCRIPT $scrArg -command \"$rCommand\"" >> outp.tst_2+2.log
194 jmc 1.3 echo ' ' >> outp.tst_2+2.log
195 jmc 1.8 $SCRIPT $scrArg -command "$rCommand" >> outp.tst_2+2.log 2>&1
196 jmc 1.3 out=$?
197     fi
198 jmc 1.1 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 jmc 1.2 if test $out != '0' ; then
208 jmc 1.1 echo " test 2+2=4 FAIL (exit $out)"
209     echo " "
210     tail -5 outp.tst_2+2.log
211     echo " "
212 jmc 1.2 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 jmc 1.1 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
257    

  ViewVC Help
Powered by ViewVC 1.1.22