#!/bin/bash
surfex_dir="$1"
shift
tmp_dir=/tmp
std_eqn="x^3+y^3+z^3+1-0.25*(x+y+z+1)^3"
allargs=""
if [ -z $1 ] ; then
    allargs="-e $std_eqn"
else
    allargs=$*
fi
echo "$PWD" | sed -e 's/ /\\ /g' > $tmp_dir/tmp.$$.txt
read surfexstartdir <$tmp_dir/tmp.$$.txt
command rm $tmp_dir/tmp.$$.txt
cd "$surfex_dir"
java -jar surfex.jar -d "$surfexstartdir" -t "$tmp_dir" $allargs
