
# Makefile to link LAPACK (or BLAS) from MKL (sequential or parallel)
# GCG 16-Oct-2013

LAPACK_DIR = /vol/thchem/lib/mkl-sequential
LAPACK     = lapack_mkl_sequential

# To use executable:
# setenv LD_LIBRARY_PATH = /vol/thchem/lib/mkl-sequential
#
# or in bash:
# LD_LIBRARY_PATH=/vol/thchem/lib/mkl-sequential
# EXPORT LD_LIBRARY_PATH

# for parallel version of MKL:
# LAPACK_DIR = /vol/thchem/lib/mkl-parallel
# LAPACK     = lapack_mkl_parallel

# specify the number of parallel threads:
# setenv MKL_NUM_THREADS 8

# or in bash:
# MKL_NUM_THREADS=8
# EXPORT MKL_NUM_THREADS

# For BLAS the directories are the same, and the library names are:
# BLAS     = blas_mkl_sequential
# BLAS     = blas_mkl_parallel


FC        = gfortran			# fortran compiler
FFLAGS    =  -O				# fortran flags
EXEC      = tst_lapack_mkl		# executable
OBJECT    = tst_lapack_mkl.o		# object

# to link the executable:
$(EXEC): $(OBJECT)
	$(FC) -o $@ -L $(LAPACK_DIR) $(OBJECT) -l$(LAPACK)

# gfortran -o tst_lapack_mkl -L /vol/thchem/lib/mkl-sequential tst_lapack_mkl.f -llapack_mkl_sequential

# WARNING: this will NOT work:
#	$(FC) -o $@ -L $(LAPACK_DIR) -l$(LAPACK)  $(OBJ)
# The fortran source.f or object.o must come BEFORE -lsomelibrary

# It is assumed that libiomp5.so is already available from
# /opt/intel/lib/intel64/libiomp5.so
# If not, it must be linked as well using -liomp5 (at the end)

# To test whether the correct libraries are linked use
# ldd tst_lapack_mkl

clean:
	rm -f *.o

veryclean: clean
	rm -f $(EXEC)
