#
# should be run as ./do_test oofem_target_dir_path
#
RESULT=$1/test_results

#test if param provided
if [ -z $1 ]
then
echo "usage: do_test oofem_target_dir_path"
exit
fi

#test if valid target provided
if [ ! -d $1 ]
then
echo "invalid oofem_target_dir_path"
exit 
fi

# determine oofem version to use
if [ ! -f $1/bin/oofem ]
then
echo "oofem executable not found" >> ${RESULT}
exit
fi

# determine poofem version to use
if [ ! -f $1/bin/poofem ]
then
echo "poofem executable not found" >> ${RESULT}
exit
fi

ln -s $1/bin/oofem  ./oofem
ln -s $1/bin/poofem ./poofem

./oofem -f bar03.oofem.in -ksp_rtol 1.e-15
python ../../../tools/extractor.py -c -f bar03.oofem.in >> ${RESULT}
./oofem -f bar03.statics.oofem.in -ksp_rtol 1.e-15
python ../../../tools/extractor.py -c -f bar03.statics.oofem.in >> ${RESULT}
mpirun -np 2 ./poofem -f bar03.oofem.in -ksp_rtol 1.e-15
for i in *.in??; do python ../../../tools/extractor.py -c -f $i; done >> ${RESULT}

rm *.oofem.out
rm *.oofem.out.*

rm oofem
rm poofem
