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 |
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 |
59 |
-mf ) yy=MPI_MFILE ;; |
-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 |
126 |
else CMDLINE="$CMDLINE '$xx'" ; fi |
else CMDLINE="$CMDLINE '$xx'" ; fi |
127 |
done |
done |
128 |
#for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done |
#for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done |
129 |
DATE=`date +%Y%m%d` |
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" |
173 |
|
|
174 |
for xx in $LIST |
for xx in $LIST |
175 |
do |
do |
176 |
echo ============================================================================== |
echo '------------------------------------------------------------------------------' |
177 |
if [ $mpi -le 0 ] ; then |
if [ $mpi -le 0 ] ; then |
178 |
rCommand=$COMMAND |
rCommand=$COMMAND |
179 |
else |
else |
225 |
else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi |
else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi |
226 |
echo -n "Entering $xx/$yy :" |
echo -n "Entering $xx/$yy :" |
227 |
cd $xx/$yy |
cd $xx/$yy |
228 |
pwd > outp.tst_2+2.log |
pwd > $LOGFILE |
229 |
if test "x$COMMAND" = x ; then |
if test "x$COMMAND" = x ; then |
230 |
echo $SCRIPT $scrArg >> outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log |
echo $SCRIPT $scrArg >> $LOGFILE ; echo ' ' >> $LOGFILE |
231 |
$SCRIPT $scrArg >> outp.tst_2+2.log 2>&1 |
$SCRIPT $scrArg >> $LOGFILE 2>&1 |
232 |
out=$? |
out=$? |
233 |
else |
else |
234 |
echo "$SCRIPT $scrArg -command \"$rCommand\"" >> outp.tst_2+2.log |
echo "$SCRIPT $scrArg -command \"$rCommand\"" >> $LOGFILE |
235 |
echo ' ' >> outp.tst_2+2.log |
echo ' ' >> $LOGFILE |
236 |
$SCRIPT $scrArg -command "$rCommand" >> outp.tst_2+2.log 2>&1 |
$SCRIPT $scrArg -command "$rCommand" >> $LOGFILE 2>&1 |
237 |
out=$? |
out=$? |
238 |
fi |
fi |
239 |
case $out in |
case $out in |
248 |
if test $out != '0' ; then |
if test $out != '0' ; then |
249 |
echo " test 2+2=4 FAIL (exit $out)" |
echo " test 2+2=4 FAIL (exit $out)" |
250 |
echo " " |
echo " " |
251 |
tail -5 outp.tst_2+2.log |
tail -5 $LOGFILE |
252 |
echo " " |
echo " " |
253 |
cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log |
cp -p $LOGFILE ../../$DRESULTS/$nam.log |
254 |
elif test $SAVELOG = 1 ; then |
elif test $SAVELOG = 1 ; then |
255 |
cp -p outp.tst_2+2.log ../../$DRESULTS/$nam.log |
cp -p $LOGFILE ../../$DRESULTS/$nam.log |
256 |
fi |
fi |
257 |
cd $here |
cd $here |
258 |
fi |
fi |
262 |
printf "End time: " >> $SUMMARY |
printf "End time: " >> $SUMMARY |
263 |
date >> $SUMMARY |
date >> $SUMMARY |
264 |
|
|
265 |
# If address was supplied and mpack exist, then send email using mpack. |
# If address was supplied, then send email using Send-Command or mpack. |
266 |
if test "x$ADDRESS" != xNONE -a "x$ADDRESS" != x ; then |
if test "x$ADDRESS" != xNONE -a "x$ADDRESS" != x ; then |
267 |
if test -x $MPACK ; then |
if test "x$SENDCMD" = x ; then |
268 |
tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ |
# if Send-Command is empty and mpack exist, then send email using mpack. |
269 |
&& gzip $DRESULTS".tar" \ |
if test -x $MPACK ; then SENDCMD=$MPACK |
270 |
&& $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESS |
else |
271 |
|
echo "Warning: $MPACK is not executable => no email was sent" |
272 |
|
echo |
273 |
|
fi |
274 |
|
fi |
275 |
|
if test "x$SENDCMD" != x ; then |
276 |
|
#echo " run: $SENDCMD -s MITgcm-test -m 3555000 ${SAVDIR}/${DRESULTS}".tar.gz" $ADDRESS" |
277 |
|
tar -cf ${SAVDIR}/${DRESULTS}".tar" $DRESULTS > /dev/null 2>&1 \ |
278 |
|
&& gzip ${SAVDIR}/${DRESULTS}".tar" \ |
279 |
|
&& $SENDCMD -s MITgcm-test -m 3555000 ${SAVDIR}/${DRESULTS}".tar.gz" $ADDRESS |
280 |
out=$? |
out=$? |
281 |
if test "x$out" != x0 ; then |
if test "x$out" != x0 ; then |
282 |
echo |
echo |
290 |
echo " \"$ADDRESS\"" |
echo " \"$ADDRESS\"" |
291 |
echo |
echo |
292 |
fi |
fi |
293 |
test -f $DRESULTS".tar" && rm -f $DRESULTS".tar" |
test -f ${SAVDIR}/${DRESULTS}".tar" && rm -f ${SAVDIR}/${DRESULTS}".tar" |
294 |
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 |
|
295 |
fi |
fi |
296 |
fi |
fi |
297 |
|
|
302 |
if test "x$ADDRESS" = x ; then |
if test "x$ADDRESS" = x ; then |
303 |
rm -rf $DRESULTS |
rm -rf $DRESULTS |
304 |
fi |
fi |
|
|
|