# TITLE:	Makefile for building MPI wrapper library to called
#		from Fortran programs that useh 4- or 8-byte INTEGER
#		and/or REAL data.
# AUTHOR:	Parallel Communication Team at SGI
# USAGE:	A few basic examples...
#		To build/run sample test program (the default):
#			% make hello
#		To build wrapper library (single .o file):
#			% make wrapper.o
#		To clean (removing executable and .o files):
#			% make clean
# UPDATED:	Updated with the MPT 1.6 release, May, 2002.

# Set DEBUG macro to display debugging messages from wrapper library:
# DEBUG=	-DDEBUG
DEBUG=		

# The wrapper library is a single object file:
WRAPPER=	wrapper.o

# Define sizes for integer & real data...
# ---------------------------------------
# 8-byte INTEGER, 8-byte REAL data:
SIZES=		SIZES_I8_R8
sizes_opt=	-i8 -r8 -d16

# 4-byte INTEGER, 8-byte REAL data:
# SIZES=		SIZES_I4_R8
# sizes_opt=	-i4 -r8 -d16
#
# 4-byte INTEGER, 4-byte REAL data (default):
# SIZES=		SIZES_I4_R4
# sizes_opt=	-i4 -r4 -d8

# Define the ABI...
# -----------------
# 64-bit pointers:
ABI=		ABI64
abi_opt=	-64

# 32-bit pointers:
# ABI=		ABI32
# abi_opt=	-n32

# Compiler & load options:
CC=		cc
CFLAGS=		-c $(abi_opt) -D$(ABI) -D$(SIZES)
FC=		f90
FFLAGS=		 $(abi_opt) $(sizes_opt)
LDFLAGS=	-lmpi

# mpirun command & options:
NPES=		2
MPIRUN_OPTIONS=	-np $(NPES)

# List of test program(s):
TESTS=	hello

# Default make target will build and run test(s):
default:	$(TESTS)

# Build wrapper library:
wrapper.o:	wrapper.c
	$(CC) $(DEBUG) $(CFLAGS) wrapper.c

# Build & run test program(s):
hello:	$(WRAPPER) hello.f
	$(FC) $(FFLAGS) $@.f $(WRAPPER) $(LDFLAGS) -o $@
	mpirun $(MPIRUN_OPTIONS) ./$@

# Remove wrapper.o and test program executables:
clean:
	rm -f $(TESTS) *.o
