# CP2K arch file for Juwels psmp
# module load GCC, ParastationMPI/5.2.2-1 FFTW/3.3.8 imkl/2019.5.281

CC       = mpicc
FC       = mpif90 -fopenmp
LD       = mpif90 -fopenmp
AR       = ar -r

DATA_DIR   = /p/project/prpb92/CP2K/cp2k-8.1/data
CP2K_ROOT  = /p/project/prpb92/CP2K

MKL_LIB = ${MKLROOT}/lib/intel64

DFLAGS   = -D__FFTW3 -D__MKL -D__ELPA=202005 \
           -D__LIBINT -D__MAX_CONTR=4  -D__LIBXC -D__LIBXSMM \
           -D__parallel -D__SCALAPACK -D__MPI_VERSION=3 \
           -D__STATM_RESIDENT

CFLAGS   = -O3 -mavx -funroll-loops -ftree-vectorize \
           -ffree-form -mtune=native -fno-math-errno 

FCFLAGS  = $(DFLAGS) $(CFLAGS) \
           -I$(CP2K_ROOT)/libs/libint/include \
           -I$(MKLROOT)/include -m64 \
           -I$(CP2K_ROOT)/libs/libxsmm/include \
           -I$(CP2K_ROOT)/libs/libxc/include   \
           -I$(CP2K_ROOT)/libs/elpa-openmp/include/elpa_openmp-2020.05.001/modules \
           -I$(CP2K_ROOT)/libs/elpa-openmp/include/elpa_openmp-2020.05.001/elpa

LDFLAGS  = $(FCFLAGS)

LIBS     = -L$(CP2K_ROOT)/libs/libint/lib -lint2  \
           -L$(CP2K_ROOT)/libs/libxsmm/lib -lxsmmf -lxsmm -lxsmmext \
           -L$(CP2K_ROOT)/libs/libxc/lib -lxcf90 -lxcf03 -lxc \
           -L$(CP2K_ROOT)/libs/elpa-openmp/lib -lelpa_openmp \
           $(PLUMED_DEPENDENCIES) -lfftw3 -lfftw3_threads -lz -ldl -lstdc++ \
           $(MKL_LIB)/libmkl_scalapack_lp64.a -Wl,--start-group \
           $(MKL_LIB)/libmkl_gf_lp64.a ${MKL_LIB}/libmkl_sequential.a \
           $(MKL_LIB)/libmkl_core.a \
           ${MKL_LIB}/libmkl_blacs_intelmpi_lp64.a -Wl,--end-group \
           -lpthread -lm

