source make_sso.env


if [ ! -f Relief.nc ]; then
echo Attention missing Relief.nc file
echo I download it
wget --no-check-certificate -nv https://web.lmd.jussieu.fr/~lmdz/pub/3DInputData/Limit/Relief.nc
fi

if [ ! -d SPHEREPACK ]; then
echo Missing SPHEREPACK library. I download it
wget --no-check-certificate -nv https://web.lmd.jussieu.fr/~lmdz/pub/import/spherepack3.2.tgz 
tar -xvf spherepack3.2.tgz
mv spherepack3.2 SPHEREPACK
mv SPHEREPACK/make.inc SPHEREPACK/make.inc.old

# copy more adequate make.inc to SPHEREPACK
mv make.inc SPHEREPACK/.
# copy corrected Makefile to SPHEREPACK/test
mv SPHEREPACK/test/Makefile SPHEREPACK/test/Makefile.old
mv  Makefile.test SPHEREPACK/test/Makefile 
# clean up
rm spherepack3.2.tgz
fi



if [ ! -f SPHEREPACK/lib/libspherepack.a ]; then
  cd SPHEREPACK ; gmake ; cd -
fi
SRC="make_sso_SpherePack.f90"
mode=prod

case $mode in
  prod) OPTS="-O3" ;;
  debug) OPTS="-check all -g" ;;
esac

ifort -assume realloc_lhs $OPTS -o make_sso.e make_sso_SpherePack.f90 -I$NETCDFFORTRAN_INCDIR $netcdf -L$NETCDFFORTRAN_LIBDIR -lnetcdff -lnetcdf -L./SPHEREPACK/lib -lspherepack -L$FFTW3_LIBDIR -lfftw3
