#!/bin/bash

source ./functions

##
## entry point for script
##

MPI_IO_TEST=${CLUSTER_DIR}/mpi-io-test

${CLUSTER_DIR}/mpich2/bin/mpicc ${PVFS2_DEST}/pvfs2-${CVS_TAG}/test/client/mpi-io/mpi-io-test.c -o $MPI_IO_TEST

if [ $? -eq 1 ] ; then
	exit 1
fi

# like the other mpiio tests we can only do multi processor tests if there's a
# pav config file we can use
# If we have to we can fall back to single processor, and still do something
# reasonable. 

if [ -f $PAV_CONFIG ] ; then 
	# write out a pbs script
	pbs_script=${CLUSTER_DIR}/mpiiotest.sh
	make_pbs_script ${MPI_IO_TEST} -f pvfs2:\${MOUNTPOINT}/file1 -b $((1024*1024*32)) -y -c> $pbs_script

	# submit it
	job_id=$(qsub -N mpiiotest $pbs_script | cut -d . -f1)

	# wait patently for it to complete
	block_until_done $job_id

	# need to get results into per-test log files
	cat mpiiotest.o$job_id

	# need to know if we failed or not
	grep -q 'bandwidth' mpiiotest.o$job_id
fi
