# 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 -DMP -DMPI -DWPRNG -DPHCALC

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

# Linker/loader variables
LDFLAGS = -o eceppakpH-${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 \
	  charged_conf.o \
	  cluster.o \
	  conf_calc.o \
	  connect_ha.o \
	  connect_la97.o \
	  connect_lh.o \
          core.o \
	  degionzpH.o \
          dihedral_const.o \
	  distconf.o \
          distconst.o \
          eceppize.o \
          edmc.o \
          edmc_rtns.o \
	  en_ggg000.o \
	  en_ggg001.o \
	  ene_eval.o \
          generate.o \
          gradients.o \
	  grant2.o \
	  init_int_table.o \
	  inptest.o \
	  linbcg.o \
	  main_driver.o \
          map.o \
          minimiz.o \
	  MP.o \
	  mseed_new.o \
          nrgsetup.o \
	  openunits.o \
	  optim_ionstate.o \
          orient1.o \
	  param.o \
	  pepprob.o \
          place.o \
	  potential_eql_DR.o \
	  potential_xyz.o \
	  precal01.o \
	  probres.o \
	  protonation.o \
          randgens.o \
	  readinfo.o \
          readrtns.o \
          restart.o \
          rmdcon.o \
	  rms_rtns.o \
	  rmscalcs.o \
	  rmsconst.o \
	  set_defaults.o \
	  sigma0_loc.o \
	  sigma_ibem.o \
	  sigma_loc.o \
	  sims_01_pbl.o \
	  sims_02_pbl.o \
	  solv_frengSIMS.o \
	  solv_ibems_DR.o \
	  solv_transSIMS.o \
          solvation.o \
	  sp_KKK.o \
	  ssint_en.o \
	  ssolv_en.o \
          sumsl1.o \
	  surf_loc01.o \
	  surf_loc02.o \
          thermo.o \
	  thetartns.o \
          timing.o \
	  timit.o \
          utils.o \
          vtf_rtns.o \
	  write.o

# All rules go below here

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