#
#
#     ##################################################################
#     ##################################################################
#     ######                                                      ######
#     ######      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 for the
#           assimilation package.
#
#  AUTHOR:  Gene Bassett
#           1999/04/07
#
#  Modification history:
#
#  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:
#
# ASSIMEXE    = arpsassim
#
#-----------------------------------------------------------------------

ASSIMEXE    = arpsassim

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

ARPSSOLVER = arpssolver

#-----------------------------------------------------------------------
#
# List of ASSIM source files:
#
#-----------------------------------------------------------------------

ASSIMMAINOBJ = arpsassim.o

ASSIMOBJS1 = head3d.o assimcon.o assimdriv.o  assimpois.o assimradread.o \
             assimadasread.o assimrd.o assimfil.o assimvrfil.o     \
             assimblnd.o  assimvel.o assimtinpl.o assimptpr.o      \
             assimpsolver.o assimchk.o initassim.o assimfz.o        \
             assimthermo.o assimout.o init3d.o

ASSIMOBJS = $(ASSIMMAINOBJ) $(ASSIMOBJS1)

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

default: $(ASSIMEXE)

#-----------------------------------------------------------------------
#
# Build ASSIM executable
#
#-----------------------------------------------------------------------

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

$(BINDIR)/$(ASSIMEXE): $(ASSIMOBJS) $(LIBDIR)/$(ARPSSOLVER).a
	$(ARPS_LD) $(LDFLAGS) -o $@ $(ASSIMOBJS) \
                               $(LIBDIR)/$(ARPSSOLVER).a $(LIBS)

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

clean.arpsassim:
	-$(RM) -f $(BINDIR)/$(ASSIMEXE) $(ASSIMOBJS) \
                  $(LIBDIR)/$(ARPSSOLVER).a

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

arpsassim.o:     arpsassim.f90    $(INCLDIR)/bndry.inc \
                                  $(INCLDIR)/globcst.inc     \
                                  $(INCLDIR)/radcst.inc  \
                                  $(INCLDIR)/phycst.inc \
                                  $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/exbc.inc \
                                  $(INCLDIR)/soilcst.inc

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

head3d.o:        head3d.f90       $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/phycst.inc \
                                  $(INCLDIR)/indtflg.inc 

assimadasread.o: assimadasread.f90 $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/adas.inc 
initassim.o:     initassim.f90    $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/globcst.inc   
assimblnd.o:     assimblnd.f90    $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/adas.inc 
assimchk.o:      assimchk.f90     $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/grid.inc
assimdriv.o:     assimdriv.f90    $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/phycst.inc \
                                  $(INCLDIR)/bndry.inc
assimfil.o:      assimfil.f90     $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/grid.inc \
                                  $(INCLDIR)/phycst.inc \
                                  $(INCLDIR)/bndry.inc
assimfz.o:       assimfz.f90      $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/grid.inc
assimout.o:      assimout.f90     $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/grid.inc \
                                  $(INCLDIR)/phycst.inc \
                                  $(INCLDIR)/assim.inc 
assimpois.o:     assimpois.f90    $(INCLDIR)/assim.inc 
assimpsolver.o:  assimpsolver.f90 $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/grid.inc 
#fix Hub-CAPS possible bug
assimptpr.o:     assimptpr.f90    $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/grid.inc \
                                  $(INCLDIR)/phycst.inc \
                                  $(INCLDIR)/bndry.inc
assimradread.o:  assimradread.f90 $(INCLDIR)/assim.inc
assimrd.o:       assimrd.f90      $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/grid.inc \
                                  $(INCLDIR)/phycst.inc
assimthermo.o:   assimthermo.f90  $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/grid.inc \
                                  $(INCLDIR)/phycst.inc
assimtinpl.o:    assimtinpl.f90   $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/globcst.inc
assimvel.o:      assimvel.f90     $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/globcst.inc \
                                  $(INCLDIR)/phycst.inc \
                                  $(INCLDIR)/bndry.inc \
                                  $(INCLDIR)/grid.inc
assimvrfil.o:    assimvrfil.f90   $(INCLDIR)/assim.inc \
                                  $(INCLDIR)/grid.inc \
                                  $(INCLDIR)/globcst.inc
init3d.o    : $(TOPDIR)/src/arps/init3d.f90     \
                             $(INCLDIR)/bndry.inc \
                             $(INCLDIR)/exbc.inc \
                             $(INCLDIR)/globcst.inc \
                             $(INCLDIR)/phycst.inc \
                             $(INCLDIR)/indtflg.inc \
                             $(INCLDIR)/nudging.inc \
                             $(INCLDIR)/timelvls.inc
	$(FTN) $(FFLAGS) $(THMFLAG) $(FREEFLAGS) -c $<

