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

# The model deadlocks because of the order of the communication
# functions in the processes.

# 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          = $(PREP); ms -notest -nocancel -noprobe -dl


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

all: msg_exchg_dl_0 msg_exchg_dl_1 msg_exchg_dl_2 mpi_msg_exchg_dl 

msg_exchg_dl_0: msg_exchg_dl.prom
	$(MS) $(PARAMS0) msg_exchg_dl.prom
	mscc
	./pan -n
	./pan -n -r

msg_exchg_dl_1: msg_exchg_dl.prom
	$(MS) $(PARAMS1) msg_exchg_dl.prom
	mscc
	./pan -n
	./pan -n -r

msg_exchg_dl_2: msg_exchg_dl.prom
	$(MS) $(PARAMS2) msg_exchg_dl.prom
	mscc
	./pan -n
	./pan -n -r

mpi_msg_exchg_dl: msg_exchg_dl.c
	mpicc -o msg_exchg_dl msg_exchg_dl.c
	mpiexec -n 2 ./msg_exchg_dl

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