| 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 := -132
|
|---|
| 33 | FREEFLAGS := -free
|
|---|
| 34 | CPP := /usr/bin/cpp
|
|---|
| 35 | CPPFLAGS := -P -traditional -w # -w turns of warnings
|
|---|
| 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 ROMS_APPLICATION
|
|---|
| 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 += -O3
|
|---|
| 80 | FFLAGS += -fbounds-check
|
|---|
| 81 | # FFLAGS += -fcheck=all
|
|---|
| 82 | FFLAGS += -fsanitize=address -fsanitize=undefined
|
|---|
| 83 | else
|
|---|
| 84 | FFLAGS := -O3 -w
|
|---|
| 85 | endif
|
|---|
| 86 | endif
|
|---|
| 87 |
|
|---|
| 88 | #--------------------------------------------------------------------------
|
|---|
| 89 | # Library locations, can be overridden by environment variables.
|
|---|
| 90 | #--------------------------------------------------------------------------
|
|---|
| 91 |
|
|---|
| 92 | LDFLAGS := $(FFLAGS)
|
|---|
| 93 |
|
|---|
| 94 | ifdef USE_NETCDF4
|
|---|
| 95 | NF_CONFIG ?= nf-config
|
|---|
| 96 | NETCDF_INCDIR ?= $(shell $(NF_CONFIG) --prefix)/include
|
|---|
| 97 | LIBS += $(shell $(NF_CONFIG) --flibs)
|
|---|
| 98 | INCDIR += $(NETCDF_INCDIR) $(INCDIR)
|
|---|
| 99 | else
|
|---|
| 100 | NETCDF_INCDIR ?= /opt/gfortransoft/serial/netcdf3/include
|
|---|
| 101 | NETCDF_LIBDIR ?= /opt/gfortransoft/serial/netcdf3/lib
|
|---|
| 102 | NETCDF_LIBS ?= -lnetcdf
|
|---|
| 103 | LIBS += -L$(NETCDF_LIBDIR) $(NETCDF_LIBS)
|
|---|
| 104 | INCDIR += $(NETCDF_INCDIR) $(INCDIR)
|
|---|
| 105 | endif
|
|---|
| 106 |
|
|---|
| 107 | ifdef USE_HDF5
|
|---|
| 108 | HDF5_INCDIR ?= /opt/gfortransoft/serial/hdf5/include
|
|---|
| 109 | HDF5_LIBDIR ?= /opt/gfortransoft/serial/hdf5/lib
|
|---|
| 110 | HDF5_LIBS ?= -lhdf5_fortran -lhdf5hl_fortran -lhdf5 -lz
|
|---|
| 111 | LIBS += -L$(HDF5_LIBDIR) $(HDF5_LIBS)
|
|---|
| 112 | INCDIR += $(HDF5_INCDIR)
|
|---|
| 113 | endif
|
|---|
| 114 |
|
|---|
| 115 | ifdef USE_ARPACK
|
|---|
| 116 | ifdef USE_MPI
|
|---|
| 117 | PARPACK_LIBDIR ?= /opt/gfortransoft/PARPACK
|
|---|
| 118 | LIBS += -L$(PARPACK_LIBDIR) -lparpack
|
|---|
| 119 | endif
|
|---|
| 120 | ARPACK_LIBDIR ?= /opt/gfortransoft/ARPACK
|
|---|
| 121 | LIBS += -L$(ARPACK_LIBDIR) -larpack
|
|---|
| 122 | endif
|
|---|
| 123 |
|
|---|
| 124 | ifdef USE_MPI
|
|---|
| 125 | CPPFLAGS += -DMPI
|
|---|
| 126 | ifdef USE_MPIF90
|
|---|
| 127 | FC := mpif90
|
|---|
| 128 | else
|
|---|
| 129 | LIBS += -lfmpi -lmpi
|
|---|
| 130 | endif
|
|---|
| 131 | endif
|
|---|
| 132 |
|
|---|
| 133 | ifdef USE_OpenMP
|
|---|
| 134 | CPPFLAGS += -D_OPENMP
|
|---|
| 135 | FFLAGS += -fopenmp -static-libgcc
|
|---|
| 136 | # LIBS += -lgomp
|
|---|
| 137 | endif
|
|---|
| 138 |
|
|---|
| 139 | ifdef USE_MCT
|
|---|
| 140 | MCT_INCDIR ?= /usr/local/mct/include
|
|---|
| 141 | MCT_LIBDIR ?= /usr/local/mct/lib
|
|---|
| 142 | FFLAGS += -I$(MCT_INCDIR)
|
|---|
| 143 | LIBS += -L$(MCT_LIBDIR) -lmct -lmpeu
|
|---|
| 144 | INCDIR += $(MCT_INCDIR) $(INCDIR)
|
|---|
| 145 | endif
|
|---|
| 146 |
|
|---|
| 147 | ifdef USE_ESMF
|
|---|
| 148 | ESMF_OS ?= $(OS)
|
|---|
| 149 | ESMF_SUBDIR := $(ESMF_OS).$(ESMF_COMPILER).$(ESMF_ABI).$(ESMF_COMM).$(ESMF_SITE)
|
|---|
| 150 | ESMF_MK_DIR ?= $(ESMF_DIR)/lib/lib$(ESMF_BOPT)/$(ESMF_SUBDIR)
|
|---|
| 151 | include $(ESMF_MK_DIR)/esmf.mk
|
|---|
| 152 | FFLAGS += $(ESMF_F90COMPILEPATHS)
|
|---|
| 153 | LIBS += $(ESMF_F90LINKPATHS) $(ESMF_F90ESMFLINKLIBS)
|
|---|
| 154 | endif
|
|---|
| 155 |
|
|---|
| 156 | ifdef USE_COAMPS
|
|---|
| 157 | LIBS += $(COAMPS_LIB_DIR)/libashare.a
|
|---|
| 158 | LIBS += $(COAMPS_LIB_DIR)/libcoamps.a
|
|---|
| 159 | LIBS += $(COAMPS_LIB_DIR)/libaa.a
|
|---|
| 160 | LIBS += $(COAMPS_LIB_DIR)/libam.a
|
|---|
| 161 | LIBS += $(COAMPS_LIB_DIR)/libfishpak.a
|
|---|
| 162 | LIBS += $(COAMPS_LIB_DIR)/libfnoc.a
|
|---|
| 163 | LIBS += $(COAMPS_LIB_DIR)/libtracer.a
|
|---|
| 164 | # LIBS += $(COAMPS_LIB_DIR)/libnl_beq.a
|
|---|
| 165 | endif
|
|---|
| 166 |
|
|---|
| 167 | ifdef CICE_APPLICATION
|
|---|
| 168 | SLIBS += $(SLIBS) $(LIBS)
|
|---|
| 169 | endif
|
|---|
| 170 |
|
|---|
| 171 | ifdef USE_WRF
|
|---|
| 172 | ifeq "$(strip $(WRF_LIB_DIR))" "$(WRF_SRC_DIR)"
|
|---|
| 173 | LIBS += $(WRF_LIB_DIR)/main/module_wrf_top.o
|
|---|
| 174 | LIBS += $(WRF_LIB_DIR)/main/libwrflib.a
|
|---|
| 175 | LIBS += $(WRF_LIB_DIR)/external/fftpack/fftpack5/libfftpack.a
|
|---|
| 176 | LIBS += $(WRF_LIB_DIR)/external/io_grib1/libio_grib1.a
|
|---|
| 177 | LIBS += $(WRF_LIB_DIR)/external/io_grib_share/libio_grib_share.a
|
|---|
| 178 | LIBS += $(WRF_LIB_DIR)/external/io_int/libwrfio_int.a
|
|---|
| 179 | LIBS += $(WRF_LIB_DIR)/external/esmf_time_f90/libmyesmf_time.a
|
|---|
| 180 | LIBS += $(WRF_LIB_DIR)/external/RSL_LITE/librsl_lite.a
|
|---|
| 181 | LIBS += $(WRF_LIB_DIR)/frame/module_internal_header_util.o
|
|---|
| 182 | LIBS += $(WRF_LIB_DIR)/frame/pack_utils.o
|
|---|
| 183 | LIBS += $(WRF_LIB_DIR)/external/io_netcdf/libwrfio_nf.a
|
|---|
| 184 | WRF_MOD_DIRS = main frame phys share external/esmf_time_f90
|
|---|
| 185 | else
|
|---|
| 186 | LIBS += $(WRF_LIB_DIR)/module_wrf_top.o
|
|---|
| 187 | LIBS += $(WRF_LIB_DIR)/libwrflib.a
|
|---|
| 188 | LIBS += $(WRF_LIB_DIR)/libfftpack.a
|
|---|
| 189 | LIBS += $(WRF_LIB_DIR)/libio_grib1.a
|
|---|
| 190 | LIBS += $(WRF_LIB_DIR)/libio_grib_share.a
|
|---|
| 191 | LIBS += $(WRF_LIB_DIR)/libwrfio_int.a
|
|---|
| 192 | LIBS += $(WRF_LIB_DIR)/libmyesmf_time.a
|
|---|
| 193 | LIBS += $(WRF_LIB_DIR)/librsl_lite.a
|
|---|
| 194 | LIBS += $(WRF_LIB_DIR)/module_internal_header_util.o
|
|---|
| 195 | LIBS += $(WRF_LIB_DIR)/pack_utils.o
|
|---|
| 196 | LIBS += $(WRF_LIB_DIR)/libwrfio_nf.a
|
|---|
| 197 | endif
|
|---|
| 198 | endif
|
|---|
| 199 |
|
|---|
| 200 | # Use full path of compiler.
|
|---|
| 201 |
|
|---|
| 202 | FC := $(shell which ${FC})
|
|---|
| 203 | LD := $(FC)
|
|---|
| 204 |
|
|---|
| 205 | #--------------------------------------------------------------------------
|
|---|
| 206 | # ROMS specific rules.
|
|---|
| 207 | #--------------------------------------------------------------------------
|
|---|
| 208 |
|
|---|
| 209 | # Turn off bounds checking for function def_var, as "dimension(*)"
|
|---|
| 210 | # declarations confuse Gnu Fortran 95 bounds-checking code.
|
|---|
| 211 |
|
|---|
| 212 | ifdef ROMS_APPLICATION
|
|---|
| 213 | $(SCRATCH_DIR)/def_var.o: FFLAGS += -fno-bounds-check
|
|---|
| 214 | endif
|
|---|
| 215 |
|
|---|
| 216 | # Allow integer overflow in ran_state.F. This is not allowed
|
|---|
| 217 | # during -O3 optimization. This option should be applied only for
|
|---|
| 218 | # Gfortran versions >= 4.2.
|
|---|
| 219 |
|
|---|
| 220 | ifdef ROMS_APPLICATION
|
|---|
| 221 | FC_TEST := $(findstring $(shell ${FC} --version | head -1 | \
|
|---|
| 222 | awk '{ sub("Fortran 95", "Fortran"); print }' | \
|
|---|
| 223 | cut -d " " -f 4 | \
|
|---|
| 224 | cut -d "." -f 1-2), \
|
|---|
| 225 | 4.0 4.1)
|
|---|
| 226 |
|
|---|
| 227 | ifeq "${FC_TEST}" ""
|
|---|
| 228 | $(SCRATCH_DIR)/ran_state.o: FFLAGS += -fno-strict-overflow
|
|---|
| 229 | endif
|
|---|
| 230 | endif
|
|---|
| 231 |
|
|---|
| 232 | # Set free form format in some ROMS source files to allow long string for
|
|---|
| 233 | # local directory and compilation flags inside the code.
|
|---|
| 234 |
|
|---|
| 235 | ifdef ROMS_APPLICATION
|
|---|
| 236 | $(SCRATCH_DIR)/mod_ncparam.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 237 | $(SCRATCH_DIR)/mod_strings.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 238 | $(SCRATCH_DIR)/analytical.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 239 | $(SCRATCH_DIR)/biology.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 240 |
|
|---|
| 241 | ifdef USE_ADJOINT
|
|---|
| 242 | $(SCRATCH_DIR)/ad_biology.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 243 | endif
|
|---|
| 244 | ifdef USE_REPRESENTER
|
|---|
| 245 | $(SCRATCH_DIR)/rp_biology.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 246 | endif
|
|---|
| 247 | ifdef USE_TANGENT
|
|---|
| 248 | $(SCRATCH_DIR)/tl_biology.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 249 | endif
|
|---|
| 250 | endif
|
|---|
| 251 |
|
|---|
| 252 | #--------------------------------------------------------------------------
|
|---|
| 253 | # Model coupling specific rules.
|
|---|
| 254 | #--------------------------------------------------------------------------
|
|---|
| 255 |
|
|---|
| 256 | # Add COAMPS library directory to include path of ESMF coupling files.
|
|---|
| 257 |
|
|---|
| 258 | ifdef USE_COAMPS
|
|---|
| 259 | $(SCRATCH_DIR)/esmf_atm.o: FFLAGS += -I$(COAMPS_LIB_DIR)
|
|---|
| 260 | $(SCRATCH_DIR)/esmf_esm.o: FFLAGS += -I$(COAMPS_LIB_DIR)
|
|---|
| 261 | endif
|
|---|
| 262 |
|
|---|
| 263 | # Add WRF library directory to include path of ESMF coupling files.
|
|---|
| 264 |
|
|---|
| 265 | ifdef USE_WRF
|
|---|
| 266 | ifeq "$(strip $(WRF_LIB_DIR))" "$(WRF_SRC_DIR)"
|
|---|
| 267 | $(SCRATCH_DIR)/esmf_atm.o: FFLAGS += $(addprefix -I$(WRF_LIB_DIR)/,$(WRF_MOD_DIRS))
|
|---|
| 268 | else
|
|---|
| 269 | $(SCRATCH_DIR)/esmf_atm.o: FFLAGS += -I$(WRF_LIB_DIR)
|
|---|
| 270 | endif
|
|---|
| 271 | endif
|
|---|
| 272 |
|
|---|
| 273 | # Supress free format in SWAN source files since there are comments
|
|---|
| 274 | # beyond column 72.
|
|---|
| 275 |
|
|---|
| 276 | ifdef USE_SWAN
|
|---|
| 277 | $(SCRATCH_DIR)/ocpcre.o: FFLAGS += -ffixed-form
|
|---|
| 278 | $(SCRATCH_DIR)/ocpids.o: FFLAGS += -ffixed-form
|
|---|
| 279 | $(SCRATCH_DIR)/ocpmix.o: FFLAGS += -ffixed-form
|
|---|
| 280 | $(SCRATCH_DIR)/swancom1.o: FFLAGS += -ffixed-form
|
|---|
| 281 | $(SCRATCH_DIR)/swancom2.o: FFLAGS += -ffixed-form
|
|---|
| 282 | $(SCRATCH_DIR)/swancom3.o: FFLAGS += -ffixed-form
|
|---|
| 283 | $(SCRATCH_DIR)/swancom4.o: FFLAGS += -ffixed-form
|
|---|
| 284 | $(SCRATCH_DIR)/swancom5.o: FFLAGS += -ffixed-form
|
|---|
| 285 | $(SCRATCH_DIR)/swanmain.o: FFLAGS += -ffixed-form
|
|---|
| 286 | $(SCRATCH_DIR)/swanout1.o: FFLAGS += -ffixed-form
|
|---|
| 287 | $(SCRATCH_DIR)/swanout2.o: FFLAGS += -ffixed-form
|
|---|
| 288 | $(SCRATCH_DIR)/swanparll.o: FFLAGS += -ffixed-form
|
|---|
| 289 | $(SCRATCH_DIR)/swanpre1.o: FFLAGS += -ffixed-form
|
|---|
| 290 | $(SCRATCH_DIR)/swanpre2.o: FFLAGS += -ffixed-form
|
|---|
| 291 | $(SCRATCH_DIR)/swanser.o: FFLAGS += -ffixed-form
|
|---|
| 292 | $(SCRATCH_DIR)/swmod1.o: FFLAGS += -ffixed-form
|
|---|
| 293 | $(SCRATCH_DIR)/swmod2.o: FFLAGS += -ffixed-form
|
|---|
| 294 | $(SCRATCH_DIR)/m_constants.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 295 | $(SCRATCH_DIR)/m_fileio.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 296 | $(SCRATCH_DIR)/mod_xnl4v5.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 297 | $(SCRATCH_DIR)/serv_xnl4v5.o: FFLAGS += -ffree-form -ffree-line-length-none
|
|---|
| 298 | endif
|
|---|