#!/bin/bash
echo ' '
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo %% Try to translate contours into gridded  format %%%
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cp ./input/TopoInfo.dat ./divawork/fort.13
cp ./input/coast.cont ./divawork/fort.10
cd ./divawork
if [ -f ../output/diva.log ] ; then
 cp  -f ../output/diva.log .
fi
../../bin/cont2grid.a >> diva.log
if [ $? -ne 0 ];then
echo ' '
echo --------------------------------------------
echo A problem was encountered during execution !
echo        divacont2grid:   cont2grid.a
echo Check execution track
echo --------------------------------------------
echo ' ' >> diva.log
echo -------------------------------------------- >> diva.log
echo A problem was encountered during execution ! >> diva.log
echo        divacont2grid: cont2grid.a  >> diva.log
echo Check execution track >> diva.log
echo -------------------------------------------- >> diva.log
fi
 cp -f diva.log ../output/.
cp -v fort.99 ../output/topomask.grd
rm -f fort13
rm -f fort.10
rm -f fort.99
rm -f fort.66
if [ "$1" == "-r" ] 
then
echo Placing new contour file as input
cp -v ../output/topomask.grd ../input/topomask.grd
fi
cd ..
