#! /bin/sh
#
# Run the tests for the barrier test
#
#MACH=anlsp2
MACH=`uname -s`
Show=eval
OPT="-O"
donopoll=1
do_html=0
#PATH=/usr/local/mpi/lib/rs6000/ch_mpl:$PATH
#PATH=/home/MPI/mpich/lib/rs6000/ch_mpl:$PATH
#export PATH
do_base=0
do_update=0
mpirunargs=""
#
for arg in "$@" ; do
    case $arg in 
	-echo) set -x ;;
        -np=*) NPLIST=`echo a$arg | sed "s/a-np=//"` ;;
	-base) do_base=1 ;;
	-show) Show=echo ;;
	-mach=*) MACH=`echo a$arg | sed "s/a-mach=//"` ;;
	-nopoll) mpirunargs="-nopoll" ;;
	-update) do_update=1 ;;
	-html) do_html=1 ;;
        -logs) echo "No logfiles for barrier" ; exit 0 ;;
        *) echo "Unrecognized argument $arg" ; exit 1 ;;
    esac
done
#
if [ -z "$MPIEXMPL_MAX_NP" ] ; then
    MPIEXMPL_MAX_NP=16
fi
if [ $do_base = 1 ] ; then 
    if [ -s related.lst ] ; then 
	dirs=". `cat related.lst`"
    else
	dirs="."
    fi
    for dir in $dirs ; do
	( cd $dir ; \
	if [ $do_html = 1 ] ; then \
	    echo "<H2>`cat title.txt`</H2>" ; \
	    echo "<PRE>" ; \
	else cat title.txt ; fi ; \
          $Show make barrier ; \
	  for np in 1 2 4 8 16 32 64 128 ; do \
	  if [ $np -gt $MPIEXMPL_MAX_NP ] ; then break ; fi ; \
	  $Show mpirun $mpirunargs -np $np -mvhome barrier ; done )
	if [ $do_html = 1 ] ; then
	    echo "</PRE>"
	fi
    done
    exit 0
fi
