14 |
echo " -skd LIST_EXP : skip experiments in LIST_EXP" |
echo " -skd LIST_EXP : skip experiments in LIST_EXP" |
15 |
echo " -exe COMMAND : use COMMAND to run the tests" |
echo " -exe COMMAND : use COMMAND to run the tests" |
16 |
echo " -mpi : run the tests using MPI" |
echo " -mpi : run the tests using MPI" |
17 |
|
echo " -mf STRING :(MPI) file with list of possible machines to run on" |
18 |
echo " -o STRING : used to build output directory name" |
echo " -o STRING : used to build output directory name" |
19 |
echo " (DEF=\"hostname\")" |
echo " (DEF=\"hostname\")" |
20 |
echo " -a,-A STRING : email address to send output to" |
echo " -a,-A STRING : email address to send output to" |
21 |
echo " (DEF=\"\" no email is sent)" |
echo " (DEF=\"\" no email is sent)" |
22 |
echo " (-A: + save each log file)" |
echo " (-A: + save each log file)" |
23 |
|
echo " -send STRING : sending command (instead of using mpack)" |
24 |
|
echo " -sd STRING : location to save output tar file to send (DEF='$SAVDIR')" |
25 |
echo " -clean : clean output & reset" |
echo " -clean : clean output & reset" |
26 |
exit |
exit |
27 |
} |
} |
30 |
TESTDIRS= |
TESTDIRS= |
31 |
SKIPDIRS= |
SKIPDIRS= |
32 |
SCRIPT='../tools/tst_2+2' |
SCRIPT='../tools/tst_2+2' |
33 |
|
LOGFILE='tst_2+2_out.log' |
34 |
scrArg='All' |
scrArg='All' |
35 |
COMMAND= |
COMMAND= |
36 |
mpi=0 |
mpi=0 |
37 |
|
MPI_MFILE= |
38 |
OUTDIR=`hostname | sed 's/\..*$//'` |
OUTDIR=`hostname | sed 's/\..*$//'` |
39 |
SAVELOG=0 |
SAVELOG=0 |
40 |
ADDRESS= |
ADDRESS= |
41 |
MPACK="../tools/mpack-1.6/mpack" |
MPACK="../tools/mpack-1.6/mpack" |
42 |
|
SENDCMD= |
43 |
|
SAVDIR='.' |
44 |
here=`pwd` |
here=`pwd` |
45 |
yy= |
yy= |
46 |
for xx |
for xx |
56 |
-skd ) yy=SKIPDIRS ;; |
-skd ) yy=SKIPDIRS ;; |
57 |
-exe ) yy=COMMAND ;; |
-exe ) yy=COMMAND ;; |
58 |
-mpi ) mpi=1 ;; |
-mpi ) mpi=1 ;; |
59 |
|
-mf ) yy=MPI_MFILE ;; |
60 |
-a ) yy=ADDRESS ;; |
-a ) yy=ADDRESS ;; |
61 |
-A ) yy=ADDRESS ; SAVELOG=1 ;; |
-A ) yy=ADDRESS ; SAVELOG=1 ;; |
62 |
|
-send ) yy=SENDCMD ;; |
63 |
|
-sd ) yy=SAVDIR ;; |
64 |
-o ) yy=OUTDIR ;; |
-o ) yy=OUTDIR ;; |
65 |
*) echo "Error: unrecognized option: "$xx ; usage ; exit ;; |
*) echo "Error: unrecognized option: "$xx ; usage ; exit ;; |
66 |
esac |
esac |
85 |
done |
done |
86 |
|
|
87 |
if test -x $SCRIPT ; then |
if test -x $SCRIPT ; then |
88 |
echo "run script '$SCRIPT' for experiment in:" |
if test $CLEAN = 1 ; then |
89 |
|
echo "clean output from script '$SCRIPT' for experiment in:" |
90 |
|
else |
91 |
|
echo "run script '$SCRIPT' for experiment in:" |
92 |
|
fi |
93 |
echo " $LIST" |
echo " $LIST" |
94 |
|
echo "" |
95 |
yy=`echo $SCRIPT | grep -c '^\/'` |
yy=`echo $SCRIPT | grep -c '^\/'` |
96 |
if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi |
if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi |
97 |
else |
else |
98 |
echo "ERROR: script '$SCRIPT' not found or not executable" |
echo "ERROR: script '$SCRIPT' not found or not executable" |
99 |
exit |
exit |
100 |
fi |
fi |
|
echo "" |
|
101 |
#------------------------ |
#------------------------ |
102 |
|
|
103 |
if test $CLEAN = 1 ; then |
if test $CLEAN = 1 ; then |
109 |
if test -r $xx/$yy/data.tst ; then |
if test -r $xx/$yy/data.tst ; then |
110 |
echo "clean dir:" $xx/$yy |
echo "clean dir:" $xx/$yy |
111 |
cd $xx/$yy |
cd $xx/$yy |
112 |
echo ' ' >> outp.tst_2+2.log |
echo ' ' >> $LOGFILE |
113 |
echo $SCRIPT 4 >> outp.tst_2+2.log |
echo $SCRIPT 4 >> $LOGFILE |
114 |
$SCRIPT 4 >> outp.tst_2+2.log 2>&1 |
$SCRIPT 4 >> $LOGFILE 2>&1 |
115 |
cd $here |
cd $here |
116 |
fi |
fi |
117 |
done |
done |
120 |
fi |
fi |
121 |
#------------------------ |
#------------------------ |
122 |
# Create a uniquely named directory to store results |
# Create a uniquely named directory to store results |
123 |
DATE=`date +%Y%m%d` |
CMDLINE=$0 |
124 |
|
for xx in "$@" ; do nw=`echo $xx | wc -w` |
125 |
|
if test $nw = '1' ; then CMDLINE="$CMDLINE $xx" |
126 |
|
else CMDLINE="$CMDLINE '$xx'" ; fi |
127 |
|
done |
128 |
|
#for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done |
129 |
|
DATE='' |
130 |
|
if test -f tr_out.txt ; then |
131 |
|
# try to use the date corresponding to 'Start time:' in file "tr_out.txt" : |
132 |
|
sTime=`grep '^Start time: ' tr_out.txt 2>/dev/null | sed 's/Start time: //'` |
133 |
|
if test "x$sTime" != x ; then DATE=`date -d "$sTime" "+%Y%m%d" 2>/dev/null` ; fi |
134 |
|
fi |
135 |
|
# otherwise, use current date: |
136 |
|
if test "x$DATE" = x ; then DATE=`date +%Y%m%d`; fi |
137 |
BASE="rs_"$OUTDIR"_"$DATE"_" |
BASE="rs_"$OUTDIR"_"$DATE"_" |
138 |
xx=0 |
xx=0 |
139 |
DRESULTS="$BASE$xx" |
DRESULTS="$BASE$xx" |
152 |
|
|
153 |
printf "Start time: " > $SUMMARY |
printf "Start time: " > $SUMMARY |
154 |
date >> $SUMMARY |
date >> $SUMMARY |
155 |
|
echo 'run:' $CMDLINE >> $SUMMARY |
156 |
if test -f tr_out.txt ; then |
if test -f tr_out.txt ; then |
157 |
echo ' using output from:' >> $SUMMARY |
echo ' using output from:' >> $SUMMARY |
158 |
sed -n '2,/OPTFILE/ p' tr_out.txt >> $SUMMARY |
sed -n '2,/^ OPTFILE=/ p' tr_out.txt >> $SUMMARY |
159 |
echo >> $SUMMARY |
echo >> $SUMMARY |
160 |
fi |
fi |
161 |
echo 'test 2+2=4 summary :' >> $SUMMARY |
echo 'test 2+2=4 summary :' >> $SUMMARY |
164 |
echo ' 1 2 3' >> $SUMMARY |
echo ' 1 2 3' >> $SUMMARY |
165 |
|
|
166 |
#-- For MPI test: |
#-- For MPI test: |
167 |
|
LOC_MFILE='tr_mpi_mfile' |
168 |
RUNOUTP="output.txt" |
RUNOUTP="output.txt" |
169 |
if [ $mpi -ge 1 ] ; then |
if [ $mpi -ge 1 ] ; then |
170 |
SCRIPT="$SCRIPT -mpi" |
SCRIPT="$SCRIPT -mpi" |
171 |
RUNOUTP="STDOUT.0000" |
RUNOUTP="STDOUT.0000" |
172 |
|
if test "x$COMMAND" = x ; then COMMAND="mpirun -v -np TR_NPROC ./mitgcmuv" ; fi |
173 |
fi |
fi |
174 |
|
|
175 |
for xx in $LIST |
for xx in $LIST |
176 |
do |
do |
177 |
echo ============================================================================== |
echo '------------------------------------------------------------------------------' |
178 |
|
if [ $mpi -le 0 ] ; then |
179 |
|
rCommand=$COMMAND |
180 |
|
else |
181 |
|
LOC_NPROC=2 |
182 |
|
mpi_size=$xx/build/SIZE.h.mpi |
183 |
|
if test -f $mpi_size ; then |
184 |
|
px=`grep '^ & *nPx *=' $mpi_size | sed 's/^ & *nPx *= *//' | sed 's/, *$//'` |
185 |
|
py=`grep '^ & *nPy *=' $mpi_size | sed 's/^ & *nPy *= *//' | sed 's/, *$//'` |
186 |
|
pp=`expr $px \* $py` > /dev/null 2>&1 ; out=$? |
187 |
|
if test "x$out" = x0 ; then LOC_NPROC=$pp ; fi |
188 |
|
fi |
189 |
|
rCommand=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"` |
190 |
|
if test "x$MPI_MFILE" != x ; then |
191 |
|
#- create new MPI machine-file with the right number of Procs |
192 |
|
rm -f $LOC_MFILE |
193 |
|
cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE |
194 |
|
nl=`wc -l $LOC_MFILE | awk '{print $1}'` |
195 |
|
if [ $nl -lt $LOC_NPROC ] ; then |
196 |
|
rm -f $LOC_MFILE |
197 |
|
cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE |
198 |
|
fi |
199 |
|
rCommand=`echo $rCommand | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"` |
200 |
|
fi |
201 |
|
fi |
202 |
|
|
203 |
listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )` |
listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )` |
204 |
for yy in $listD |
for yy in $listD |
205 |
do |
do |
208 |
comm=`grep '^# OPTFILE=' $xx/build/Makefile 2>/dev/null | head -1 | sed 's/^# //'` |
comm=`grep '^# OPTFILE=' $xx/build/Makefile 2>/dev/null | head -1 | sed 's/^# //'` |
209 |
echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state |
echo "from '$xx/build/Makefile', extract:" > $DRESULTS/genmake_state |
210 |
sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state |
sed -n '/^# executed by:/,+1 p' $xx/build/Makefile >> $DRESULTS/genmake_state |
211 |
echo $comm >> $DRESULTS/genmake_state |
echo " $comm" >> $DRESULTS/genmake_state |
212 |
eval $comm |
eval $comm |
213 |
|
gmkLog=$xx/build/genmake.log |
214 |
|
grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1 |
215 |
|
out=$? |
216 |
|
if test "x$out" = x0 ; then |
217 |
|
echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state |
218 |
|
sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \ |
219 |
|
| grep -v '^... compiler version ' > tr_vers.tmp_log |
220 |
|
sed -n '1,/^$/p' tr_vers.tmp_log | sed '/^$/d' | sed 's/^./ &/' \ |
221 |
|
>> $DRESULTS/genmake_state |
222 |
|
rm -f tr_vers.tmp_log |
223 |
|
fi |
224 |
fi |
fi |
225 |
if test $yy = 'run' ; then nam=$xx |
if test $yy = 'run' ; then nam=$xx |
226 |
else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi |
else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi |
227 |
echo -n "Entering $xx/$yy :" |
echo -n "Entering $xx/$yy :" |
228 |
cd $xx/$yy |
cd $xx/$yy |
229 |
pwd > outp.tst_2+2.log |
pwd > $LOGFILE |
230 |
if test "x$COMMAND" = x ; then |
if test "x$COMMAND" = x ; then |
231 |
echo $SCRIPT $scrArg >> outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log |
echo $SCRIPT $scrArg >> $LOGFILE ; echo ' ' >> $LOGFILE |
232 |
$SCRIPT $scrArg >> outp.tst_2+2.log 2>&1 |
$SCRIPT $scrArg >> $LOGFILE 2>&1 |
233 |
out=$? |
out=$? |
234 |
else |
else |
235 |
echo "$SCRIPT $scrArg -command \"$COMMAND\"" >> outp.tst_2+2.log |
echo "$SCRIPT $scrArg -command \"$rCommand\"" >> $LOGFILE |
236 |
echo ' ' >> outp.tst_2+2.log |
echo ' ' >> $LOGFILE |
237 |
$SCRIPT $scrArg -command "$COMMAND" >> outp.tst_2+2.log 2>&1 |
$SCRIPT $scrArg -command "$rCommand" >> $LOGFILE 2>&1 |
238 |
out=$? |
out=$? |
239 |
fi |
fi |
240 |
case $out in |
case $out in |
249 |
if test $out != '0' ; then |
if test $out != '0' ; then |
250 |
echo " test 2+2=4 FAIL (exit $out)" |
echo " test 2+2=4 FAIL (exit $out)" |
251 |
echo " " |
echo " " |
252 |
tail -5 outp.tst_2+2.log |
tail -5 $LOGFILE |
253 |
echo " " |
echo " " |
254 |
cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log |
cp -p $LOGFILE ../../$DRESULTS/$nam.log |
255 |
elif test $SAVELOG = 1 ; then |
elif test $SAVELOG = 1 ; then |
256 |
cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log |
cp -p $LOGFILE ../../$DRESULTS/$nam.log |
257 |
fi |
fi |
258 |
cd $here |
cd $here |
259 |
fi |
fi |
260 |
done |
done |
261 |
|
if test "x$mpi" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi |
262 |
done |
done |
263 |
printf "End time: " >> $SUMMARY |
printf "End time: " >> $SUMMARY |
264 |
date >> $SUMMARY |
date >> $SUMMARY |
265 |
|
|
266 |
# If address was supplied and mpack exist, then send email using mpack. |
# If address was supplied, then send email using Send-Command or mpack. |
267 |
if test "x$ADDRESS" != xNONE -a "x$ADDRESS" != x ; then |
if test "x$ADDRESS" != xNONE -a "x$ADDRESS" != x ; then |
268 |
if test -x $MPACK ; then |
if test "x$SENDCMD" = x ; then |
269 |
tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ |
# if Send-Command is empty and mpack exist, then send email using mpack. |
270 |
&& gzip $DRESULTS".tar" \ |
if test -x $MPACK ; then SENDCMD=$MPACK |
271 |
&& $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESS |
else |
272 |
|
echo "Warning: $MPACK is not executable => no email was sent" |
273 |
|
echo |
274 |
|
fi |
275 |
|
fi |
276 |
|
if test "x$SENDCMD" != x ; then |
277 |
|
#echo " run: $SENDCMD -s MITgcm-test -m 3555000 ${SAVDIR}/${DRESULTS}".tar.gz" $ADDRESS" |
278 |
|
tar -cf ${SAVDIR}/${DRESULTS}".tar" $DRESULTS > /dev/null 2>&1 \ |
279 |
|
&& gzip ${SAVDIR}/${DRESULTS}".tar" \ |
280 |
|
&& $SENDCMD -s MITgcm-test -m 3555000 ${SAVDIR}/${DRESULTS}".tar.gz" $ADDRESS |
281 |
out=$? |
out=$? |
282 |
if test "x$out" != x0 ; then |
if test "x$out" != x0 ; then |
283 |
echo |
echo |
291 |
echo " \"$ADDRESS\"" |
echo " \"$ADDRESS\"" |
292 |
echo |
echo |
293 |
fi |
fi |
294 |
test -f $DRESULTS".tar" && rm -f $DRESULTS".tar" |
test -f ${SAVDIR}/${DRESULTS}".tar" && rm -f ${SAVDIR}/${DRESULTS}".tar" |
295 |
test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz" |
test -f ${SAVDIR}/${DRESULTS}".tar.gz" && rm -f ${SAVDIR}/${DRESULTS}".tar.gz" |
|
else |
|
|
echo "Warning: $MPACK is not executable => no email was sent" |
|
|
echo |
|
296 |
fi |
fi |
297 |
fi |
fi |
298 |
|
|
303 |
if test "x$ADDRESS" = x ; then |
if test "x$ADDRESS" = x ; then |
304 |
rm -rf $DRESULTS |
rm -rf $DRESULTS |
305 |
fi |
fi |
|
|
|