/[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.1 - (show annotations) (download)
Tue Dec 25 22:10:51 2007 UTC (12 years, 6 months ago) by jmc
Branch: MAIN
moved from Contrib/jmc_script.
- change output format (compatible with testing web-page make_summary)
- add option to sent output with mpack

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

  ViewVC Help
Powered by ViewVC 1.1.22