#
#     ##################################################################
#     ##################################################################
#     ######                                                      ######
#     ######      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 ARPSEXTSND executable
#
#  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 = $(FTN)
CC  = cc
CPP = cpp
FTNMP = $(FTN)

ARPS_LD = $(LDR)

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

TOPDIR = 
BINDIR  = $(TOPDIR)/bin
INCLDIR = $(TOPDIR)/include
LIBDIR  = $(TOPDIR)/lib
88D2ADIR = $(TOPDIR)/src/88d2arps

#-----------------------------------------------------------------------
#
# Compiler Flag of Options. The default is for AIX Fortran xlf.
#
#-----------------------------------------------------------------------

FFLAGS =
CFLAGS =
LDFLAGS =
CPPFLAGS = -C -P

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:
#
# EXTSNDEXE   = arpsextsnd       ARPSEXTSND executable
# EXTSNDMPEXE = arpsextsnd       ARPSEXTSND mpi executable
#
#-----------------------------------------------------------------------

EXTSNDEXE   = arpsextsnd
EXTSNDMPEXE = arpsextsnd_mpi

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

LIBARPS   = libarps
LIBADAS   = libadas

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

#MPOBJS    = $(MPIOBJ)

EXTSNDOBJ = arpsextsnd.o arpsextsndderive.o remaplib.o

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

default: $(EXTSNDEXE)

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

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

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

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

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

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

clean.arpsextsnd:
	-$(RM) -f $(BINDIR)/$(EXTSNDEXE) $(BINDIR)/$(EXTSNDMPEXE) \
                  $(EXTSNDOBJ) remaplib.o

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

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

remaplib.o : $(88D2ADIR)/remaplib.f90     $(INCLDIR)/remap.inc    \
                               $(INCLDIR)/remaptab.inc \
                               $(INCLDIR)/globcst.inc  \
                               $(INCLDIR)/grid.inc  \
                               $(INCLDIR)/remaptab.inc
	$(FTN) $(FFLAGS) $(FREEFLAGS) -c $(88D2ADIR)/remaplib.f90

