| 1 | # svn $Id$
 | 
|---|
| 2 | #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 | 
|---|
| 3 | # Copyright (c) 2002-2019 The ROMS/TOMS Group                           :::
 | 
|---|
| 4 | #   Licensed under a MIT/X style license                                :::
 | 
|---|
| 5 | #   See License_ROMS.txt                                                :::
 | 
|---|
| 6 | #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 | 
|---|
| 7 | #
 | 
|---|
| 8 | # Include file for GNU Fortran compiler on Cygwin
 | 
|---|
| 9 | # -------------------------------------------------------------------------
 | 
|---|
| 10 | #
 | 
|---|
| 11 | # ARPACK_LIBDIR  ARPACK libary directory
 | 
|---|
| 12 | # FC             Name of the fortran compiler to use
 | 
|---|
| 13 | # FFLAGS         Flags to the fortran compiler
 | 
|---|
| 14 | # CPP            Name of the C-preprocessor
 | 
|---|
| 15 | # CPPFLAGS       Flags to the C-preprocessor
 | 
|---|
| 16 | # HDF5_INCDIR    HDF5 include directory
 | 
|---|
| 17 | # HDF5_LIBDIR    HDF5 library directory
 | 
|---|
| 18 | # HDF5_LIBS      HDF5 library switches
 | 
|---|
| 19 | # NF_CONFIG      NetCDF Fortran configuration script
 | 
|---|
| 20 | # NETCDF_INCDIR  NetCDF include directory
 | 
|---|
| 21 | # NETCDF_LIBDIR  NetCDF library directory
 | 
|---|
| 22 | # NETCDF_LIBS    NetCDF library switches
 | 
|---|
| 23 | # LD             Program to load the objects into an executable
 | 
|---|
| 24 | # LDFLAGS        Flags to the loader
 | 
|---|
| 25 | # RANLIB         Name of ranlib command
 | 
|---|
| 26 | # MDEPFLAGS      Flags for sfmakedepend  (-s if you keep .f files)
 | 
|---|
| 27 | #
 | 
|---|
| 28 | # First the defaults
 | 
|---|
| 29 | #
 | 
|---|
| 30 | 
 | 
|---|
| 31 |               BIN := $(BIN).exe
 | 
|---|
| 32 | 
 | 
|---|
| 33 |                FC := gfortran
 | 
|---|
| 34 |            FFLAGS := -frepack-arrays
 | 
|---|
| 35 |        FIXEDFLAGS := -ffixed-form
 | 
|---|
| 36 |         FREEFLAGS := -ffree-form -ffree-line-length-none
 | 
|---|
| 37 |               CPP := /usr/bin/cpp
 | 
|---|
| 38 |          CPPFLAGS := -P -traditional -w
 | 
|---|
| 39 |            INCDIR := /usr/include /usr/local/bin
 | 
|---|
| 40 |             SLIBS := -L/usr/local/lib -L/usr/lib
 | 
|---|
| 41 |             ULIBS :=
 | 
|---|
| 42 |              LIBS :=
 | 
|---|
| 43 |        MOD_SUFFIX := mod
 | 
|---|
| 44 |                LD := $(FC)
 | 
|---|
| 45 |           LDFLAGS :=
 | 
|---|
| 46 |                AR := ar
 | 
|---|
| 47 |           ARFLAGS := -r
 | 
|---|
| 48 |             MKDIR := mkdir -p
 | 
|---|
| 49 |                CP := cp -p -v
 | 
|---|
| 50 |                RM := rm -f
 | 
|---|
| 51 |            RANLIB := ranlib
 | 
|---|
| 52 |              PERL := perl
 | 
|---|
| 53 |              TEST := test
 | 
|---|
| 54 | 
 | 
|---|
| 55 | #--------------------------------------------------------------------------
 | 
|---|
| 56 | # Compiling flags for ROMS Applications.
 | 
|---|
| 57 | #--------------------------------------------------------------------------
 | 
|---|
| 58 | 
 | 
|---|
| 59 | ifdef USE_ROMS
 | 
|---|
| 60 |  ifdef USE_DEBUG
 | 
|---|
| 61 |            FFLAGS += -g
 | 
|---|
| 62 |            FFLAGS += -fbounds-check
 | 
|---|
| 63 |            FFLAGS += -fbacktrace
 | 
|---|
| 64 |            FFLAGS += -fcheck=all
 | 
|---|
| 65 | #          FFLAGS += -fsanitize=address -fsanitize=undefined
 | 
|---|
| 66 |            FFLAGS += -finit-real=nan -ffpe-trap=invalid,zero,overflow
 | 
|---|
| 67 |  else
 | 
|---|
| 68 |            FFLAGS += -O3
 | 
|---|
| 69 |            FFLAGS += -ffast-math
 | 
|---|
| 70 |  endif
 | 
|---|
| 71 |         MDEPFLAGS := --cpp --fext=f90 --file=- --objdir=$(SCRATCH_DIR)
 | 
|---|
| 72 | endif
 | 
|---|
| 73 | 
 | 
|---|
| 74 | #--------------------------------------------------------------------------
 | 
|---|
| 75 | # Compiling flags for CICE Applications.
 | 
|---|
| 76 | #--------------------------------------------------------------------------
 | 
|---|
| 77 | 
 | 
|---|
| 78 | ifdef CICE_APPLICATION
 | 
|---|
| 79 |           CPPDEFS := -DLINUS $(MY_CPP_FLAGS)
 | 
|---|
| 80 |  ifdef USE_DEBUG
 | 
|---|
| 81 |            FFLAGS += -g
 | 
|---|
| 82 |            FFLAGS += -fbounds-check
 | 
|---|
| 83 | #          FFLAGS += -fcheck=all
 | 
|---|
| 84 |            FFLAGS += -fsanitize=address -fsanitize=undefined
 | 
|---|
| 85 |  else
 | 
|---|
| 86 |            FFLAGS := -O3 -w
 | 
|---|
| 87 |  endif
 | 
|---|
| 88 | endif
 | 
|---|
| 89 | 
 | 
|---|
| 90 | #--------------------------------------------------------------------------
 | 
|---|
| 91 | # Coupled models.  Notice Linux needs the libraries repeated for
 | 
|---|
| 92 | # dependencies for some of the coupled components.
 | 
|---|
| 93 | #--------------------------------------------------------------------------
 | 
|---|
| 94 | 
 | 
|---|
| 95 | ifdef USE_COAMPS
 | 
|---|
| 96 |              LIBS += $(COAMPS_LIB_DIR)/coamps_driver.a
 | 
|---|
| 97 |              LIBS += $(COAMPS_LIB_DIR)/libaa.a
 | 
|---|
| 98 |              LIBS += $(COAMPS_LIB_DIR)/libam.a
 | 
|---|
| 99 |              LIBS += $(COAMPS_LIB_DIR)/libashare.a
 | 
|---|
| 100 |              LIBS += $(COAMPS_LIB_DIR)/libcoamps.a
 | 
|---|
| 101 |              LIBS += $(COAMPS_LIB_DIR)/libfnoc.a
 | 
|---|
| 102 |              LIBS += $(COAMPS_LIB_DIR)/libaa.a
 | 
|---|
| 103 |              LIBS += $(COAMPS_LIB_DIR)/libam.a
 | 
|---|
| 104 |              LIBS += $(COAMPS_LIB_DIR)/libashare.a
 | 
|---|
| 105 |              LIBS += $(COAMPS_LIB_DIR)/libcoamps.a
 | 
|---|
| 106 |              LIBS += $(COAMPS_LIB_DIR)/libfnoc.a
 | 
|---|
| 107 |              LIBS += $(COAMPS_LIB_DIR)/libfishpak.a
 | 
|---|
| 108 |              LIBS += $(COAMPS_LIB_DIR)/libtracer.a
 | 
|---|
| 109 | endif
 | 
|---|
| 110 | 
 | 
|---|
| 111 | ifdef USE_WRF
 | 
|---|
| 112 |              LIBS += $(WRF_LIB_DIR)/module_wrf_top.o
 | 
|---|
| 113 |              LIBS += $(WRF_LIB_DIR)/libwrflib.a
 | 
|---|
| 114 |              LIBS += $(WRF_LIB_DIR)/libfftpack.a
 | 
|---|
| 115 |              LIBS += $(WRF_LIB_DIR)/libio_grib1.a
 | 
|---|
| 116 |              LIBS += $(WRF_LIB_DIR)/libio_grib_share.a
 | 
|---|
| 117 |              LIBS += $(WRF_LIB_DIR)/libwrfio_int.a
 | 
|---|
| 118 |              LIBS += $(WRF_LIB_DIR)/libesmf_time.a
 | 
|---|
| 119 |              LIBS += $(WRF_LIB_DIR)/librsl_lite.a
 | 
|---|
| 120 |              LIBS += $(WRF_LIB_DIR)/module_internal_header_util.o
 | 
|---|
| 121 |              LIBS += $(WRF_LIB_DIR)/pack_utils.o
 | 
|---|
| 122 |              LIBS += $(WRF_LIB_DIR)/libwrfio_nf.a
 | 
|---|
| 123 | endif
 | 
|---|
| 124 | 
 | 
|---|
| 125 | ifdef CICE_APPLICATION
 | 
|---|
| 126 |             SLIBS := $(LIBS) $(SLIBS)
 | 
|---|
| 127 | endif
 | 
|---|
| 128 | 
 | 
|---|
| 129 | #--------------------------------------------------------------------------
 | 
|---|
| 130 | # Library locations, can be overridden by environment variables.
 | 
|---|
| 131 | #--------------------------------------------------------------------------
 | 
|---|
| 132 | 
 | 
|---|
| 133 |           LDFLAGS := $(FFLAGS)
 | 
|---|
| 134 | 
 | 
|---|
| 135 | ifdef USE_NETCDF4
 | 
|---|
| 136 |         NF_CONFIG ?= nf-config
 | 
|---|
| 137 |     NETCDF_INCDIR ?= $(shell $(NF_CONFIG) --prefix)/include
 | 
|---|
| 138 |              LIBS += $(shell $(NF_CONFIG) --flibs)
 | 
|---|
| 139 |            INCDIR += $(NETCDF_INCDIR) $(INCDIR)
 | 
|---|
| 140 | else
 | 
|---|
| 141 |     NETCDF_INCDIR ?= /usr/include
 | 
|---|
| 142 |     NETCDF_LIBDIR ?= /usr/lib
 | 
|---|
| 143 |       NETCDF_LIBS ?= -lnetcdf
 | 
|---|
| 144 |              LIBS += -L$(NETCDF_LIBDIR) $(NETCDF_LIBS)
 | 
|---|
| 145 |            INCDIR += $(NETCDF_INCDIR) $(INCDIR)
 | 
|---|
| 146 | endif
 | 
|---|
| 147 | 
 | 
|---|
| 148 | ifdef USE_HDF5
 | 
|---|
| 149 |       HDF5_INCDIR ?= /usr/include
 | 
|---|
| 150 |       HDF5_LIBDIR ?= /usr/lib
 | 
|---|
| 151 |         HDF5_LIBS ?= -lhdf5_fortran -lhdf5hl_fortran -lhdf5 -lz
 | 
|---|
| 152 |              LIBS += -L$(HDF5_LIBDIR) $(HDF5_LIBS)
 | 
|---|
| 153 |            INCDIR += $(HDF5_INCDIR)
 | 
|---|
| 154 | endif
 | 
|---|
| 155 | 
 | 
|---|
| 156 | ifdef USE_ARPACK
 | 
|---|
| 157 |  ifdef USE_MPI
 | 
|---|
| 158 |    PARPACK_LIBDIR ?= /usr/local/lib
 | 
|---|
| 159 |              LIBS += -L$(PARPACK_LIBDIR) -lparpack
 | 
|---|
| 160 |  endif
 | 
|---|
| 161 |     ARPACK_LIBDIR ?= /usr/local/lib
 | 
|---|
| 162 |              LIBS += -L$(ARPACK_LIBDIR) -larpack
 | 
|---|
| 163 | endif
 | 
|---|
| 164 | 
 | 
|---|
| 165 | ifdef USE_MPI
 | 
|---|
| 166 |          CPPFLAGS += -DMPI
 | 
|---|
| 167 |  ifdef USE_MPIF90
 | 
|---|
| 168 |                FC := mpif90
 | 
|---|
| 169 |  else
 | 
|---|
| 170 |              LIBS += -lfmpi -lmpi
 | 
|---|
| 171 |  endif
 | 
|---|
| 172 | endif
 | 
|---|
| 173 | 
 | 
|---|
| 174 | ifdef USE_OpenMP
 | 
|---|
| 175 |          CPPFLAGS += -D_OPENMP
 | 
|---|
| 176 |            FFLAGS += -fopenmp -static-libgcc
 | 
|---|
| 177 | endif
 | 
|---|
| 178 | 
 | 
|---|
| 179 | ifdef USE_MCT
 | 
|---|
| 180 |        MCT_INCDIR ?= /usr/local/mct/include
 | 
|---|
| 181 |        MCT_LIBDIR ?= /usr/local/mct/lib
 | 
|---|
| 182 |            FFLAGS += -I$(MCT_INCDIR)
 | 
|---|
| 183 |              LIBS += -L$(MCT_LIBDIR) -lmct -lmpeu
 | 
|---|
| 184 |            INCDIR += $(MCT_INCDIR) $(INCDIR)
 | 
|---|
| 185 | endif
 | 
|---|
| 186 | 
 | 
|---|
| 187 | ifdef USE_ESMF
 | 
|---|
| 188 |           ESMF_OS ?= $(OS)
 | 
|---|
| 189 |       ESMF_SUBDIR := $(ESMF_OS).$(ESMF_COMPILER).$(ESMF_ABI).$(ESMF_COMM).$(ESMF_SITE)
 | 
|---|
| 190 |       ESMF_MK_DIR ?= $(ESMF_DIR)/lib/lib$(ESMF_BOPT)/$(ESMF_SUBDIR)
 | 
|---|
| 191 |                      include $(ESMF_MK_DIR)/esmf.mk
 | 
|---|
| 192 |            FFLAGS += $(ESMF_F90COMPILEPATHS)
 | 
|---|
| 193 |              LIBS += $(ESMF_F90LINKPATHS) $(ESMF_F90ESMFLINKLIBS)
 | 
|---|
| 194 | endif
 | 
|---|
| 195 | 
 | 
|---|
| 196 | # Use full path of compiler.
 | 
|---|
| 197 | 
 | 
|---|
| 198 |                FC := $(shell which ${FC})
 | 
|---|
| 199 |                LD := $(FC)
 | 
|---|
| 200 | 
 | 
|---|
| 201 | #--------------------------------------------------------------------------
 | 
|---|
| 202 | # ROMS specific rules.
 | 
|---|
| 203 | #--------------------------------------------------------------------------
 | 
|---|
| 204 | 
 | 
|---|
| 205 | # Turn off bounds checking for function def_var, as "dimension(*)"
 | 
|---|
| 206 | # declarations confuse Gnu Fortran 95 bounds-checking code.
 | 
|---|
| 207 | 
 | 
|---|
| 208 | ifdef USE_ROMS
 | 
|---|
| 209 |  $(SCRATCH_DIR)/def_var.o: FFLAGS += -fno-bounds-check
 | 
|---|
| 210 | endif
 | 
|---|
| 211 | 
 | 
|---|
| 212 | # Allow integer overflow in ran_state.F.  This is not allowed
 | 
|---|
| 213 | # during -O3 optimization. This option should be applied only for
 | 
|---|
| 214 | # Gfortran versions >= 4.2.
 | 
|---|
| 215 | 
 | 
|---|
| 216 | ifdef USE_ROMS
 | 
|---|
| 217 |  FC_TEST := $(findstring $(shell ${FC} --version | head -1 | \
 | 
|---|
| 218 |                               awk '{ sub("Fortran 95", "Fortran"); print }' | \
 | 
|---|
| 219 |                               cut -d " " -f 4 | \
 | 
|---|
| 220 |                               cut -d "." -f 1-2), \
 | 
|---|
| 221 |              4.0 4.1)
 | 
|---|
| 222 | 
 | 
|---|
| 223 |  ifeq "${FC_TEST}" ""
 | 
|---|
| 224 |   $(SCRATCH_DIR)/ran_state.o: FFLAGS += -fno-strict-overflow
 | 
|---|
| 225 |  endif
 | 
|---|
| 226 | endif
 | 
|---|
| 227 | 
 | 
|---|
| 228 | # Set free form format in some ROMS source files to allow long string for
 | 
|---|
| 229 | # local directory and compilation flags inside the code.
 | 
|---|
| 230 | 
 | 
|---|
| 231 | ifdef USE_ROMS
 | 
|---|
| 232 |  $(SCRATCH_DIR)/mod_ncparam.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 233 |  $(SCRATCH_DIR)/mod_strings.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 234 |  $(SCRATCH_DIR)/analytical.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 235 |  $(SCRATCH_DIR)/biology.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 236 | 
 | 
|---|
| 237 |  ifdef USE_ADJOINT
 | 
|---|
| 238 |   $(SCRATCH_DIR)/ad_biology.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 239 |  endif
 | 
|---|
| 240 |  ifdef USE_REPRESENTER
 | 
|---|
| 241 |   $(SCRATCH_DIR)/rp_biology.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 242 |  endif
 | 
|---|
| 243 |  ifdef USE_TANGENT
 | 
|---|
| 244 |   $(SCRATCH_DIR)/tl_biology.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 245 |  endif
 | 
|---|
| 246 | endif
 | 
|---|
| 247 | 
 | 
|---|
| 248 | #--------------------------------------------------------------------------
 | 
|---|
| 249 | # Model coupling specific rules.
 | 
|---|
| 250 | #--------------------------------------------------------------------------
 | 
|---|
| 251 | 
 | 
|---|
| 252 | # Add COAMPS library directory to include path of ESMF coupling files.
 | 
|---|
| 253 | 
 | 
|---|
| 254 | ifdef USE_COAMPS
 | 
|---|
| 255 |  $(SCRATCH_DIR)/esmf_atm.o: FFLAGS += -I$(COAMPS_LIB_DIR)
 | 
|---|
| 256 |  $(SCRATCH_DIR)/esmf_esm.o: FFLAGS += -I$(COAMPS_LIB_DIR)
 | 
|---|
| 257 | endif
 | 
|---|
| 258 | 
 | 
|---|
| 259 | # Add WRF library directory to include path of ESMF coupling files.
 | 
|---|
| 260 | 
 | 
|---|
| 261 | ifdef USE_WRF
 | 
|---|
| 262 |  ifeq "$(strip $(WRF_LIB_DIR))" "$(WRF_SRC_DIR)"
 | 
|---|
| 263 |   $(SCRATCH_DIR)/esmf_atm.o: FFLAGS += $(addprefix -I$(WRF_LIB_DIR)/,$(WRF_MOD_DIRS))
 | 
|---|
| 264 |  else
 | 
|---|
| 265 |   $(SCRATCH_DIR)/esmf_atm.o: FFLAGS += -I$(WRF_LIB_DIR)
 | 
|---|
| 266 |  endif
 | 
|---|
| 267 | endif
 | 
|---|
| 268 | 
 | 
|---|
| 269 | # Supress free format in SWAN source files since there are comments
 | 
|---|
| 270 | # beyond column 72.
 | 
|---|
| 271 | 
 | 
|---|
| 272 | ifdef USE_SWAN
 | 
|---|
| 273 |  $(SCRATCH_DIR)/ocpcre.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 274 |  $(SCRATCH_DIR)/ocpids.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 275 |  $(SCRATCH_DIR)/ocpmix.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 276 |  $(SCRATCH_DIR)/swancom1.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 277 |  $(SCRATCH_DIR)/swancom2.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 278 |  $(SCRATCH_DIR)/swancom3.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 279 |  $(SCRATCH_DIR)/swancom4.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 280 |  $(SCRATCH_DIR)/swancom5.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 281 |  $(SCRATCH_DIR)/swanmain.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 282 |  $(SCRATCH_DIR)/swanout1.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 283 |  $(SCRATCH_DIR)/swanout2.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 284 |  $(SCRATCH_DIR)/swanparll.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 285 |  $(SCRATCH_DIR)/swanpre1.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 286 |  $(SCRATCH_DIR)/swanpre2.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 287 |  $(SCRATCH_DIR)/swanser.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 288 |  $(SCRATCH_DIR)/swmod1.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 289 |  $(SCRATCH_DIR)/swmod2.o: FFLAGS += $(FIXEDFLAGS)
 | 
|---|
| 290 |  $(SCRATCH_DIR)/m_constants.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 291 |  $(SCRATCH_DIR)/m_fileio.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 292 |  $(SCRATCH_DIR)/mod_xnl4v5.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 293 |  $(SCRATCH_DIR)/serv_xnl4v5.o: FFLAGS += $(FREEFLAGS)
 | 
|---|
| 294 | endif
 | 
|---|