# 
# gmake makefile for MMM95 model module 
#
# NOTE Must use gmake not make.
# The user must set the environmental variable "CPU" to be
# one of the following:
#
# FUJITSU  for the Lahey Fujitsu F90/F95 compiler
# IBM      for the standard compiler on IBM/AIX workstations
# SOL      for the standard compiler on Sun Solaris workstations
# SGI      for the standard compiler on SGI IRIX workstations
# DEC      for the standard compiler on DEC alpha workstations
# HP       for the standard compiler on Hewlett Packard workstations
#
#       For example, in the Bourne shell on an SGI workstation, type:
#
#  export CPU=SGI
#
#       If you are using the C-shell on an SGI workstation, type
#
#  setenv CPU SGI
#
# Use `gmake clean' to remove all binaries.
#
# The MMM95 transport model has been used ONLY in DOUBLE PRECISION
# with the precision set by flags in the makefile
#
# Glenn Bateman and Arnold Kritz, Lehigh University
#
#
# environment variable CPU is used to set platform-dependent make variables.
#
ifeq ($(CPU),)
   # CPU is undefined; default to SGI.
   WARNcpu = 2
   CPU = SGI
endif
ifeq ($(filter $(CPU), FUJITSU, IBM SOL SGI DEC HP),)
   ERRcpu = 2
endif

#
#
# Compilation/linking flags
#
# Compilation/linking flags for LINUX
#
ifeq ($(CPU),FUJITSU)
   FC=lf95
   FFLAGS=--dbl -g --tpp --chk a,e,s,u
   COMPILE = $(FC) $(FFLAGS) -c
   LINK    = $(FC)
endif
#
# For IBM/AIX compilers, the compilation flags are (in order):
#   - Optimization (level 1 out of 3)
#   - Default real-variable size is 8 bytes
#   - Default integer-variable size is 4 bytes
#   - No limit on the executable's memory usage
#     (works with the -O flag to give greater optimization)
#   - Input files are written in fixed-format fortran, lines 72 chars long
#   - Compile only (linking is done in a seperate step)
#
ifeq ($(CPU),IBM)
   FFLAGS  = -O -qrealsize=8 -qintsize=4 -qmaxmem=-1
   FFLAGS2 = -qfixed=72 -c
   COMPILE = $(FC) $(FFLAGS) $(FFLAGS2)
   LINK    = $(FC) $(FFLAGS)
endif
#
# For Solaris compilers, these compilation flags are (in order):
#
ifeq ($(CPU),SOL)
   FFLAGS  = -O4 -Nx600 -Nn2000 -r8 -i4
   FFLAGS2 = -c
   COMPILE = $(FC) $(FFLAGS) $(FFLAGS2)
   LINK    = $(FC) $(FFLAGS)
endif
# For SGI compilers, these compilation flags are (in order):
#
ifeq ($(CPU),SGI)
   FFLAGS  = -default64
   FFLAGS2 = -c
   FC=f90
   COMPILE = $(FC) $(FFLAGS) $(FFLAGS2)
   LINK    = $(FC) $(FFLAGS)
endif
#
# For DEC-alpha workstations (dmc)
#
ifeq ($(CPU),DEC)
   FFLAGS  = -O -r8 -i4
   FFLAGS2 = -c
   COMPILE = $(FC) $(FFLAGS) $(FFLAGS2)
   LINK    = $(FC) $(FFLAGS)
endif
#
# For HP workstations (dmc)
#
ifeq ($(CPU),HP)
   FFLAGS = -O3 +autodblpad
   FFLAGS2 = -c
   FC=fort77
   COMPILE = $(FC) $(FFLAGS) $(FFLAGS2)
   LINK    = $(FC) $(FFLAGS)
endif

#
# Targets and Rules
#

xbdped: driver.o bdped.o bdlh.o bdlhmode1.o bdhden.o bddensity1.o bdhtemp.o bdheight1.o bdshear1.o bdheight2.o bdshear2.o bdheight3.o bdshear3.o bdcoll.o bdboots.o bdheight11.o bdheight12.o stripx.o
	$(LINK) -o xbdped driver.o bdped.o bdlh.o bdlhmode1.o bdhden.o bddensity1.o bdhtemp.o bdheight1.o bdshear1.o bdheight2.o bdshear2.o bdheight3.o bdshear3.o bdcoll.o bdboots.o bdheight11.o bdheight12.o stripx.o 

stripx.o:	stripx.f
	$(COMPILE) -o stripx.o stripx.f

bdheight12.o:	bdheight12.f
	$(COMPILE) -o bdheight12.o bdheight12.f

bdheight11.o:	bdheight11.f
	$(COMPILE) -o bdheight11.o bdheight11.f

bdboots.o:	bdboots.f
	$(COMPILE) -o bdboots.o bdboots.f

bdcoll.o:	bdcoll.f
	$(COMPILE) -o bdcoll.o bdcoll.f

bdshear3.o:	bdshear3.f
	$(COMPILE) -o bdshear3.o bdshear3.f

bdheight3.o:	bdheight3.f
	$(COMPILE) -o bdheight3.o bdheight3.f

bdshear2.o:	bdshear2.f
	$(COMPILE) -o bdshear2.o bdshear2.f

bdheight2.o:	bdheight2.f
	$(COMPILE) -o bdheight2.o bdheight2.f

bdshear1.o:	bdshear1.f
	$(COMPILE) -o bdshear1.o bdshear1.f

bdheight1.o:	bdheight1.f
	$(COMPILE) -o bdheight1.o bdheight1.f

bdhtemp.o:	bdhtemp.f
	$(COMPILE) -o bdhtemp.o bdhtemp.f

bddensity1.o:	bddensity1.f
	$(COMPILE) -o bddensity1.o bddensity1.f

bdhden.o:	bdhden.f
	$(COMPILE) -o bdhden.o bdhden.f

bdlhmode1.o:	bdlhmode1.f
	$(COMPILE) -o bdlhmode1.o bdlhmode1.f

bdlh.o:		bdlh.f
	$(COMPILE) -o bdlh.o bdlh.f

bdped.o  :	bdped.f
	$(COMPILE) -o bdped.o bdped.f

driver.o:	driver.f
	$(COMPILE) -o driver.o driver.f

cputst:
  ifeq ($(ERRcpu),2)
	@echo CPU=$(CPU) is not yet implemented in edge makefile.
	@exit 2
  endif
  ifeq ($(WARNcpu),2)
	@echo CPU defaulted, CPU=IBM assumed.
  endif

clean:
	@rm *.o xbdped

