#
#     ##################################################################
#     ##################################################################
#     ######                                                      ######
#     ######      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 ARPSCVT executables.
#
#  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 = 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:
#
# CVTEXE = arpscvt      ARPS data converter.
# H2GEXE = hdf2grads
#
#-----------------------------------------------------------------------

CVTEXE = arpscvt
H2GEXE = hdf2grads

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

LIBARPS = libarps

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

MAKEFILE = Makefile

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

CVTMAINOBJ = arpscvt.o
CVTOBJ1    = cvtiolib3d.o

CVTOBJ = $(CVTMAINOBJ) $(CVTOBJ1)

H2GOBJ = hdf2grads.o

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

default: $(CVTEXE)

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

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

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

$(H2GEXE): $(BINDIR)/$(H2GEXE)
	ls -l $(BINDIR)/$(H2GEXE)
$(BINDIR)/$(H2GEXE): $(H2GOBJ)
	$(ARPS_LD) $(LDFLAGS) -o $@ $(H2GOBJ) $(LIBS)

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

clean: clean.arpscvt clean.hdf2grads

clean.arpscvt:
	-$(RM) -f $(BINDIR)/$(CVTEXE) $(CVTOBJ)

clean.hdf2grads:
	-$(RM) -f $(BINDIR)/$(H2GEXE) $(H2GOBJ)

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

arpscvt.o    : arpscvt.f90   $(INCLDIR)/grid.inc    \
                             $(INCLDIR)/globcst.inc \
                             $(INCLDIR)/indtflg.inc  \
                             $(INCLDIR)/exbc.inc 
cvtiolib3d.o : cvtiolib3d.f90

hdf2grads.o  : hdf2grads.f90
