#!/bin/sh
#
#
eCode=0
temp_success="1"
/bin/rm  -f  out.txt err_out.txt \
             vcs_equilibrate_res.csv \
             diff_csv.txt  diff_out.txt
#
# Create a symbolic link to mpequil, if none exists already
#

testName=NaCl_equil

BINDIR=../../../bin

#################################################################
#
#################################################################
MPEQUIL_EXE=${MPEQUIL_EXE:=nacl_equil}

./$MPEQUIL_EXE -d 3 > out.txt 2>err_out.txt
retnStat=$?
if test $retnStat != "0" 
then
  echo "mpequil returned with bad status, $retnStat, check output"
fi

diff -w good_out.txt out.txt  > diff_out.txt
retnStat_txt=$?
$BINDIR/csvdiff -a 1.0E-50 vcs_equilibrate_blessed.csv vcs_equilibrate_res.csv  > diff_csv.txt
retnStat_csv=$?

if test $retnStat_csv = "1"  
then
  echo "Successful test comparison on "`pwd`
  if [ $retnStat_txt != "0" ]
  then
     echo "   But, text output files have differences. See diff_out.txt"
  fi
else
  echo "Unsuccessful test comparison on "`pwd` " test"
  if test $retnStat_csv != "1"  
  then
     echo "      csv files are different - see diff_csv.txt"
  fi
  if test $retnStat_txt != "0" 
  then
     echo "      And, text output files have differences. See diff_out.txt"
  fi
fi
#
# return 0 for no errors, 1 for errors
#
exit $eCode

