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