SHELL           	=       /bin/sh

# Listing of options that are usually independent of machine type.
# When necessary, these are over-ridden by each architecture.

ARFLAGS			=	-X64

#### Architecture specific settings ####

# Settings for Linux x86_64, Intel compiler w/MKL, SGI MPT	 (dmpar)#
LDFLAGS        =  -Wl,-noinhibit-exec 

WRF_GRIB2 =  
WRF_PNETCDF = -L$(WRF_DIR)/external/io_grib2 -lio_grib2 -L/usr/lib64 -ljasper -lz -lpng
NETCDF_INCLUDE  = -I$(NETCDF)/include
NETCDF_LDFLAGS  = -L$(NETCDF)/lib -lnetcdf

BYTE_ORDER     =  LITTLE_ENDIAN
SFC            =  ftn   
SF90           =  ftn -free
SCC            =  cc
OMP_FFLAGS     = -openmp
DEBUG_FLAGS    =  -g -fpe0 -traceback 
FFLAGS         =  -O3 -convert big_endian -DLINUX -fp-model precise \
                  -assume byterecl # $(DEBUG_FLAGS)
FFLAGS_SHIPS   =  -O3 -fp-model precise
FFLAGS_BUFR    =  -O3 -DLINUX -fp-model precise -assume byterecl
CFLAGS_BUFR    =  -O3 -DUNDERSCORE
FFLAGS_DOUBLE  =  -integer-size 32 -real-size 64
FFLAGS_SINGLE  =  -integer-size 32 -real-size 32
FFLAGS_TRACKER =  -O3 -convert big_endian -DLINUX -fp-model precise \
                  -assume byterecl $(FFLAGS_DOUBLE) # $(DEBUG_FLAGS)
CPP            =  /lib/cpp
CPPFLAGS       =  -P -D$(BYTE_ORDER) -DWRF -DLINUX -I$(WRF_DIR)/inc 
FPPFLAGS       =  $(CPPFLAGS) -traditional-cpp
ARFLAGS        =  -ruv

DM_FC          =  ftn 
DM_F90         =  ftn -free
DM_CC          =  cc
DM_LDFLAGS     =  $(LD_FLAGS) -L$(MPI_ROOT)/lib -lmpi
DM_FFLAGS      =  $(FFLAGS) -I$(MPI_ROOT)/include
DM_CFLAGS      =  $(CFLAGS) -I$(MPI_ROOT)/include

FC             =  $(DM_FC)
F90            =  $(DM_F90)
CC             =  $(DM_CC)

CFLAGS         =  -O0 -DLINUX -DUNDERSCORE -Dfunder -DFortranByte=char \
                  -DFortranInt=int -DFortranLlong='long long'
DEBUG_CFLAGS   =

ESSLLIB        =  -mkl=sequential 
MASSLIB        = 
WRF_DIR        =  ../../hmon_hwrf_v3.9.1.fd
SED_FTN        =  $(WRF_DIR)/tools/standard.exe
LIB_EXTERNAL   =  -L$(WRF_DIR)/external/io_grib1 -lio_grib1 \
                  -L$(WRF_DIR)/external/io_grib_share -lio_grib_share \
                  -L$(WRF_DIR)/external/atm_ocn -latm_ocn \
                  -L$(WRF_DIR)/external/io_int -lwrfio_int \
                  -L$(WRF_DIR)/external/esmf_time_f90 -lesmf_time \
                  -L$(WRF_DIR)/external/RSL_LITE -lrsl_lite \
                  -L$(WRF_DIR)/external/io_netcdf -lwrfio_nf \
                  

###########################################################
#
#	Macros, these should be generic for all machines

LN		=	ln -sf
MAKE		=	make -i -r
RM		=	/bin/rm -f
CP		=	/bin/cp
AR		=	ar 
MKDIR		=	/bin/mkdir -p
RANLIB		=	ranlib

.IGNORE:
.SUFFIXES: .c .f .F .F90 .f90 .o .fpp

#	There is probably no reason to modify these rules

.c.o:
	$(RM) $@
	$(CC) $(CFLAGS) -c $<	

.f.o:
	$(RM) $@ $*.mod
	$(FC) $(FFLAGS) -c $<

.fpp.o:
	$(RM) $@ $*.mod $*.f
	$(CPP) $(FPPFLAGS) $(FDEFS)  $< > $*.f
	$(FC) $(FFLAGS) -c $*.f
	$(RM) $*.f

.F.o:
	$(RM) $@ $*.mod
	$(CPP) $(FPPFLAGS) $(FDEFS)  $< > $*.f90
	$(F90) $(FFLAGS) -c $*.f90 
	$(RM) $*.f90

.F90.o:
	$(RM) $@ $*.mod
	$(CPP) $(FPPFLAGS) $(FDEFS)  $< > $*.f90
	$(F90) $(FFLAGS) -c $*.f90 
	$(RM) $*.f90

.f90.o:
	$(RM) $@ $*.mod
	$(F90) $(FFLAGS) -c $<