# Author: Alfio Lazzaro (alazzaro@cray.com), CRAY, 2013-2014
# Program environments:
# - module load PrgEnv-intel
# Note that MKL FFTW can be used only with Intel compiler >=v14, otherwise the
# version from fftw.org is needed for thread safety.
# To avoid problems with thread pinning (Intel uses N+1 threads for a
# N-threaded OMP run) aprun supports the option "-cc depth" in combination
# with the env variable "export KMP_AFFINITY=compact"

CC       = cc
CPP      = 
FC       = ftn
LD       = ftn
AR       = ar -r
CPPFLAGS =
DFLAGS   = -D__MKL -D__FFTW3 -D__parallel -D__SCALAPACK -D__HAS_smm_dnn -D__HAS_NO_SHARED_GLIBC
CFLAGS   = $(DFLAGS) -O2
FCFLAGS  = $(DFLAGS) -O2 -openmp -openmp-threadprivate=compat \
	   -pad -opt-prefetch -mavx -funroll-loops -fpp -free \
           -nogen-interfaces \
	   -I${MKLROOT}/include -I${MKLROOT}/include/fftw
LDFLAGS  = $(FCFLAGS)
MKL_LIB  = ${MKLROOT}/lib/intel64
LIBS     = /project/cray/alazzaro/libsmm/affinity/sandybridge_gcc_4.9.0/lib/libsmm_dnn_cray.gnu.a
LIBS    += $(MKL_LIB)/libmkl_scalapack_lp64.a -Wl,--start-group \
           $(MKL_LIB)/libmkl_intel_lp64.a ${MKL_LIB}/libmkl_sequential.a \
           $(MKL_LIB)/libmkl_core.a -Wl,--end-group \
           ${MKL_LIB}/libmkl_blacs_intelmpi_lp64.a

