#
# 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.
#
.SUFFIXES:
.SUFFIXES: .f .F .o .a .f90 .F90

SIESTA_ARCH=x86_64-ubuntu-12.04-ifort-13-mkl-11.0-openmpi-1.6.3-siesta-trunk-428-netcdf-3.6.3

FPP=
FPP_OUTPUT=
FC=mpif90
RANLIB=ranlib    #or echo

SYS=nag

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

#DUMMY_FOX= --enable-dummy

FFLAGS= -O2 -march=corei7 -xSSE4.2 -axSSE4.2 -msse4.2 -i-static
#-xHOST
FFLAGS_DEBUG= -g
FPPFLAGS= -DFC_HAVE_FLUSH -DFC_HAVE_ABORT -DMPI -DGRID_DP -DPHI_GRID_SP -DBROYDEN_DP -DCDF -DTRANSIESTA
LDFLAGS= -openmp

ARFLAGS_EXTRA=

FCFLAGS_fixed_f=
FCFLAGS_free_f90=
FPPFLAGS_fixed_F=
FPPFLAGS_free_F90=
#NO.1
#MKLROOT=/opt/intel/composer_xe_2013.1.117/mkl

#BLAS_LIBS=-L$(MKLROOT)/lib/intel64 -lmkl_blas95_lp64 -lmkl_intel_lp64
#LAPACK_LIBS=-L$(MKLROOT)/lib/intel64 -lmkl_lapack95_lp64 -lmkl_sequential -lmkl_core -lmkl_mc3 #dc_lapack.a liblapack.a
#BLACS_LIBS=-L$(MKLROOT)/lib/intel64 -lmkl_blacs_openmpi_lp64
#SCALAPACK_LIBS=-L$(MKLROOT)/lib/intel64 -lmkl_scalapack_lp64

#NO.2  mc3.s or core.a
MKLPATH=/opt/intel/l_mkl_11.1.0.080/mkl/lib/intel64
SUGGESTED_LIBS=$(MKLPATH)/libmkl_scalapack_lp64.a \
               -Wl,--start-group \
                  $(MKLPATH)/libmkl_intel_lp64.a \
                  $(MKLPATH)/libmkl_blas95_lp64.a \
                  $(MKLPATH)/libmkl_lapack95_lp64.a \
                  $(MKLPATH)/libmkl_intel_thread.a \
                  $(MKLPATH)/libmkl_core.a \
                  $(MKLPATH)/libmkl_blacs_openmpi_lp64.a \
               -Wl,--end-group \
               -liomp5 -lpthread -lm


#LIBS=$(SCALAPACK_LIBS) $(BLACS_LIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(NETCDF_LIBS)
#threading=sequential
#LIBS=$(SCALAPACK_LIBS) -Wl,--start-group $(BLACS_LIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(NETCDF_LIBS) -Wl,--end-group -lpthread -lm
#
#threading=threading
#LIBS=$(SCALAPACK_LIBS) -Wl,--start-group $(BLAS_LIBS) $(LAPACK_LIBS) $(CORE_LIBS) $(BLACS_LIBS) -Wl,--end-group -liomp5 -lpthread -lm # $(NETCDF_LIBS)
#

COMP_LIBS=                          #dc_lapack.a liblapack.a libblas.a

NETCDF_LIBS=
NETCDF_INTERFACE=

#
#
NETCDF_ROOT=/opt/netcdf-3.6.3
NETCDF_INCFLAGS=-I$(NETCDF_ROOT)/include
DEFS_CDF=-DCDF
#
NETCDF_LIBS= -L$(NETCDF_ROOT)/lib -lnetcdf #-lnetcdff
#METIS_LIB=/share/apps/metis-4.0/libmetis.a
#
LIBS=$(SUGGESTED_LIBS) $(NETCDF_LIBS) #$(METIS_LIB)


#SIESTA needs an F90 interface to MPI
#This will give you SIESTA's own implementation
#If your compiler vendor offers an alternative, you may change
#to it here.
MPI_INTERFACE= libmpi_f90.a
MPI_INCLUDE=/opt/openmpi-1.6.3/include

#Dependency rules are created by autoconf according to whether
#discrete preprocessing is necessary or not.
.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)  $<
