#Makefile for compiling dipelm
#Variable definitions
ver = _0.1
objects = dipelmdefs.o anglib.o angmom_procs.o readsh.o dipelmio.o dipelmprocs.o analytic_1p1_photon_pad.o chiral_procs.o
f90comp = mpiifort -i8 -CB -traceback 
#switch = -check all -g -O3 -mkl #with debugging
# switch = -O3  -xHost -ipo -opt-report 3 -opt-report-phase=hlo -mkl -openmp -parallel
switch = -mkl -openmp -debug full -check all
#-O3 -mkl -openmp -parallel
#modpath = -I/opt/Intel/mkl/include/em64t/lp64/ 32-bit integers
#modpath = -I/opt/Intel/mkl/include/em64t/ilp64/ -I/home/alex/svn_working_copies/interpolate/trunk/src -I/home/alex/svn_working_copies/ukrmol-out/dev-branches/dipelm/source/lib
#modpath = -I/opt/Intel/mkl/include/em64t/ilp64/ -I/home/alex/svn_working_copies/interpolate/trunk/src -I/home/alex/svn_working_copies/ukrmol-out/trunk/lib
#lib = -L/opt/Intel/mkl/lib/em64t -lmkl_blas95_ilp64 -L/home/alex/svn_working_copies/ukrmol-out/dev-branches/dipelm/source/lib -louter -lutil -L/home/alex/svn_working_copies/interpolate/trunk/src -linterpolate
#lib = -L/opt/Intel/mkl/lib/em64t -lmkl_blas95_ilp64 -L/home/alex/svn_working_copies/ukrmol-out/trunk/lib -louter -lutil -L/home/alex/svn_working_copies/interpolate/trunk/src -linterpolate
MKLROOT=/opt/intel/composer_xe_2015.1.133/mkl
MKL_INCLUDE=-I$(MKLROOT)/include/intel64/ilp64  -i8 -I$(MKLROOT)/include
MKL_LINK=-Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_blas95_ilp64.a $(MKLROOT)/lib/intel64/libmkl_lapack95_ilp64.a $(MKLROOT)/lib/intel64/libmkl_intel_ilp64.a $(MKLROOT)/lib/intel64/libmkl_intel_thread.a $(MKLROOT)/lib/intel64/libmkl_core.a -Wl,--end-group -openmp -lpthread -lm
outerpath=/home/zdenek/svn/ukrmol-out/trunk/lib
libukplus=/home/zdenek/svn/ukrmol-in/trunk/source/lib/integral_library/lib_ep
modpath = ${MKL_INCLUDE} -I/home/zdenek/svn/interpolate/trunk/src -I${outerpath}
lib = -L${outerpath} -louter -lutil -L/home/zdenek/svn/interpolate/trunk/src -linterpolate -L${libukplus} -lintegral ${MKL_LINK}
%.o : %.f90
	$(f90comp) -c $(switch) $(modpath) $<
%.o : %.f
	$(f90comp) -c $(switch) $(modpath) $<

.PHONY:dipelm two_photon chiral
all: dipelm two_photon chiral

dipelm:$(objects) dipelm.o
	$(f90comp) -o dipelm dipelm.o $(switch) $(objects) $(lib) $(modpath)

two_photon:$(objects) two_photon.o
	$(f90comp) -o two_photon two_photon.o $(switch) $(objects) $(lib) $(modpath)
	cp analytic_1p1_photon_pad.f90 ../
	cp two_photon.f90 ../

chiral:$(objects) chiral.o
	$(f90comp) -o chiral chiral.o $(switch) $(objects) $(lib) $(modpath)

makelib: $(objects) two_photon.o
	set -x
	ar -r libdipelm.a $(objects)

dipelm.o: dipelmdefs.o anglib.o angmom_procs.o readsh.o dipelmio.o dipelmprocs.o
two_photon.o: analytic_1p1_photon_pad.o chiral_procs.o
analytic_1p1_photon_pad.o: dipelm.o chiral_procs.o
chiral_procs.o: dipelm.o
chiral.o: chiral_procs.o

#Cleaning everything
clean:
	rm -f -r *.o *.mod
#End of makefile
