# This config file contains the compile options for compilation
# of the GSI code on the NOAA HPCS.

# ----------------------------------
# Redefine variables for WCOSS
# ----------------------------------
COREINC  = /nwprod/lib/incmod
CORELIB  = /nwprod/lib
INCsfcio = $(COREINC)/sfcio_4
INCsigio = $(COREINC)/sigio_4
INCnemsio= $(COREINC)/nemsio
INCw3    = $(COREINC)/w3emc_d
INCcrtm  = $(COREINC)/crtm_2.0.6
INCgfsio = $(COREINC)/gfsio_4


# WRF locations
WRFPATH = /nwprod/sorc/wrf_shared.fd
LIBwrfio_int    = $(WRFPATH)/external/io_int/libwrfio_int.a
LIBwrfio_netcdf = $(WRFPATH)/external/io_netcdf/libwrfio_nf.a
OBJwrf_frame_pk = $(WRFPATH)/frame/pack_utils.o
WRFLIB = $(LIBwrfio_int) $(LIBwrfio_netcdf) $(OBJwrf_frame_pk)

NETCDFPATH = /usrx/local/NetCDF/3.6.3
INCnetcdf  = $(NETCDFPATH)/include



# Empty out definition of libs use by GMAO GSI building structure
LIBtransf = #-L$(CORELIB) -ltransf
LIBhermes = #-L$(CORELIB) -lhermes
LIBgfio   = #-L$(CORELIB) -lgfio
INChdf    = #-I$(BASEDIR)/$(ARCH)/include/hdf
LIBhdf    = #-L$(BASEDIR)/$(ARCH)/lib  -lmfhdf -ldf -lhdfjpeg -lhdfz -lsz


# ---------------------------
# General targets/definitions
# ---------------------------

  AR     = ar -v

# ----------------------------
# Fortran compiler and options
# ----------------------------

  CF            = mpfort
  FC            = $(CF)

#--- Normal mode options
  PROF= #-pg
  OMP = -openmp

  FFLAGS_F90    = -D_REAL8_ -DWRF

  FFLAGS_COM_N  = -I ./ -I $(INCcrtm) -I $(INCsfcio) -I $(INCsigio) -I $(INCnemsio) \
  		-I $(INCnetcdf) -I $(INCw3) -I $(INCgfsio) \
                -O3 -fp-model strict -convert big_endian -assume byterecl \
                -implicitnone -traceback $(OMP)

  FFLAGS_COM_N_NOSWAP  = -I ./ -I $(INCcrtm) -I $(INCsfcio) -I $(INCsigio) -I $(INCnemsio) \
  		       -I $(INCnetcdf) -I $(INCw3) -I $(INCgfsio) \
                       -O3 -fp-model strict -convert big_endian -assume byterecl \
                       -implicitnone -traceback $(OMP)

  FFLAGS_N  = $(FFLAGS_F90) $(FFLAGS_COM_N) $(PROF)
  FFLAGS_NOSWAP_N  = $(FFLAGS_F90) $(FFLAGS_COM_N_NOSWAP) $(PROF)
  FFLAGS_f  = $(FFLAGS_COM_N) $(PROF)
  FFLAGS    = $(FFLAGS_N) $(PROF)


#--- Debug mode options
  FFLAGS_COM_D  =  -I ./ -I $(INCcrtm) -I $(INCsfcio) -I $(INCsigio) -I $(INCnemsio) \
  		-I $(INCnetcdf) -I $(INCw3) -I $(INCgfsio) \
  		-O0 -fp-model strict -convert big_endian -assume byterecl \
		-implicitnone -g -traceback -debug -check -warn
  FFLAGS_COM_NOSWAP_D  =  -I ./ -I $(INCcrtm) -I $(INCsfcio) -I $(INCsigio) -I $(INCnemsio) \
  		       -I $(INCnetcdf) -I $(INCw3) -I $(INCgfsio) \
  		       -O0 -fp-model strict -convert big_endian -assume byterecl \
		       -implicitnone -g -traceback -debug -check -warn
  FFLAGS_D  = $(FFLAGS_F90) $(FFLAGS_COM_D)
  FFLAGS_NOSWAP_D = $(FFLAGS_F90) $(FFLAGS_COM_NOSWAP_D)



# ----------------------
# C Compiler and options
# ----------------------

  CC            = mpcc

#--- Normal mode options

  CFLAGS_N      = -DLINUX -Dfunder -I ./ -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 $(OMP)

#--- Debug mode options

  CFLAGS_D      = -DLINUX -Dfunder -I ./ -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g


# ------------------
# Linker and options
# ------------------

  LD            = $(CF)

#--- Normal mode options

  LIBS_N        = -L$(CORELIB) -lsp_d -lnemsio -lgfsio_4 -lbacio_4 -lsigio_4 \
		-lsfcio_4 -lbufr_d_64 -lw3nco_d -lw3emc_d -lcrtm_v2.0.6 $(WRFLIB) \
		-L$(NETCDFPATH)/lib -lnetcdf

  LDFLAGS_N     = -mkl -Wl,-Map,loadmap.txt $(OMP)

  LDFLAGS       = $(LDFLAGS_N)

#--- Debug mode options

  LIBS_D        = $(LIBS_N)

  LDFLAGS_D     = -mkl -Wl,-Map,loadmap.txt

#--- Empty out mpi library definition: embedded in compiler

  LIBmpi	=