SHELL=/bin/sh

# MPICC      - C compiler 
# CFLAGS     - C compilation arguments
# CMPI_INC   - any -I arguments required for compiling MPI/C 
# CLINK      - C linker
# CLINKFLAGS - C linker flags
# CC         - C compiler
# CMPI_LIB   - any -L and -l arguments required for linking MPI/C 
#
# compilations are done with $(MPICC) $(CMPI_LIB)
# linking is done with       $(CLINK) $(CMPI_LIB) $(CLINKFLAGS)
#---------------------------------------------------------------------------

CC = /usr/bin/gcc

#---------------------------------------------------------------------------
# This is the C compiler used for MPI programs
#------------------------------------------------------------------------

#MPICC = /usr/bin/mpicc
#MPICC = /opt/mpich/gnu/bin/mpicc
MPICC = /usr/local/mpich-1.2.7/bin/mpicc

# This links MPI C programs; usually the same as ${MPICC}

#CLINK	= /usr/bin/mpicc
#CLINK	= /opt/mpich/gnu/bin/mpicc
CLINK = /usr/local/mpich-1.2.7/bin/mpicc

#---------------------------------------------------------------------------
# These macros are passed to the linker to help link with MPI correctly
#---------------------------------------------------------------------------
#CMPI_LIB  = -L/usr/local/lib
CMPI_LIB = -L/usr/local/mpich-1.2.7/lib

#---------------------------------------------------------------------------
# These macros are passed to the compiler to help find 'mpi.h'
#---------------------------------------------------------------------------
#CMPI_INC = -I/usr/local/include
#CMPI_INC = -I/usr/mpi/include
CMPI_INC = -I/usr/local/mpich-1.2.7/include

#---------------------------------------------------------------------------
# Global *compile time* flags for C programs
#---------------------------------------------------------------------------
CFLAGS	= -O3

#---------------------------------------------------------------------------
# Global *link time* flags. Flags for increasing maximum executable 
# size usually go here. 
#---------------------------------------------------------------------------
CLINKFLAGS = -O

FF = /usr/bin/f77

FFLAGS = -O3

OBJS = derivs.o rkcs.o four2dbl.o fileoperation.o getnewjob.o myodestep.o gasdev.o stream.o odestep.o emflds1.o emflds2.o emflds3.o emflds8.o mhdflds.o lint.o kloc3.o loadcommon.o

streamline : ${OBJS}
	${CLINK} ${CLINKFLAGS} -o streamline ${OBJS} ${CMPI_LIB} ${CMPI_INC} -lm -lg2c

stream.o:	stream.c
	${MPICC} -c stream.c  ${CMPI_LIB}

loadcommon.o:	loadcommon.for
	${FF} ${FFLAGS} -c loadcommon.for

odestep.o:	odestep.for
	${FF} ${FFLAGS} -c odestep.for

derivs.o:	derivs.for
	${FF} ${FFLAGS} -c derivs.for

rkcs.o:		rkcs.for 
	${FF} ${FFLAGS} -c rkcs.for

emflds1.o:	emflds1.for maxdef.h
	${FF} ${FFLAGS} -c emflds1.for

emflds2.o:	emflds2.for maxdef.h
	${FF} ${FFLAGS} -c emflds2.for

emflds3.o:	emflds3.for maxdef.h
	${FF} ${FFLAGS} -c emflds3.for

#emflds4.o:	emflds4.for maxdef.h
#	${FF} ${FFLAGS} -c emflds4.for

#emflds5.o:	emflds5.for maxdef.h
#	${FF} ${FFLAGS} -c emflds5.for

#emflds6.o:	emflds6.for maxdef.h
#	${FF} ${FFLAGS} -c emflds6.for

emflds8.o:	emflds8.for maxdef.h
	${FF} ${FFLAGS} -c emflds8.for

kloc3.o:	kloc3.for
	${FF} ${FFLAGS} -c kloc3.for

mhdflds.o:	mhdflds.for
	${FF} ${FFLAGS} -c mhdflds.for

lint.o:	lint.for
	${FF} ${FFLAGS} -c lint.for

gasdev.o:	gasdev.for
	${FF} ${FFLAGS} -c gasdev.for

four2dbl.o:	four2dbl.for
	${FF} ${FFLAGS} -c four2dbl.for

getnewjob.o:	getnewjob.c
	${CC} ${CFLAGS} -c getnewjob.c

myodestep.o:	myodestep.c
	${CC} ${CFLAGS} -c myodestep.c

fileoperation.o:	fileoperation.c
	${MPICC} ${CFLAGS} -c fileoperation.c

clean:
	rm -f *.o *~ core PI* streamline

xclean:
	rm -f *.o *~ core PI* streamline b* out*

oclean:
	rm -f *.o *~ core PI* b* out*
