#
#     ##################################################################
#     ##################################################################
#     ######                                                      ######
#     ######      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 ARPS executables. It can be
#           run directly or through the makeagri script.
#
#  AUTHOR:  Yuhe Liu
#           11/06/95
#
#  Modification history:
#
#  03/27/1997 (Yuhe Liu)
#    Modified in consistence with makearps and makefile.arps
#
#  OTHER INFORMATION:
#       See the makearps command.
#
#=======================================================================

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

# SHELL = /bin/csh

FTN = f90
LDR = f90

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 =
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:
#
# AGREXE    = arpsagr
#
#-----------------------------------------------------------------------

AGREXE    = arpsagr

#-----------------------------------------------------------------------
#
# ARPS solver library
#
# ARPSSOLVER = arpssolver    ARPS solver library
#
#-----------------------------------------------------------------------

ARPSSOLVER = arpssolver

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

CRAYLIBOBJ = packcray.o
GENLIBOBJ  = packgen.o
IBMLIBOBJ  = $(GENLIBOBJ)
SUNLIBOBJ  = $(GENLIBOBJ)
IRIXLIBOBJ = $(GENLIBOBJ)
LNXLIBOBJ  = $(GENLIBOBJ)
TRU64LIBOBJ = $(GENLIBOBJ)

MACHLIBOBJS = $(CRAYLIBOBJ) $(GENLIBOBJ) $(IBMLIBOBJ) $(SUNLIBOBJ) \
              $(IRIXLIBOBJ)

MACHLIBOBJ = $(GENLIBOBJ)

#-----------------------------------------------------------------------
#
# List of ARPS AGR source files:
#
#-----------------------------------------------------------------------

AGRMAINOBJ = arpsagr.o

AGROBJS1 =  manage.o setstr.o arpstgrid.o pointf.o initcgrd.o    \
            util1.o regrid.o fill.o filgrd.o inivar.o updgrd.o   \
            updbc.o tick.o arpsinit.o arpsolve.o arpscnst.o      \
            arpsout.o usrout.o change_cnst.o updexbc.o

AGROBJS = $(AGRMAINOBJ) $(AGROBJS1) $(MACHLIBOBJ)

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

default: $(AGREXE)

#-----------------------------------------------------------------------
#
# Build ARPS AGR executable
#
#-----------------------------------------------------------------------

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

$(BINDIR)/$(AGREXE): $(AGROBJS) $(LIBDIR)/$(ARPSSOLVER).a
	$(ARPS_LD) $(LDFLAGS) -o $@ $(AGROBJS) \
                               $(LIBDIR)/$(ARPSSOLVER).a

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

clean.arpsagr:
	-$(RM) -f $(BINDIR)/$(AGREXE) $(AGROBJS) $(MACHLIBOBJS) \
                  $(LIBDIR)/$(ARPSSOLVER).a

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

arpsagr.o:      arpsagr.f90  $(INCLDIR)/agricst.inc \
                             $(INCLDIR)/agrialloc.inc   \
                             $(INCLDIR)/agricpu.inc     \
                             $(INCLDIR)/grddsc.inc  \
                             $(INCLDIR)/agrigrid.inc    \
                             $(INCLDIR)/nodal.inc   \
                             $(INCLDIR)/manage.inc  \
                             $(INCLDIR)/globcst.inc \
                             $(INCLDIR)/bndry.inc

arpscnst.o:    arpscnst.f90  $(INCLDIR)/agricst.inc     \
                             $(INCLDIR)/bndry.inc     \
                             $(INCLDIR)/cumucst.inc   \
                             $(INCLDIR)/globcst.inc   \
                             $(INCLDIR)/grid.inc   \
                             $(INCLDIR)/phycst.inc    \
                             $(INCLDIR)/sfcphycst.inc \
                             $(INCLDIR)/soilcst.inc   \
                             $(INCLDIR)/exbc.inc

arpsinit.o:    arpsinit.f90  $(INCLDIR)/agricst.inc     \
                             $(INCLDIR)/agrialloc.inc       \
                             $(INCLDIR)/agricpu.inc         \
                             $(INCLDIR)/grddsc.inc      \
                             $(INCLDIR)/agrigrid.inc        \
                             $(INCLDIR)/nodal.inc       \
                             $(INCLDIR)/bndry.inc     \
                             $(INCLDIR)/cumucst.inc   \
                             $(INCLDIR)/globcst.inc   \
                             $(INCLDIR)/grid.inc   \
                             $(INCLDIR)/phycst.inc    \
                             $(INCLDIR)/sfcphycst.inc \
                             $(INCLDIR)/soilcst.inc    \
                             $(INCLDIR)/radcst.inc

arpsolve.o:    arpsolve.f90  $(INCLDIR)/agrialloc.inc     \
                             $(INCLDIR)/agricpu.inc       \
                             $(INCLDIR)/agrigrid.inc      \
                             $(INCLDIR)/nodal.inc     \
                             $(INCLDIR)/globcst.inc \
                             $(INCLDIR)/bndry.inc \
                             $(INCLDIR)/exbc.inc \
                             $(INCLDIR)/radcst.inc

arpsout.o:     arpsout.f90   $(INCLDIR)/agrialloc.inc       \
                             $(INCLDIR)/agricpu.inc         \
                             $(INCLDIR)/agrigrid.inc        \
                             $(INCLDIR)/nodal.inc       \
                             $(INCLDIR)/bndry.inc     \
                             $(INCLDIR)/cumucst.inc   \
                             $(INCLDIR)/globcst.inc   \
                             $(INCLDIR)/phycst.inc    \
                             $(INCLDIR)/sfcphycst.inc \
                             $(INCLDIR)/agricst.inc

arpsplot.o:    arpsplot.f90  $(INCLDIR)/agrialloc.inc  \
                             $(INCLDIR)/grddsc.inc \
                             $(INCLDIR)/agrigrid.inc   \
                             $(INCLDIR)/nodal.inc 
arpstgrid.o:   arpstgrid.f90 $(INCLDIR)/grddsc.inc \
                             $(INCLDIR)/agrigrid.inc
change_cnst.o: change_cnst.f90 $(INCLDIR)/agrialloc.inc \
                             $(INCLDIR)/agrigrid.inc  \
                             $(INCLDIR)/nodal.inc
filgrd.o:      filgrd.f90    $(INCLDIR)/agricst.inc \
                             $(INCLDIR)/agrialloc.inc   \
                             $(INCLDIR)/grddsc.inc  \
                             $(INCLDIR)/nodal.inc \
                             $(INCLDIR)/agrigrid.inc
fill.o:        fill.f90      $(INCLDIR)/agricst.inc \
                             $(INCLDIR)/agrialloc.inc   \
                             $(INCLDIR)/nodal.inc
initcgrd.o:    initcgrd.f90  $(INCLDIR)/agrialloc.inc \
                             $(INCLDIR)/agrigrid.inc  \
                             $(INCLDIR)/nodal.inc
inivar.o:      inivar.f90    $(INCLDIR)/agricst.inc \
                             $(INCLDIR)/agrialloc.inc   \
                             $(INCLDIR)/grddsc.inc \
                             $(INCLDIR)/agrigrid.inc   \
                             $(INCLDIR)/nodal.inc
manage.o:      manage.f90    $(INCLDIR)/agricst.inc \
                             $(INCLDIR)/agrialloc.inc   \
                             $(INCLDIR)/manage.inc  \
                             $(INCLDIR)/nodal.inc
pointf.o:      pointf.f90    $(INCLDIR)/agrialloc.inc  \
                             $(INCLDIR)/grddsc.inc \
                             $(INCLDIR)/agrigrid.inc   \
                             $(INCLDIR)/nodal.inc
regrid.o:      regrid.f90    $(INCLDIR)/agricst.inc \
                             $(INCLDIR)/agricpu.inc     \
                             $(INCLDIR)/nodal.inc
setstr.o:      setstr.f90    $(INCLDIR)/agrialloc.inc  \
                             $(INCLDIR)/grddsc.inc \
                             $(INCLDIR)/agrigrid.inc   \
                             $(INCLDIR)/agricst.inc   \
                             $(INCLDIR)/nodal.inc
stgrid.o:      stgrid.f90    $(INCLDIR)/grddsc.inc \
                             $(INCLDIR)/agrigrid.inc
tick.o:        tick.f90      $(INCLDIR)/agrialloc.inc \
                             $(INCLDIR)/agricpu.inc   \
                             $(INCLDIR)/nodal.inc \
                             $(INCLDIR)/agricst.inc
updbc.o:       updbc.f90     $(INCLDIR)/agricst.inc \
                             $(INCLDIR)/agrialloc.inc   \
                             $(INCLDIR)/agricpu.inc     \
                             $(INCLDIR)/grddsc.inc  \
                             $(INCLDIR)/agrigrid.inc    \
                             $(INCLDIR)/nodal.inc
updexbc.o:     updexbc.f90   $(INCLDIR)/agricst.inc   \
                             $(INCLDIR)/agrialloc.inc     \
                             $(INCLDIR)/grddsc.inc    \
                             $(INCLDIR)/agrigrid.inc      \
                             $(INCLDIR)/nodal.inc     \
                             $(INCLDIR)/globcst.inc \
                             $(INCLDIR)/exbc.inc
updgrd.o:      updgrd.f90    $(INCLDIR)/agricst.inc \
                             $(INCLDIR)/agrialloc.inc   \
                             $(INCLDIR)/grddsc.inc  \
                             $(INCLDIR)/agrigrid.inc    \
                             $(INCLDIR)/nodal.inc
usrout.o:      usrout.f90    $(INCLDIR)/agrialloc.inc \
                             $(INCLDIR)/agricpu.inc   \
                             $(INCLDIR)/agrigrid.inc  \
                             $(INCLDIR)/nodal.inc
util1.o:       util1.f90     $(INCLDIR)/agricst.inc \
                             $(INCLDIR)/agrialloc.inc   \
                             $(INCLDIR)/agricpu.inc     \
                             $(INCLDIR)/grddsc.inc  \
                             $(INCLDIR)/agrigrid.inc    \
                             $(INCLDIR)/nodal.inc   \
                             $(INCLDIR)/globcst.inc \
                             $(INCLDIR)/manage.inc

packcray.o:    packcray.f90  $(INCLDIR)/agricpu.inc
packgen.o:     packgen.f90
packibm.o:     packibm.f90
packsun.o:     packsun.f90
