# This is the makefile for testing the mesa num library

MESA_DIR = ../../..

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

# STEP 1: get the standard compiler info

include $(MESA_DIR)/utils/makefile_header

ifeq ($(NUM_OFFLOAD),YES)
CC += -Doffload
FC += -Doffload
endif

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

# STEP 2: info about the dependencies

LOAD_LOCAL = -L$(LOCAL_LIB_DIR) -lnum
LOAD_OTHER = -L$(MESA_LIB_DIR) $(LOAD_MATRIX)

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

# STEP 3: build the test

TEST_SUPPORT_OBJS = \
   test_support.o test_int_support.o \
   bari_beam.o test_beam.o \
   bari_chemakzo.o test_chemakzo.o \
   bari_medakzo.o test_medakzo.o \
   bari_vdpol.o test_vdpol.o \
   test_mebdfi_pollu.o test_mebdfi_medakzo.o \
   test_diffusion.o test_brent.o test_bobyqa.o test_newuoa.o \
   test_simplex.o test_newton.o
TEST_OBJS = $(TEST_SUPPORT_OBJS) test_num.o

TEST_MPI_OBJS = $(TEST_SUPPORT_OBJS) test_num_mpi.o

TEST = tester
#TEST_MPI = test_mpi

SAMPLE = sample
SAMPLE_OBJS = sample_ode_solver.o


all : $(TEST) $(SAMPLE) $(MIXING_TEST)

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

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

$(SAMPLE) : $(SAMPLE_OBJS)
	$(LOADER) $(FCopenmp) -o $(TEST_DIR)/$(SAMPLE) $(SAMPLE_OBJS) $(LOAD_LOCAL) $(LOAD_OTHER)
	
#################################################################

COMPILE_NC = $(FC) $(FCbasic) $(FCopenmp) $(FCstatic) $(FCopt) $(FCfixed) $(TEST_INCLUDES) -c

test_brent.o: $(TEST_SRC_DIR)/test_brent.f
	$(TEST_COMPILE) $(FCfree) $<

test_simplex.o: $(TEST_SRC_DIR)/test_simplex.f
	$(TEST_COMPILE) $(FCfree) $<

test_bobyqa.o: $(TEST_SRC_DIR)/test_bobyqa.f
	$(TEST_COMPILE) $(FCfixed) $<

test_newuoa.o: $(TEST_SRC_DIR)/test_newuoa.f
	$(TEST_COMPILE) $(FCfixed) $<

test_mebdfi_pollu.o: $(TEST_SRC_DIR)/test_mebdfi_pollu.f
	$(TEST_COMPILE) $(FCfixed) $<

test_mebdfi_medakzo.o: $(TEST_SRC_DIR)/test_mebdfi_medakzo.f
	$(TEST_COMPILE) $(FCfixed) $<

bari_vdpol.o: $(TEST_SRC_DIR)/bari_vdpol.f
	$(COMPILE_NC) $<
   
bari_vdpol3.o: $(TEST_SRC_DIR)/bari_vdpol3.f
	$(COMPILE_NC) $<
   
bari_vdpol_x.o: $(TEST_SRC_DIR)/bari_vdpol_x.f
	$(COMPILE_NC) $<
   
bari_vdpol3_x.o: $(TEST_SRC_DIR)/bari_vdpol3_x.f
	$(COMPILE_NC) $<
   
bari_medakzo.o: $(TEST_SRC_DIR)/bari_medakzo.f
	$(COMPILE_NC) $<

bari_hires.o: $(TEST_SRC_DIR)/bari_hires.f
	$(COMPILE_NC) $<

bari_pollu.o: $(TEST_SRC_DIR)/bari_pollu.f
	$(COMPILE_NC) $<

bari_rober.o: $(TEST_SRC_DIR)/bari_rober.f
	$(COMPILE_NC) $<

bari_beam.o: $(TEST_SRC_DIR)/bari_beam.f
	$(COMPILE_NC) $<

bari_chemakzo.o: $(TEST_SRC_DIR)/bari_chemakzo.f
	$(COMPILE_NC) $<

%.o: $(TEST_SRC_DIR)/%.f
	$(TEST_COMPILE) $(FCfree) $<

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










