# run this script by typing: source hopper-pgi-cmake
# After thus script completes, type: make -j 8
# If rebuilding, type 'make clean' before running 'make -j 8'

# This cmake configuration script builds cism_driver


# This script should be run from the builds/linux-gnu-bisicles subdirectory
# of the main seacism repository (reflected in the two instances
# of "../.." below).

# BUILD OPTIONS:
# The call to cmake below includes several input ON/OFF switch parameters, to
# provide a simple way to select different build options.  These are:
# CISM_BUILD_CISM_DRIVER -- ON by default, set to OFF to only build the CISM libraries.
# CISM_ENABLE_BISICLES -- OFF by default, set to ON to build a BISICLES-capable cism_driver.
# CISM_ENABLE_FELIX -- OFF by default, set to ON to build a FELIX-capable cism_driver.
# CISM_USE_TRILINOS -- OFF by default, set to on for builds with Trilinos.
# CISM_MPI_MODE -- ON by default, only set to OFF for serial builds.
# CISM_SERIAL_MODE -- OFF by default, set to ON for serial builds.
# CISM_USE_GPTL_INSTRUMENTATION -- ON by default, set to OFF to not use GPTL instrumentation.
# CISM_COUPLED -- OFF by default, set to ON to build with CESM.
#popd

echo
echo "Doing CMake Configuration step"

#set Netcdf installation directory here
#setenv NETCDF_HOME /home/loren/users/dmartin/util/netcdf/netcdf-4.1.2 
#setenv NETCDF_HOME /usr/local/netcdf 
setenv NETCDF_HOME ${NETCDFHOME}
setenv NETCDFF_HOME ${NETCDFFHOME}

cmake \
  -D CISM_NETCDF_DIR=${NETCDF_HOME} \
  -D CISM_BUILD_CISM_DRIVER:BOOL=ON \
  -D CISM_ENABLE_BISICLES=ON \
  -D CISM_ENABLE_FELIX=OFF \
\
  -D CISM_USE_TRILINOS:BOOL=OFF \
  -D CISM_MPI_MODE:BOOL=ON \
  -D CISM_SERIAL_MODE:BOOL=OFF \
\
  -D CISM_USE_GPTL_INSTRUMENTATION:BOOL=OFF \
  -D CISM_COUPLED:BOOL=OFF \
  -D CMAKE_INSTALL_PREFIX:PATH=$PWD/install \
  -D CMAKE_VERBOSE_MAKEFILE:BOOL=ON \
\
  -D CMAKE_CXX_COMPILER=/usr/bin/mpiCC \
  -D CMAKE_C_COMPILER=/usr/bin/mpicc \
  -D CMAKE_Fortran_COMPILER=/usr/bin/mpif90 \
\
  -D CISM_HDF5_LIB_DIR=${ANAG_HDF5_DIR}/lib \
  -D CISM_HDF5_LIBS="-lnetcdff -lnetcdf -lhdf5 -lhdf5_hl -lz -lstdc++" \
  -D CMAKE_PREFIX_PATH="${ANAG_HDF5_DIR}" \
\
  -D CMAKE_CXX_FLAGS:STRING="-g" \
  -D CISM_Fortran_FLAGS:STRING="-g  -ffree-line-length-none -fno-range-check -DNO_RESCALE" \
  -D CISM_EXTRA_LIBS:STRING="-llapack -lblas -lhdf5 -lhdf5_hl" \
  -D BISICLES_INTERFACE_DIR=$PWD/../../../BISICLES/CISM-interface/interface \
  -D BISICLES_LIB_SUBDIR=libgnu \
 ../..

# Note: last argument above  "../.."  is path to top seacism directory
