##############
# source /opt/intel/parallel_studio_xe_2015/psxevars.sh
# source /opt/intel/parallel_studio_xe_2017.0.035/psxevars.sh
# source /opt/intel/Compiler/11.0/083/bin/ifortvars.sh intel64
# source /opt/intel/impi_5.0.2/bin64/mpivars.sh
# This file is part of the SIESTA package.
#
# Copyright (c) Fundacion General Universidad Autonoma de Madrid:
# E.Artacho, J.Gale, A.Garcia, J.Junquera, P.Ordejon, D.Sanchez-Portal
# and J.M.Soler, 1996- .
# 
# Use of this software constitutes agreement with the full conditions
# given in the SIESTA license, as signed by all legitimate users.
#
# ------------
# Description:
#              Intel compiler/mkl  V11 on atto
#              OpenMPI with support for Intel compiler V11
#              MKL V11 libraries, including a version of BLACS provided
#                             by Intel for the openmpi framework,
#                             and Intel's own Scalapack, Lapack, and BLAS.
#
# Execution:
#
#           $(OPENMPI_ROOT)/bin in PATH
#           $(OPENMPI_ROOT)/lib in LD_LIBRARY_PATH
#
#           mpirun -np NPROCS siesta ....
#
SIESTA_ARCH=intel-mpi
#
#
FC=mpiifort
FC_SERIAL=ifort

#
#  You can play with other optimization options
#  I am not sure whether the compiler attempts to multithread the code
#
FFLAGS= -w  -O2 -mp
FFLAGS_CHECKS=-g -O0 -debug full -traceback -C
FFLAGS_DEBUG= -g
LDFLAGS= 
#COMP_LIBS += libncdf.a libfdict.a
RANLIB=echo
#
# You might want to turn off FoX for Intel11
#
DUMMY_FOX=--enable-dummy
#
#
NETCDF_ROOT=/software/lib/netcdf
NETCDF_INCFLAGS=-I$(NETCDF_ROOT)/include
NETCDF_LIBS=-L$(NETCDF_ROOT)/lib64 -lnetcdff -lnetcdf
HDF5_ROOT=/software/lib/hdf5
LIBS +=-L$(HDF5_ROOT)/lib64 -lhdf5_fortran -lhdf5 -lz
FPPFLAGS_CDF=-DCDF -DNCDF_4 -DNCDF_PARALLEL
#
MPI_INTERFACE=libmpi_f90.a
MPI_INCLUDE=.      # Note . for no-op
FPPFLAGS_MPI=-DMPI

METIS_LIB=/software/lib/metis/lib/libmetis.a
FPPFLAGS += -DSIESTA__METIS

#
# From the "Intel advisor"
#
#MKLPATH=/opt/intel/composer_xe_2015/mkl/lib/intel64
#MKLPATH=/opt/intel/Compiler/11.0/083/mkl/lib/em64t
MKLPATH=/opt/intel/compilers_and_libraries_2017.0.098/linux/mkl/lib/intel64_lin
SUGGESTED_LIBS=$(MKLPATH)/libmkl_scalapack_lp64.a \
               -Wl,--start-group \
                  $(MKLPATH)/libmkl_intel_lp64.a \
                  $(MKLPATH)/libmkl_sequential.a \
                  $(MKLPATH)/libmkl_core.a \
                  $(MKLPATH)/libmkl_blacs_intelmpi_lp64.a \
               -Wl,--end-group \
               -lpthread 
#
COMP_LIBS += libncdf.a libfdict.a

LIBS=$(SUGGESTED_LIBS) $(NETCDF_LIBS) $(COMP_LIBS) $(METIS_LIB)
#
SYS=nag
FPPFLAGS= $(FPPFLAGS_CDF) $(FPPFLAGS_MPI)
INCFLAGS +=$(NETCDF_INCFLAGS)
FFLAGS += $(INCFLAGS)
#
.F.o:
    $(FC) -c $(FFLAGS) $(INCFLAGS)  $(FPPFLAGS) $<
.f.o:
    $(FC) -c $(FFLAGS) $(INCFLAGS)   $<
.F90.o:
    $(FC) -c $(FFLAGS) $(INCFLAGS)  $(FPPFLAGS) $<
.f90.o:
    $(FC) -c $(FFLAGS) $(INCFLAGS)  $(FPPFLAGS) $<
