11 |
echo "where possible OPTIONS are:" |
echo "where possible OPTIONS are:" |
12 |
echo " (-help|-h) print usage" |
echo " (-help|-h) print usage" |
13 |
echo " (-mpi) use MPI input files" |
echo " (-mpi) use MPI input files" |
14 |
|
echo " (-ieee|-noieee) if possible, use IEEE compiler flags" |
15 |
echo " (-optfile=|-of=)STRING list of optfiles to use" |
echo " (-optfile=|-of=)STRING list of optfiles to use" |
16 |
echo " (-a|-addr)STRING list of email recipients" |
echo " (-a|-addr)STRING list of email recipients" |
17 |
echo " (DEF=\"edhill@mitgcm.org\")" |
echo " (DEF=\"edhill@mitgcm.org\")" |
19 |
echo " (DEF=\"\" which builds all)" |
echo " (DEF=\"\" which builds all)" |
20 |
echo " (-b|-bash)STRING location of \"bash\" executable" |
echo " (-b|-bash)STRING location of \"bash\" executable" |
21 |
echo " (DEF=\"\" for \"/bin/bash\")" |
echo " (DEF=\"\" for \"/bin/bash\")" |
22 |
echo " (-c|-command)STRING command to run" |
echo " (-command)STRING command to run" |
23 |
echo " (DEF=\"make output.txt\")" |
echo " (DEF=\"make output.txt\")" |
24 |
echo " (-m|-make)STRING command to use for \"make\"" |
echo " (-m|-make)STRING command to use for \"make\"" |
25 |
echo " (DEF=\"make\")" |
echo " (DEF=\"make\")" |
26 |
|
echo " (-clean) *ONLY* run \"make CLEAN\"" |
27 |
|
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
28 |
|
echo " (-nogenmake|-ng) skip the genmake stage" |
29 |
|
echo " (-noclean|-nc) skip the \"make clean\" stage" |
30 |
|
echo " (-nodepend|-nd) skip the \"make depend\" stage" |
31 |
echo |
echo |
32 |
echo "and where STRING follows a whitespace-delimited format" |
echo "and where STRING follows a whitespace-delimited format" |
33 |
echo "such as:" |
echo "such as:" |
180 |
genmakemodel() |
genmakemodel() |
181 |
{ |
{ |
182 |
# genmakemodel directory |
# genmakemodel directory |
183 |
GENMAKE2="$BASH ../../../tools/genmake2" |
if test "x$NOGENMAKE" = xt ; then |
184 |
( |
echo "genmake skipped!" |
185 |
cd $1; |
else |
186 |
printf 'genmake ... ' 1>&2 |
GENMAKE2="$BASH ../../../tools/genmake2" |
187 |
# ../../../tools/genmake -ieee -mods=../code > make.log 2>&1 |
( |
188 |
$GENMAKE2 -ds -m $MAKE --mods=../code "--optfile="$OPTFILE > make.log 2>&1 |
cd $1; |
189 |
RETVAL=$? |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
190 |
for i in gm_state gm_optfile gm_local Makefile ; do |
if test "x$OPTFILE" != xNONE ; then |
191 |
if test -r $i ; then |
command="$command --optfile=$OPTFILE" |
192 |
cp $i $CDIR |
# echo " command=\"$command\"" |
193 |
fi |
fi |
194 |
done |
if test "x$IEEE" != x ; then |
195 |
if test "x$RETVAL" != x0 ; then |
command="$command -ieee" |
196 |
tail make.log |
fi |
197 |
echo "genmakemodel: genmake failed" 1>&2 |
# echo "command: \"$command\"" |
198 |
cp make.log $CDIR |
printf 'genmake ... ' 1>&2 |
199 |
return 1 |
$command > make.log 2>&1 |
200 |
else |
RETVAL=$? |
201 |
echo "succesful" 1>&2 |
for i in genmake_state genmake_optfile genmake_local Makefile ; do |
202 |
fi |
if test -r $i ; then |
203 |
) |
cp $i $CDIR |
204 |
|
fi |
205 |
|
done |
206 |
|
if test "x$RETVAL" != x0 ; then |
207 |
|
tail make.log |
208 |
|
echo "genmakemodel: genmake failed" 1>&2 |
209 |
|
cp make.log $CDIR |
210 |
|
return 1 |
211 |
|
else |
212 |
|
echo "succesful" 1>&2 |
213 |
|
fi |
214 |
|
) |
215 |
|
fi |
216 |
} |
} |
217 |
|
|
218 |
makeclean() |
makeclean() |
219 |
{ |
{ |
220 |
# makeclean directory |
# makeclean directory |
221 |
( |
if test "x$NOCLEAN" = xt ; then |
222 |
cd $1; |
echo "make CLEAN skipped!" |
223 |
if test -e output.txt ; then |
else |
224 |
rm -f output.txt |
( |
225 |
fi |
cd $1; |
226 |
printf 'make CLEAN ... ' 2>&1 |
if test -e output.txt ; then |
227 |
if test -r Makefile ; then |
rm -f output.txt |
|
$MAKE CLEAN >> make.log 2>&1 |
|
|
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
tail make.log |
|
|
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
|
|
cp make.log $CDIR"/make.log" |
|
|
return 1 |
|
228 |
fi |
fi |
229 |
fi |
printf 'make CLEAN ... ' 2>&1 |
230 |
echo succesful 1>&2 |
if test -r Makefile ; then |
231 |
exit 0 |
$MAKE CLEAN >> make.log 2>&1 |
232 |
) |
RETVAL=$? |
233 |
|
if test "x$RETVAL" != x0 ; then |
234 |
|
tail make.log |
235 |
|
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
236 |
|
cp make.log $CDIR"/make.log" |
237 |
|
return 1 |
238 |
|
fi |
239 |
|
fi |
240 |
|
echo succesful 1>&2 |
241 |
|
exit 0 |
242 |
|
) |
243 |
|
fi |
244 |
} |
} |
245 |
|
|
246 |
makedependmodel() |
makedependmodel() |
247 |
{ |
{ |
248 |
# makedependmodel directory |
# makedependmodel directory |
249 |
( |
if test "x$NODEPEND" = xt ; then |
250 |
cd $1; |
echo "make depend skipped!" |
251 |
printf 'make depend ... ' 1>&2 |
else |
252 |
$MAKE depend >> make.log 2>&1 |
( |
253 |
RETVAL=$? |
cd $1; |
254 |
if test "x$RETVAL" != x0 ; then |
printf 'make depend ... ' 1>&2 |
255 |
tail make.log |
$MAKE depend >> make.log 2>&1 |
256 |
echo "makedependmodel: make depend failed" 1>&2 |
RETVAL=$? |
257 |
cp make.log $CDIR"/make.log" |
if test "x$RETVAL" != x0 ; then |
258 |
return 1 |
tail make.log |
259 |
else |
echo "makedependmodel: make depend failed" 1>&2 |
260 |
echo succesful 1>&2 |
cp make.log $CDIR"/make.log" |
261 |
fi |
return 1 |
262 |
) |
else |
263 |
|
echo succesful 1>&2 |
264 |
|
fi |
265 |
|
) |
266 |
|
fi |
267 |
} |
} |
268 |
|
|
269 |
makemodel() |
makemodel() |
386 |
{ |
{ |
387 |
cat - << EOF |
cat - << EOF |
388 |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
389 |
-help Show this help message |
|
390 |
-quick Skip "genmake" and "make depend" if the Makefile exists |
-help|-h Show this help message |
391 |
-quiet Reduce the amount of output |
-quiet Reduce the amount of output |
392 |
-verbose Produce copious amounts of output |
-verbose Produce copious amounts of output |
393 |
-debug Produce even more output which will mean nothing to most |
-debug Produce even more output which will mean nothing to most |
394 |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
395 |
-clean Do "make CLEAN" after compiling and testing. |
-clean Do "make CLEAN" after compiling and testing. |
|
-noieee By default, $0 uses the -ieee option for genmake. This turns it off. |
|
396 |
-cleanup Aggresively removes all model output, executables and object files |
-cleanup Aggresively removes all model output, executables and object files |
397 |
and then exits. Use with care. |
and then exits. Use with care. |
398 |
|
|
424 |
clean=0 |
clean=0 |
425 |
expts='' |
expts='' |
426 |
# ieee=1 |
# ieee=1 |
427 |
# quick=0 |
|
428 |
|
IEEE= |
429 |
|
if test "x$MITGCM_IEEE" != x ; then |
430 |
|
IEEE=$MITGCM_IEEE |
431 |
|
fi |
432 |
|
|
433 |
|
|
434 |
|
CLEANUP=f |
435 |
|
QUICK=f |
436 |
|
NOGENMAKE=f |
437 |
|
NOCLEAN=f |
438 |
|
NODEPEND=f |
439 |
|
|
440 |
BASH= |
BASH= |
441 |
OPTFILES= |
OPTFILE=NONE |
442 |
ADDRESSES=edhill@mitgcm.org |
ADDRESSES= |
443 |
TESTDIRS= |
TESTDIRS= |
444 |
MPACKDIR="../tools/mpack-1.6" |
MPACKDIR="../tools/mpack-1.6" |
445 |
MPACK="$MPACKDIR/mpack" |
MPACK="$MPACKDIR/mpack" |
467 |
usage ;; |
usage ;; |
468 |
|
|
469 |
-optfile | --optfile | -of | --of) |
-optfile | --optfile | -of | --of) |
470 |
ac_prev=OPTFILES ;; |
ac_prev=OPTFILE ;; |
471 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
472 |
OPTFILES=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
473 |
|
|
474 |
-addr | --addr | -a | --a) |
-addr | --addr | -a | --a) |
475 |
ac_prev=ADDRESSES ;; |
ac_prev=ADDRESSES ;; |
496 |
-make=* | --make=*) |
-make=* | --make=*) |
497 |
MAKE=$ac_optarg ;; |
MAKE=$ac_optarg ;; |
498 |
|
|
499 |
-mpi) MPI=t ;; |
-clean | --clean) |
500 |
|
CLEANUP=t ;; |
501 |
|
|
502 |
|
-quick | --quick | -q | --q) |
503 |
|
QUICK=t ;; |
504 |
|
-nogenmake | --nogenmake | -ng | --ng) |
505 |
|
NOGENMAKE=t ;; |
506 |
|
-noclean | --noclean | -nc | --nc) |
507 |
|
NOCLEAN=t ;; |
508 |
|
-nodepend | --nodepend | -nd | --nd) |
509 |
|
NODEPEND=t ;; |
510 |
|
|
511 |
|
-mpi) MPI=true ;; |
512 |
|
|
513 |
|
-ieee) IEEE=true ;; |
514 |
|
-noieee) IEEE= ;; |
515 |
|
|
516 |
-verbose) verbose=2 ;; |
-verbose) verbose=2 ;; |
517 |
-debug) debug=1 ;; |
-debug) debug=1 ;; |
|
-clean) clean=1 ;; |
|
518 |
-quiet) verbose=0 ;; |
-quiet) verbose=0 ;; |
519 |
|
|
520 |
-*) |
-*) |
531 |
|
|
532 |
done |
done |
533 |
|
|
534 |
|
if test "x$QUICK" = xt ; then |
535 |
|
NOGENMAKE=t |
536 |
|
NOCLEAN=t |
537 |
|
NODEPEND=t |
538 |
|
fi |
539 |
|
|
540 |
if test "x$TESTDIRS" = x ; then |
if test "x$TESTDIRS" = x ; then |
541 |
TESTDIRS=`scandirs` |
TESTDIRS=`scandirs` |
542 |
fi |
fi |
543 |
|
|
544 |
|
if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then |
545 |
|
OPTFILE=$MITGCM_OF |
546 |
|
fi |
547 |
|
|
548 |
echo "OK" |
echo "OK" |
549 |
|
|
550 |
# create the FORTRAN comparison code |
# create the FORTRAN comparison code |
583 |
|
|
584 |
NDIR=0 |
NDIR=0 |
585 |
|
|
586 |
# For each optfile... |
if test "x$OPTFILE" != xNONE ; then |
587 |
for OPTFILE in $OPTFILES ; do |
if test -r $OPTFILE ; then |
588 |
|
OPTFILE=`pwd`"/$OPTFILE" |
|
OPTFILE=`pwd`"/$OPTFILE" |
|
|
if test ! -r $OPTFILE ; then |
|
|
echo "Error: can't read optfile \"$OPTFILE\"" |
|
|
exit 1 |
|
589 |
fi |
fi |
590 |
echo |
fi |
591 |
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
echo |
592 |
echo >> $SUMMARY |
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
593 |
|
echo >> $SUMMARY |
|
# ...and each test directory... |
|
|
for dir in $TESTDIRS ; do |
|
594 |
|
|
595 |
# Verify that the testdir exists and contains previous |
# ...and each test directory... |
596 |
# results in the correct location--or skip this directory! |
for dir in $TESTDIRS ; do |
597 |
if test ! -r $dir"/results/output.txt" ; then |
|
598 |
echo | tee -a $SUMMARY |
# Cleanup only! |
599 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \ |
if test "x$CLEANUP" = xt ; then |
600 |
| tee -a $SUMMARY |
if test -r $dir/build/Makefile ; then |
601 |
continue |
( cd $dir/build ; make CLEAN ) |
602 |
fi |
fi |
603 |
|
if test -r $dir/input/Makefile ; then |
604 |
# Is this an MPI run? |
( cd $dir/input ; make CLEAN ) |
|
if test "x$MPI" = xt ; then |
|
|
if test ! -r $dir"/code/CPP_EEOPTIONS.h_mpi" -o ! -r $dir"/code/SIZE.h_mpi" ; then |
|
|
echo | tee -a $SUMMARY |
|
|
echo "can't read \"$dir/code/CPP_EEOPTIONS.h_mpi\" or \"$dir/code/SIZE.h_mpi\"" \ |
|
|
| tee -a $SUMMARY |
|
|
continue |
|
|
else |
|
|
cp $dir"/code/CPP_EEOPTIONS.h_mpi" $dir"/code/CPP_EEOPTIONS.h" |
|
|
cp $dir"/code/SIZE.h_mpi" $dir"/code/SIZE.h" |
|
|
fi |
|
|
else |
|
|
if test -r $dir"/code/CPP_EEOPTIONS.h_nompi" ; then |
|
|
cp $dir"/code/CPP_EEOPTIONS.h_nompi" $dir"/code/CPP_EEOPTIONS.h" |
|
|
fi |
|
|
if test -r $dir"/code/SIZE.h_nompi" ; then |
|
|
cp $dir"/code/SIZE.h_nompi" $dir"/code/SIZE.h" |
|
|
fi |
|
605 |
fi |
fi |
606 |
|
continue |
607 |
|
fi |
608 |
|
|
609 |
# Create an output dir for each OPTFILE/tdir combination |
# Verify that the testdir exists and contains previous |
610 |
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
# results in the correct location--or skip this directory! |
611 |
mkdir $CDIR |
if test ! -r $dir"/results/output.txt" ; then |
612 |
CDIR=`pwd`"/$CDIR" |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
613 |
|
continue |
614 |
|
fi |
615 |
|
|
616 |
# ...configue, make, run, and compare the output. |
echo "-------------------------------------------------------------------------------" |
617 |
echo "-------------------------------------------------------------------------------" |
echo |
618 |
echo |
echo "Experiment: $dir" |
619 |
echo "Experiment: $dir" |
echo |
620 |
echo |
unset genmake makedepend make run |
621 |
unset genmake makedepend make run |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
|
( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; ) |
|
|
if [ -r $dir/build ]; then |
|
|
seperatebuilddir=1 |
|
|
builddir=build |
|
|
rundir=build |
|
|
( cd $dir/build; ln -sf ../input/* . ) |
|
|
else |
|
|
seperatebuilddir=0 |
|
|
builddir=input |
|
|
rundir=input |
|
|
fi |
|
622 |
|
|
623 |
|
if [ -r $dir/build ]; then |
624 |
|
seperatebuilddir=1 |
625 |
|
builddir=build |
626 |
|
rundir=build |
627 |
|
( cd $dir/build; ln -sf ../input/* . ) |
628 |
|
else |
629 |
|
seperatebuilddir=0 |
630 |
|
builddir=input |
631 |
|
rundir=input |
632 |
|
fi |
633 |
|
|
634 |
|
CODE_DIR=$dir/code |
635 |
|
BUILD_DIR=$dir/$builddir |
636 |
|
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
637 |
|
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
638 |
|
|
639 |
|
# Is this an MPI run? |
640 |
|
if test "x$MPI" = xt ; then |
641 |
|
FILES=$MPI_FILES |
642 |
|
endings="_mpi" |
643 |
|
else |
644 |
|
FILES=$NOMPI_FILES |
645 |
|
endings="_nompi" |
646 |
|
fi |
647 |
|
|
648 |
|
# Check to see that we have the files |
649 |
|
have_files=t |
650 |
|
for i in $FILES ; do |
651 |
|
if test ! -r $CODE_DIR/$i ; then |
652 |
|
echo "Warning: can't read file $CODE_DIR/$i" |
653 |
|
have_files=f |
654 |
|
fi |
655 |
|
done |
656 |
|
if test "x$have_files" != xt -a "x$MPI" = xt ; then |
657 |
|
echo "Skipping $dir due to lack of input files (see above warning)" |
658 |
|
continue |
659 |
|
fi |
660 |
|
|
661 |
|
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
662 |
|
if test "x$have_files" = xt ; then |
663 |
|
for i in $FILES ; do |
664 |
|
sstr="s|$endings||" |
665 |
|
name=`echo $i | sed -e $sstr ` |
666 |
|
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
667 |
|
RETVAL=$? |
668 |
|
if test "x$RETVAL" != x0 ; then |
669 |
|
cp $CODE_DIR/$i $BUILD_DIR/$name |
670 |
|
fi |
671 |
|
done |
672 |
|
fi |
673 |
|
|
674 |
|
# Create an output dir for each OPTFILE/tdir combination |
675 |
|
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
676 |
|
mkdir $CDIR |
677 |
|
CDIR=`pwd`"/$CDIR" |
678 |
|
|
679 |
|
if test "x$CLEANUP" = xt ; then |
680 |
|
makeclean $dir/$builddir |
681 |
|
else |
682 |
genmakemodel $dir/$builddir && genmake=Y \ |
genmakemodel $dir/$builddir && genmake=Y \ |
683 |
&& makeclean $dir/$builddir \ |
&& makeclean $dir/$builddir \ |
684 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
686 |
&& linkdata $seperatebuilddir $dir/$rundir \ |
&& linkdata $seperatebuilddir $dir/$rundir \ |
687 |
&& runmodel $dir/$builddir && run=Y \ |
&& runmodel $dir/$builddir && run=Y \ |
688 |
&& results=`testoutput $dir $rundir` |
&& results=`testoutput $dir $rundir` |
689 |
echo |
fi |
690 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
|
691 |
${run:-N} $results |
echo |
692 |
echo |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
693 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
${run:-N} $results |
694 |
${run:-N} $results >> $SUMMARY |
echo |
695 |
echo "fresults='" > $CDIR"/summary.txt" |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
696 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
${run:-N} $results >> $SUMMARY |
697 |
${run:-N} $results >> $CDIR"/summary.txt" |
echo "fresults='" > $CDIR"/summary.txt" |
698 |
echo "'" >> $CDIR"/summary.txt" |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
699 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
${run:-N} $results >> $CDIR"/summary.txt" |
700 |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
echo "'" >> $CDIR"/summary.txt" |
701 |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
702 |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
703 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
704 |
( |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
705 |
cd $DRESULTS |
|
706 |
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
( |
707 |
gzip $NDIR".tar" |
cd $DRESULTS |
708 |
) |
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
709 |
|
gzip $NDIR".tar" |
710 |
|
) |
711 |
|
|
712 |
|
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
713 |
|
echo "No mail sent" |
714 |
|
else |
715 |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
716 |
RETVAL=$? |
RETVAL=$? |
717 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
719 |
else |
else |
720 |
rm -f $DRESULTS"/"$NDIR".tar*" |
rm -f $DRESULTS"/"$NDIR".tar*" |
721 |
fi |
fi |
722 |
|
fi |
723 |
|
|
724 |
NDIR=$(( $NDIR + 1 )) |
echo "-------------------------------------------------------------------------------" |
725 |
|
|
726 |
done |
NDIR=$(( $NDIR + 1 )) |
727 |
|
|
728 |
done |
done |
729 |
|
|
730 |
rm tmp_cmpnum.f a.out |
rm tmp_cmpnum.f a.out |