#
#     ##################################################################
#     ##################################################################
#     ######                                                      ######
#     ######      Advanced Regional Prediction System (ARPS)      ######
#     ######                                                      ######
#     ######                     Developed by                     ######
#     ######     Center for Analysis and Prediction of Storms     ######
#     ######                University of Oklahoma                ######
#     ######                                                      ######
#     ##################################################################
#     ##################################################################
#
#=======================================================================
#
#  PURPOSE: This makefile generates the ARPSTRN executables.
#
#  AUTHOR:  Yuhe Liu
#           7/22/1997
#
#  Modification history:
#
#
#  OTHER INFORMATION:
#       See the makearps command.
#
#=======================================================================

#-----------------------------------------------------------------------
#
# Default shell
#
#-----------------------------------------------------------------------

# SHELL=/bin/csh

#-----------------------------------------------------------------------
#
# Default names of the loader and tar, can be replaced on the command
# line for other system
#
#-----------------------------------------------------------------------

FTN = f90
LDR = f90
CC  = cc

ARPS_LD = $(LDR)

TAR = tar
AWK = awk
RM  = rm
LN  = ln

TOPDIR  = 
BINDIR  = $(TOPDIR)
INCLDIR = $(TOPDIR)/include
LIBDIR  = $(TOPDIR)/lib

#-----------------------------------------------------------------------
#
# ADAS library to be linked
#
# LIBARPS = libarps      ARPS shared library
# LIBADAS = libadas      ADAS shared library
#
#-----------------------------------------------------------------------

LIBARPS   = libarps
LIBADAS   = libadas
LIBZXPOST = libzxpost
LIBZXNCAR = libzxncar

#-----------------------------------------------------------------------
#
# Compiler Flag of Options
#
#-----------------------------------------------------------------------

FFLAGS =
CFLAGS =
LDFLAGS =

FIXFLAGS  =
FREEFLAGS =

#-----------------------------------------------------------------------
#
# Dependencies
#
#-----------------------------------------------------------------------
.SUFFIXES: $(SUFFIXES) .f90

.f.o:
	$(FTN) $(FFLAGS) $(FIXFLAGS) -c $<
.f90.o:
	$(FTN) $(FFLAGS) $(FREEFLAGS) -c $<
.c.o:
	$(CC)  $(CFLAGS) -c $<

#-----------------------------------------------------------------------
#
# Executable commands to be generated by this make file:
#
# ARPSTRNEXE = arpstrn     ARPS terrain data pre-processor. 
#
#-----------------------------------------------------------------------

ARPSTRNEXE  = arpstrn

#-----------------------------------------------------------------------
#
# List of Makefiles
#
#-----------------------------------------------------------------------

MAKEFILE = Makefile

#-----------------------------------------------------------------------
#
# List of machine-dependent object codes
#
#-----------------------------------------------------------------------

ZXPLOTOBJ_ON  = 
ZXPLOTOBJ_POST    = $(LIBDIR)/$(LIBZXPOST).a
ZXPLOTOBJ_NCAR    = $(LIBDIR)/$(LIBZXNCAR).a
ZXPLOTOBJ_OFF = nozxplot.o

ZXPLOTOBJ = $(ZXPLOTOBJ_OFF)

ARPSTRNOBJ = arpstrn.o $(ZXPLOTOBJ)

#-----------------------------------------------------------------------
#
# Set Default
#
#-----------------------------------------------------------------------

default: $(ARPSTRNEXE)

MERGETRNOBJ = mergetrn.o
MERGETRNEXE = mergetrn

#-----------------------------------------------------------------------
#
# Compile and link the executable, arpstrn
#
#-----------------------------------------------------------------------

$(ARPSTRNEXE):  $(BINDIR)/$(ARPSTRNEXE)
	ls -l $(BINDIR)/$(ARPSTRNEXE)

$(MERGETRNEXE): $(BINDIR)/$(MERGETRNEXE)
	ls -l $(BINDIR)/$(MERGETRNEXE)

$(BINDIR)/$(ARPSTRNEXE): $(ARPSTRNOBJ) $(LIBDIR)/$(LIBARPS).a
	$(ARPS_LD) $(LDFLAGS) -o $@ $(ARPSTRNOBJ) $(LIBDIR)/$(LIBARPS).a $(LIBS)

$(BINDIR)/$(MERGETRNEXE): $(MERGETRNOBJ) $(LIBDIR)/$(LIBADAS).a   \
                  $(LIBDIR)/$(LIBARPS).a $(ZXPLOTOBJ)
	$(ARPS_LD) $(LDFLAGS) -o $@ $(MERGETRNOBJ)                \
                  $(LIBDIR)/$(LIBADAS).a   $(LIBDIR)/$(LIBARPS).a \
                  $(ZXPLOTOBJ) $(LIBS)

#-----------------------------------------------------------------------
#
# Remove the object code for individual programs
#
#-----------------------------------------------------------------------

clean: clean.arpstrn

clean.arpstrn:
	-$(RM) -f $(BINDIR)/$(ARPSTRNEXE)  $(ARPSTRNOBJ)

clean.mergetrn:
	-$(RM) -f $(BINDIR)/$(MERGETRNEXE) $(MERGETRNOBJ)

#-----------------------------------------------------------------------
#
# Object code dependency list:
#
#-----------------------------------------------------------------------

arpstrn.o: arpstrn.f90 $(INCLDIR)/grid.inc \
                       $(INCLDIR)/globcst.inc 

nozxplot.o: nozxplot.f90

mergetrn.o   : mergetrn.f90   $(INCLDIR)/grid.inc \
                              $(INCLDIR)/globcst.inc
