#
#     ##################################################################
#     ##################################################################
#     ######                                                      ######
#     ######      Advanced Regional Prediction System (ARPS)      ######
#     ######                   Version 5.0                        ######
#     ######                                                      ######
#     ######                     Developed by                     ######
#     ######     Center for Analysis and Prediction of Storms     ######
#     ######                University of Oklahoma                ######
#     ######                                                      ######
#     ##################################################################
#     ##################################################################
#
#=======================================================================
#
#  PURPOSE: This makefile generates the ARPSTINTRP executables.
#
#  AUTHOR:  M. Xue
#           Created based on src/arpsintrp/Makefile.
#
#  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

#-----------------------------------------------------------------------
#
# 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:
#
# TINTRPEXE    = arpstintrp      ARPS data converter.
#
#-----------------------------------------------------------------------

TINTRPEXE    = arpstintrp
TINTRPMPEXE  = arpstintrp_mpi

#-----------------------------------------------------------------------
#
# ARPS shared library
#
#-----------------------------------------------------------------------

LIBARPS = libarps

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

MAKEFILE = Makefile

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

TINTRPOBJ    = arpstintrp.o

TINTRPOBJS    = $(TINTRPOBJ)

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

default: $(TINTRPEXE)

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

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

$(BINDIR)/$(TINTRPEXE): $(TINTRPOBJS) $(LIBDIR)/$(LIBARPS).a
	$(ARPS_LD) $(LDFLAGS) -o $@ $(TINTRPOBJS) \
                               $(LIBDIR)/$(LIBARPS).a $(LIBS)

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

$(BINDIR)/$(TINTRPMPEXE): $(TINTRPOBJS) $(LIBDIR)/$(LIBARPS).a
	$(ARPS_LD) $(LDFLAGS) -o $@ $(TINTRPOBJS) \
                               $(LIBDIR)/$(LIBARPS).a $(LIBS)

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

clean: clean.arpstintrp

clean.arpstintrp:
	-$(RM) -f $(BINDIR)/$(TINTRPEXE) $(BINDIR)/$(TINTRPMPEXE) $(TINTRPOBJS)

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

arpstintrp.o   : arpstintrp.f90      $(INCLDIR)/globcst.inc   \
                                     $(INCLDIR)/grid.inc   \
                                     $(INCLDIR)/bndry.inc   \
                                     $(INCLDIR)/phycst.inc   \
                                     $(INCLDIR)/indtflg.inc \
                                     $(INCLDIR)/exbc.inc

