################################################################
# Makefile for ParPre demos.
#
# make sure you suppply the following:
MACH_FILE = mf
# give the debugger time to attach
DEBUGGER_PAUSE = 40
#
# the problem size and type are hard-coded in the mat.c file
#
################################################################

# default production: helpful information
default help info all:
	@echo " "
	@echo "Type: make <method>"
	@echo "where <method> stands for any of:"
	@echo "   none, jacobi, aschwarz, mschwarz, domdec, gbssor"
	@echo "at present."
	@echo
	@echo "Also possible: make method_options=<options> <method>"
	@echo "where <options> can be found in the manual."
	@echo

NP = 2

none jacobi gbssor aschwarz mschwarz domdec mlevel tinker: \
	        test_main.o mat.o cg.o $$@.o
	make BOPT=$(BOPT) METH=$@ OPTIONS="$(OPTIONS)" NP=$(NP) \
		PETSC_OPTIONS="$(PETSC_OPTIONS)" MPI_OPTIONS="$(MPI_OPTIONS)" \
		method_options="$(method_options)" \
		run

none_debug gbssor_debug aschwarz_debug mschwarz_debug domdec_debug mlevel_debug: test_main.o mat.o cg.o $${@:_debug=}.o
	@make BOPT=$(BOPT) METH=${@:_debug=} NP=$(NP) \
		PETSC_OPTIONS="$(PETSC_OPTIONS)" MPI_OPTIONS="$(MPI_OPTIONS)" \
		$@_OPTIONS='$(${@:_debug=}_OPTIONS)' \
		DEBUG="-start_in_debugger dbx -debugger_pause $(DEBUGGER_PAUSE)" \
		run


run:
	@echo "*******************************"
	@echo "A simple test of $(NP) processor cg"
	@echo "*******************************"
	-$(CLINKER)  -o test test_main.o cg.o $(METH).o mat.o \
	        $(PARPRE_LIB)
	chmod 755 test
	@echo ; echo "Ah! " $(METH) "!" ; echo ;
	mpirun -np $(NP) $(MPI_OPTIONS) \
	  $(PARPRE_DIR)/Examples/test \
	    $(method_options) -optionsleft $(DEBUG) $(PETSC_OPTIONS)

clean_examples:
	rm -f *~ *.o prec.* test mf PI* tmp *.out

include $(PARPRE_DIR)/bmake/parpre_base
