/[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.4 - (hide annotations) (download)
Fri May 1 13:46:51 2009 UTC (14 years, 11 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62, checkpoint61n, checkpoint61o, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y
Changes since 1.3: +3 -2 lines
use short "hostname" for output-dir name

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

  ViewVC Help
Powered by ViewVC 1.1.22