################################################################
# Makefile for ParPre demos.
#
# make sure you suppply the following:
MACH_FILE = mf
#
# the problem size and type are hard-coded in the mat.c file
#
################################################################
CFLAGS        =  $(PARPRE_INCLUDE) $(PETSC_INCLUDE) $(CONF) $(COPT)


# 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
	@echo "Make sure you have an mpi machine file called" $(MACH_FILE)
	@echo

NP = 2
domdec_OPTIONS  =       -interface_pc_type jacobi -sub_pc_type ilu
gbssor_OPTIONS  =       -sub_pc_type sor -sub_pc_sor_symmetric \
	                -sub_pc_sor_its 3
mlevel_OPTIONS =	-presmoother_pc_type genblockssor \
	                -postsmoother_pc_type genblockssor
aschwarz_OPTIONS =      -pc_halo_size 1 -sub_pc_type ilu
mschwarz_OPTIONS =      -pc_halo_size 1 -sub_pc_type ilu

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

none_debug gbssor_debug aschwarz_debug mschwarz_debug domdec_debug mlevel_debug: test_main.o mat.o cg.o $${@:_debug=}.o
	@make METH=${@:_debug=} OPTIONS="$(OPTIONS)" NP=$(NP) \
		$@_OPTIONS='$(${@:_debug=}_OPTIONS)' \
		DEBUG="-malloc_debug -start_in_debugger gbd" 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) -machinefile mf `pwd`/test \
	                $(OPTIONS) $($(METH)_OPTIONS) -optionsleft $(DEBUG)

clean_examples:
	rm -f *~ *.o prec.* test

include $(PARPRE_DIR)/bmake/$(PARPRE_ARCH)/base
