# Makefile for MPI-Spin model of Example 2.10 from
# "MPI: The Complete Reference, vol. 1", 2nd ed.

# Author: Pujan Kafle <kafle@cis.udel.edu>
# Created: 19-jul-2007
# Last modified: 19-jul-2007

PREP        = rm -f pan* *trail mpi-spin-init.c
MS_NO_DL    = $(PREP); ms -notest -nocancel -noprobe 
MS          = $(PREP); ms -notest -nocancel -noprobe -dl 

PARAMS0 = -np=2 -block -chansize=0 
PARAMS1 = -np=2 -block -chansize=2 
PARAMS2 = -np=4 -buf=2 -req=4

all: msg_exchg_buf_0 msg_exchg_buf_1 msg_exchg_buf_2 msg_exchg_buf_3 \
     mpi_msg_exchg_buf

# This model relies on buffering for message exchanges.
# The exchange may be possible when the -dl option is disabled.
# The following two targets exemplify this buffer dependent exchange

msg_exchg_buf_0: msg_exchg_buf.prom
	$(MS_NO_DL) $(PARAMS0) msg_exchg_buf.prom
	mscc
	./pan -n
	./pan -n -r

msg_exchg_buf_1: msg_exchg_buf.prom
	$(MS_NO_DL) $(PARAMS1) msg_exchg_buf.prom
	mscc
	./pan -n

msg_exchg_buf_2: msg_exchg_buf.prom
	$(MS) $(PARAMS1) msg_exchg_buf.prom
	mscc
	./pan -n
	./pan -n -r

msg_exchg_buf_3: msg_exchg_buf.prom
	$(MS) $(PARAMS2) msg_exchg_buf.prom
	mscc
	./pan -n
	./pan -n -r

mpi_msg_exchg_buf: msg_exchg_buf.c
	mpicc -o msg_exchg_buf msg_exchg_buf.c
	mpiexec -n 2 ./msg_exchg_buf

clean:
	-rm -f msg_exchg_buf pan* *.trail *.out mpi-spin-init.c *.err *~