# CP2K arch file for Marenostrum  psmp
# module unload intel impi
# module load gnu/8.4.0
# module load openmpi/4.0.2
# module load mkl/2018.4



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

DATA_DIR   = /gpfs/scratch/pr1emd00/pr1emd01/CP2K/cp2k-8.1/data
CP2K_ROOT  = /gpfs/scratch/pr1emd00/pr1emd01/CP2K


MKL_LIB = ${MKLROOT}/lib/intel64
FFTW_LIB = /gpfs/scratch/pr1emd00/pr1emd01/CP2K/libs/fftw

# Options

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

CFLAGS   = -O3 -mavx -funroll-loops -ftree-vectorize \
           -ffree-form -march=skylake-avx512 -fno-math-errno 

FCFLAGS  = $(DFLAGS) $(CFLAGS) \
           -I$(CP2K_ROOT)/libs/libint/include  \
           -I$(CP2K_ROOT)/libs/libxc/include   \
           -I$(MKLROOT)/include \
           -I$(FFTW_LIB)/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/libxc/lib -lxcf90 -lxcf03 -lxc \
           -L$(CP2K_ROOT)/libs/elpa-openmp/lib -lelpa_openmp \
           $(FFTW_LIB)/lib/libfftw3.a $(FFTW_LIB)/lib/libfftw3_threads.a -lz \
           $(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_openmpi_lp64.a -Wl,--end-group \
           -ldl -lpthread -lm -lstdc++
