#
#     ##################################################################
#     ##################################################################
#     ######                                                      ######
#     ######      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 ARPSDIFF executable
#
#  AUTHOR:  Yuhe Liu
#           7/22/1997
#
#  Modification history:
#
#  1 June 2002 Eric Kemp
#  Bug fix for linking arpsraindiff
#
#
#  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. The default is for AIX Fortran xlf.
#
#-----------------------------------------------------------------------

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 to be generated by this make file:
#
# DIFFEXE = arpsdiff            ARPSDIFF executable
# RAINDIFFEXE = arpsraindiff    ARPSRAINDIFF executable
#
#-----------------------------------------------------------------------

DIFFEXE     = arpsdiff
RAINDIFFEXE = arpsraindiff

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

LIBARPS = libarps
LIBADAS = libadas

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

DIFFOBJ = arpsdiff.o
RAINDIFFOBJ = arpsraindiff.o

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

default: $(DIFFEXE)

#-----------------------------------------------------------------------
#
# Compile and link ARPS model executable, arps
#
#-----------------------------------------------------------------------

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

$(BINDIR)/$(DIFFEXE): $(DIFFOBJ) $(LIBDIR)/$(LIBARPS).a \
                                 $(LIBDIR)/$(LIBADAS).a
	$(ARPS_LD) $(LDFLAGS) -o $@ $(DIFFOBJ)             \
                               $(LIBDIR)/$(LIBARPS).a \
                               $(LIBDIR)/$(LIBADAS).a $(LIBS)

#$(RAINDIFFEXE): $(RAINDIFFOBJ) $(LIBDIR)/$(LIBARPS).a
#	$(ARPS_LD) $(LDFLAGS) -o $(BINDIR)/$@ $(RAINDIFFOBJ) \
#                                         $(LIBDIR)/$(LIBARPS).a


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

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

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

clean.arpsdiff:
	-$(RM) -f $(BINDIR)/$(DIFFEXE) $(DIFFOBJ)

clean.arpsraindiff:
	-$(RM) -f $(BINDIR)/$(RAINDIFFEXE) $(RAINDIFFOBJ)

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

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

arpsraindiff.o : arpsraindiff.f90 $(INCLDIR)/globcst.inc
