# 
# Copyright (C) 1996-2016	The SIESTA group
#  This file is distributed under the terms of the
#  GNU General Public License: see COPYING in the top directory
#  or http://www.gnu.org/copyleft/gpl.txt.
# See Docs/Contributors.txt for a list of contributors.
#
#-------------------------------------------------------------------
# arch.make file for Intel compiler.
# To use this arch.make file you should rename it to
#   arch.make
# or make a sym-link.
# For an explanation of the flags see DOCUMENTED-TEMPLATE.make

.SUFFIXES:
.SUFFIXES: .f .F .o .c .a .f90 .F90

SIESTA_ARCH = x86_64_MPI_INTEL

CC = mpicc
FPP = $(FC) -E -P
FC = mpifort
FC_SERIAL = ifort

FFLAGS = -O3 -fPIC -heap-arrays
FPPFLAGS = $(DEFS_PREFIX)-DFC_HAVE_ABORT -DMPI -DSIESTA__MRRR

MPI_INTERFACE=libmpi_f90.a
MPI_INCLUDE=.

AR = ar
RANLIB = ranlib

SYS = nag

SP_KIND = 4
DP_KIND = 8
KINDS = $(SP_KIND) $(DP_KIND)

LDFLAGS =
INCFLAGS=
COMP_LIBS =
LIBS =

### PSML ###

ROOT_GLOBAL=/n/kaxiras_lab/dbennett/lib
PSML_ROOT=$(ROOT_GLOBAL)/libs-libpsml
XMLF90_ROOT=$(ROOT_GLOBAL)/libs-xmlf90
LIBXC_ROOT=$(ROOT_GLOBAL)/libs-libxc

GRIDXC_ROOT = /n/kaxiras_lab/software/siesta/siesta-4.1.5/Docs/build
include $(GRIDXC_ROOT)/share/org.siesta-project/gridxc_dp_mpi.mk
LDFLAGS += -Wl,-rpath,/n/kaxiras_lab/software/siesta/siesta-4.1.5/Docs/build/lib


### LIBFDF ###
FDF_ROOT=$(ROOT_GLOBAL)/libs-libfdf

#include $(XMLF90_ROOT)/share/org.siesta-project/xmlf90.mk
#include $(PSML_ROOT)/share/org.siesta-project/psml.mk
#include $(GRIDXC_ROOT)/gridxc.mk


### NETCDF ###

INCFLAGS += -I/n/kaxiras_lab/software/siesta/siesta-4.1.5/Docs/build/include
LDFLAGS += -L/n/kaxiras_lab/software/siesta/siesta-4.1.5/Docs/build/lib -Wl,-rpath,/n/kaxiras_lab/software/siesta/siesta-4.1.5/Docs/build/lib
LIBS += -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz
COMP_LIBS += libncdf.a libfdict.a
FPPFLAGS += -DCDF -DNCDF -DNCDF_4


### MKL WITH SCALAPACK ###
#MKLROOT = $(INSDIR)/intel/compilers_and_libraries/linux/mkl
INCFLAGS += -I${MKLROOT}/include
LDFLAGS += -L${MKLROOT}/lib/intel64 
LIBS += -lmkl_scalapack_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lmkl_blacs_intelmpi_lp64 -lpthread -lm -ldl


# Dependency rules ---------

FFLAGS_DEBUG = -g -O1   # your appropriate flags here...

# The atom.f code is very vulnerable. Particularly the Intel compiler
# will make an erroneous compilation of atom.f with high optimization
# levels.
atom.o: atom.F
	$(FC) -c $(FFLAGS_DEBUG) $(INCFLAGS) $(FPPFLAGS) $(FPPFLAGS_fixed_F) $< 
state_analysis.o: state_analysis.F
	$(FC) -c $(FFLAGS_DEBUG) $(INCFLAGS) $(FPPFLAGS) $(FPPFLAGS_fixed_F) $< 

.c.o:
	$(CC) -c $(CFLAGS) $(INCFLAGS) $(CPPFLAGS) $< 
.F.o:
	$(FC) -c $(FFLAGS) $(INCFLAGS) $(FPPFLAGS) $(FPPFLAGS_fixed_F)  $< 
.F90.o:
	$(FC) -c $(FFLAGS) $(INCFLAGS) $(FPPFLAGS) $(FPPFLAGS_free_F90) $< 
.f.o:
	$(FC) -c $(FFLAGS) $(INCFLAGS) $(FCFLAGS_fixed_f)  $<
.f90.o:
	$(FC) -c $(FFLAGS) $(INCFLAGS) $(FCFLAGS_free_f90)  $<

