################################################################################ # 
#     Makefile for Eta Coordinate Model 
#
#     Use:
#     make         -  build the executable
#     make clean   -  start with a clean slate
#
#     The following macros will be of interest:
#
#         TARGET   - name of the executable
#         FC       - name of Fortran compiler
#         CPP      - name of CPP
#         ARCH     - architecture
#         CPPFLAGS - CPP flags
#         OPTS     - compiler code optimizations
#         LIST     - source listing
#         SMP      - threading
#         TRAPS    - runtime traps for floating point exceptions
#         PROFILE  - source code profiling ( -pg )
#         DEBUG    - -g
#         MEM      - user data area and stack size
#         MAP      - load map
#         W3LIB    - w3lib
#         ESSL     - ESSL library
#         MASS     - MASS library
#         SEARCH   - library search location
#
#         COMMENTS: This version for Eta with I/O servers and EXCHM Module
#                   J. Tuccillo 4 April 2000
#
#################################################################################
#
# Define the name of the executable
#
TARGET = etafcst.x
#
# CPP, Compiler, and Linker Options
#
FC       = mpxlf_r
CPP      = /lib/cpp -P
ARCH     = pwr3
CPPFLAGS = 
OPTS     = -O3 -qstrict -qarch=$(ARCH) -qnosave -qmaxmem=-1 -NS2000
LIST     = -qsource -qxref=full -qattr=full
SMP      = -qsmp=noauto
TRAPS    =  -qinitauto=FF -qflttrap=ov:zero:inv:en -qsigtrap
PROFILE  =
DEBUG    = -g
MEM      = -bmaxdata:2000000000 -bmaxstack:256000000
MAP      = -bmap:map -bloadmap:lm
W3LIB    = /nwprod/w3lib90/w3lib_4_$(ARCH)
ESSL     = -lessl_r
MASS     = -lmass_r
SEARCH   =
#
# Assemble Options
#
FFLAGS   = $(OPTS) $(LIST) $(TRAPS) $(PROFILE) $(DEBUG)
FFLAGST  = $(OPTS) $(LIST) $(SMP) $(TRAPS) $(PROFILE) $(DEBUG)
LDFLAGS  = $(MEM) $(MAP) $(SMP) $(PROFILE)
LIBS     = $(W3LIB) $(ESSL) $(MASS) $(SEARCH)
#
# Non-threaded object files
#
OBJS=	EXCHM.o BOCOH.o BOCOV.o CHKOUT.o \
        CLO89.o COLLECT.o CONDLOAD.o CONRAD.o DDAMP.o \
        DIFCOF.o DIGFLT.o DIST.o DSTRB.o DTFRZ2.o E1E290.o E290.o \
        E2SPEC.o E3V88.o EBU.o ENVIRTHT.o  FILT25.o FST88.o \
        GFDLRD.o GOSSIP.o GRADFS.o HCONST.o \
        IDSTRB.o ILOC2GLB.o INIT.o KFPARA.o \
        LOC2GLB.o LUTAB.o LWR88.o \
        MIXLEN.o MPI_FIRST.o MPPINIT.o O3CLIM.o O3INT.o \
        OZON2D.o PARA_RANGE.o PDNEW.o PDTE.o \
        PGCOR.o PRECPD.o PRODQ2.o PROF5.o \
        QUILT.o RADFS.o  RDTEMP.o READ_NHB.o \
        READ_RESTRT.o READ_RESTRT2.o SETUP_SERVERS.o \
        SFCDIF.o SFLX.o SLP.o SOLARD.o SPA88.o SURFCE.o SWR93.o \
        TABLE.o TPMIX2.o TPMIX2DD.o TTBLEX.o \
        VDIFH.o VDIFQ.o VDIFV.o VTADV.o \
        VTADVF.o  ZENITH.o ZERO2.o ZERO3.o ZERO3_T.o TWR.o 
#
# Threaded object files
#
OBJST=	DIVHOA.o GSCOND.o HDIFF.o HZADV.o HZADV2.o KFDRIVE.o KFTEND.o \
        RADTN.o TURBL.o
#
# Includes
#
INCLUDES=  mpp.h parmeta EXCHM.h parmbuf
#
# Common Blocks
#
COMMS= 	ACMCLD.comm   CTLBLK.comm   MAPOT.comm    PHYS.comm     SEASO3.comm \
	ACMCLH.comm   BOCO.comm     DYNAM.comm    MAPOT1.comm   PHYS1.comm    SOIL.comm \
	ACMPRE.comm   CLDWTR.comm   DYNAMD.comm   MASKS.comm    PHYS2.comm    TABCOM.comm \
	ACMRDL.comm   CNVCLD.comm   HCON.comm     MSLP.comm     PRFHLD.comm   TEMPV.comm \
	ACMRDS.comm   CO2DTA.comm   INDX.comm     OPTIONS.comm  PVRBLS.comm   VRBLS.comm \
	ACMSFC.comm   CONTIN.comm   LOOPS.comm    OUTFIL.comm   RNDDTA.comm   Z0EFFT.comm \
	KFFDBK.comm   KFLUT.comm

DEPS= $(COMMS) $(INCLUDES)

.SUFFIXES:	.F .f .o .mod

.F.f:
	$(CPP) $(CPPFLAGS) $< > $*.f

$(TARGET):	$(OBJS) $(OBJST)
	$(FC) $(LDFLAGS) $(LIBS) -o $@ $(OBJS) $(OBJST)

$(OBJS):	$(DEPS)
	$(FC) $(FFLAGS) -c $<

$(OBJST):	$(DEPS)
	$(FC) $(FFLAGST) -c $<

clean:	
	/bin/rm -f  $(TARGET) *.f *.lst *.o *.mod
