# Makefile for the Eceppak Package (parallel version) on the SP2
# using MPI.
#
# Note: This file is written for the gnu version of make, and it may not
#  be compatible with other versions.

# Make configuration variables
SHELL = /bin/sh
VPATH = Object_MPI:Include:../bin

# Preprocessor variables
CPP = /usr/lib/cpp

# Wilson's VRND is used for the serial version.
# The -DWVRND flag should be used in this case.
# PRNG (Parallel Random Number Generator ) algorithm should be used 
# for the parallel version. 
# When using PRNG, LIBS should include the correct library.
CPPFLAGS = -P -DAIX -DSP2 -DMP -DMPI  -DWPRNG

# Fortran compiler variables
FC = mpxlf
OPT = -O3 -g
FFLAGS = ${OPT} -qarch=pwr2 -qcheck -qsigtrap -IInclude \
	-bmaxdata:500000000 -bmaxstack:500000000

# Linker/loader variables
LDFLAGS = -o eceppak-${ECEPP_ARCH} -bmaxdata:500000000 \
	-bmaxstack:500000000 -bloadmap:loadmap
#
# LIBS should include library for PRNG on the SP2
LIBS  = -L/usr/local/lib -lctc -lesslp2 -limsl

# Suffix rule definitions
# All three of these need to be here. ".F.f" is necessary for working
# with RCS and GNU make, and ".f.o" and ".F.o" are always necessary. 
.SUFFIXES: .o .f .F

.F.f:
	 ${CPP} ${CPPFLAGS} $*.F >  $*.f
	cp $*.f f_FILES_MPI/
.f.o:
	${FC} -c ${FFLAGS} $<
	mv $*.o Object_MPI

.F.o:
	${CPP} ${CPPFLAGS} $*.F >  $*.f
	cp $*.f f_FILES_MPI/
	${FC} -c ${FFLAGS} $*.f
	mv $*.o Object_MPI
	rm $*.f

objects = accept.o \
          bd11p.o \
          calcfpo.o \
	  cluster.o \
	  conf_calc.o \
          core.o \
          dihedral_const.o \
	  distconf.o \
          distconst.o \
          eceppize.o \
          edmc.o \
          edmc_rtns.o \
	  ene_eval.o \
          generate.o \
          gradients.o \
	  init_int_table.o \
	  main_driver.o \
          map.o \
          minimiz.o \
	  MP.o \
          nrgsetup.o \
	  openunits.o \
          orient1.o \
	  param.o \
	  pepprob.o \
          place.o \
	  probres.o \
          randgens.o \
          readrtns.o \
          restart.o \
          rmdcon.o \
	  rmscalcs.o \
	  rmsconst.o \
	  rms_rtns.o \
	  set_defaults.o \
          solvation.o \
          sumsl1.o \
          thetartns.o \
          thermo.o \
          timing.o \
          utils.o \
          vtf_rtns.o \
	  write.o

# All rules go below here

eceppak-${ECEPP_ARCH}: ${objects} 
	cd Object_MPI; ${FC} ${LDFLAGS} ${objects} ${LIBS}; \
	mv $(@F) ${ECEPP_ROOT}/bin
clean:
	rm -f Object_MPI/*.o *.o
