# This is the makefile for testing mesa mtx package 

MESA_DIR = ../../..

#################################################################

# STEP 1: set up the standard info

include $(MESA_DIR)/utils/makefile_header

#################################################################

# STEP 2: info about the libraries

LOAD_LOCAL = -L$(LOCAL_LIB_DIR) $(LOAD_MATRIX)
LOAD_OTHER = -L$(MESA_LIB_DIR) -lutils -lalert

#################################################################

# STEP 3: build the test program

ifeq ($(USE_MKL_PARDISO),YES)
TEST_PARDISO_OBJ = test_pardiso.o
else
TEST_PARDISO_OBJ = test_pardiso_stub.o
endif

TEST_SUPPORT_OBJS = \
   $(TEST_PARDISO_OBJ) \
   test_klu.o test_mtx_support.o test_banded.o \
   test_block_tri_dble.o test_block_tri_quad.o \
   test_square.o test_square_quad.o test_sparse.o \
   test_trisolve.o
   
TEST_OBJS = $(TEST_SUPPORT_OBJS) test_mtx.o 
TEST_MPI_OBJS = $(TEST_SUPPORT_OBJS) test_mtx_mpi.o

TEST = tester
TEST_MPI = test_mpi

all : $(TEST) $(TEST_MPI)

$(TEST) : $(TEST_OBJS)
	$(LOADER) $(FCopenmp) -o $(TEST_DIR)/$(TEST) $(TEST_OBJS) \
	$(LOAD_LOCAL) $(LOAD_OTHER)

$(TEST_MPI) : $(TEST_MPI_OBJS)
	$(LOADER) $(FCopenmp) -o $(TEST_DIR)/$(TEST_MPI) $(TEST_MPI_OBJS) \
	$(LOAD_LOCAL) $(LOAD_OTHER)


#################################################################

%.o: $(TEST_SRC_DIR)/%.f
	$(TEST_COMPILE) $(FCfree) $<
	
test_block_tri_dble.o: $(TEST_SRC_DIR)/test_block_tridiagonal.f
	$(TEST_COMPILE) $(FCfree) $(FC_free_preprocess) -DDBLE -o test_block_tri_dble.o $<
test_block_tri_quad.o: $(TEST_SRC_DIR)/test_block_tridiagonal.f
	$(TEST_COMPILE) $(FCfree) $(FC_free_preprocess) -o test_block_tri_quad.o $<

clean:
	-@rm -f *.o *.mod $(TEST_LIB) $(TEST_DIR)/$(TEST)
