/[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.3 - (hide annotations) (download)
Fri Feb 27 22:58:57 2009 UTC (15 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k
Changes since 1.2: +26 -6 lines
modified for MPI test

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

  ViewVC Help
Powered by ViewVC 1.1.22