# 
# Copyright (c) 2008 Kristopher L. Kuhlman (kuhlman at hwr dot arizona dot edu)
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# 
# Malama, B., K.L. Kuhlman, and W. Barrash, 2007. Semi-analytical solution
#  for flow in leaky unconfined aquifer-aquitard systems, Journal of
#  Hydrology, 346(1-2), 59–68.
# http://dx.doi.org/10.1016/j.jhydrol.2007.08.018
#
# Malama, B., K.L. Kuhlman, and W. Barrash, 2008. Semi-analytical solution
#  for flow in a leaky unconfined aquifer toward a partially penetrating
#  pumping well, Journal of Hydrology, 356(1-2), 234–244.
# http://dx.doi.org/10.1016/j.jhydrol.2008.03.029
#

# $Id: Makefile,v 1.3 2007/03/06 17:40:37 kris Exp kris $ 
EXTERNAL = constant.o qxgs.o 
INVLAPTF = invlap.o
KKFILES = laplace_hankel_solutions.o gauss_quad.o
OBJS = $(EXTERNAL) utility.o expint.o $(INVLAPTF)  $(KKFILES)

MAIN = driver2.o

OPTOBJS = $(patsubst %.o,%.opt.o,$(OBJS) $(MAIN))
DEBUGOBJS = $(patsubst %.o,%.debug.o,$(OBJS) $(MAIN))
MATRIXOBJS = $(patsubst %.o,%.mat.o,$(OBJS) $(MAIN))

F90SRC=$(patsubst %.o,%.f90,$(OBJS) $(MAIN))

OUT = revised_driver
DEBUGOUT = debug_revised_driver
MATOUT = extra_debug_revised_driver

LD = $(F90)

####### default optimized (no debugging) target ##########################
driver: $(OPTOBJS)
	$(LD) $(PERFLDFLAGS) -o $(OUT) $(OPTOBJS)

####### compiler debugging ### 
##(no optimization, checks for out-of-bounds arrays and gives more warninngs, but still runs to completion)
debug_driver: $(DEBUGOBJS)
	$(LD) -o $(DEBUGOUT) $(DEBUGOBJS)

####### super matrix debugging (only runs one time step, generates output files for checking) 
## this requires LAPACK and BLAS to be installed and in the
## LD_LIBRARY_PATH search path.  if not use -L/path/to/libs to point to them
matrix_driver: $(MATRIXOBJS)
	$(LD) -o $(MATOUT) $(MATRIXOBJS) -llapack -lblas

####### rule for making optimized object files ############
%.opt.o: %.f90
	$(F90) -c -cpp $(INTEL) $(PERF) -o $@ $<

####### rule for making debugging object files ############
%.debug.o: %.f90
	$(F90) -c -cpp $(INTEL) $(DEBUG) -o $@ $<

####### rule for making matrix comparisong debugging object files ############
%.mat.o: %.f90
	$(F90) -c -cpp $(INTEL) -DDEBUG -DCONSISTENCY -DMATRIXCHECK $(DEBUG) -o $@ $< 


## copied from dep.mod created using target below
constant.opt.o constants_nswc.mod: constant.f90
qxgs.opt.o adapt_quad.mod: constants_nswc.mod qxgs.f90
utility.opt.o invlap_fcns.mod complex_hyp_trig.mod shared_data.mod constants.mod: utility.f90
expint.opt.o expint_approx.mod: constants.mod expint.f90
invlap.opt.o invlap.mod: constants.mod invlap.f90
laplace_hankel_solutions.opt.o neuman72_mod.mod classical_mod.mod one_aquifer.mod two_aquifer.mod \
 hantush64_mod.mod: complex_hyp_trig.mod invlap_fcns.mod invlap.mod shared_data.mod constants.mod \
 laplace_hankel_solutions.f90
gauss_quad.opt.o gauss_points.mod: constants.mod gauss_quad.f90
driver2.opt.o: expint_approx.mod gauss_points.mod classical_mod.mod two_aquifer.mod one_aquifer.mod \
 hantush64_mod.mod neuman72_mod.mod constants.mod shared_data.mod adapt_quad.mod driver2.f90

constant.debug.o constants_nswc.mod: constant.f90
qxgs.debug.o adapt_quad.mod: constants_nswc.mod qxgs.f90
utility.debug.o invlap_fcns.mod complex_hyp_trig.mod shared_data.mod constants.mod: utility.f90
expint.debug.o expint_approx.mod: constants.mod expint.f90
invlap.debug.o invlap.mod: constants.mod invlap.f90
laplace_hankel_solutions.debug.o neuman72_mod.mod classical_mod.mod one_aquifer.mod two_aquifer.mod \
 hantush64_mod.mod: complex_hyp_trig.mod invlap_fcns.mod invlap.mod shared_data.mod constants.mod \
 laplace_hankel_solutions.f90
gauss_quad.debug.o gauss_points.mod: constants.mod gauss_quad.f90
driver2.debug.o: expint_approx.mod gauss_points.mod classical_mod.mod two_aquifer.mod one_aquifer.mod \
 hantush64_mod.mod neuman72_mod.mod constants.mod shared_data.mod adapt_quad.mod driver2.f90

constant.mat.o constants_nswc.mod: constant.f90
qxgs.mat.o adapt_quad.mod: constants_nswc.mod qxgs.f90
utility.mat.o invlap_fcns.mod complex_hyp_trig.mod shared_data.mod constants.mod: utility.f90
expint.mat.o expint_approx.mod: constants.mod expint.f90
invlap.mat.o invlap.mod: constants.mod invlap.f90
laplace_hankel_solutions.mat.o neuman72_mod.mod classical_mod.mod one_aquifer.mod two_aquifer.mod \
 hantush64_mod.mod: complex_hyp_trig.mod invlap_fcns.mod invlap.mod shared_data.mod constants.mod \
 laplace_hankel_solutions.f90
gauss_quad.mat.o gauss_points.mod: constants.mod gauss_quad.f90
driver2.mat.o: expint_approx.mod gauss_points.mod classical_mod.mod two_aquifer.mod one_aquifer.mod \
 hantush64_mod.mod neuman72_mod.mod constants.mod shared_data.mod adapt_quad.mod driver2.f90

###### clean up #################################
clean:
	rm -f *.o *.mod $(OUT) $(DEBUGOUT) $(MATOUT)

