1 #***********************************************************************
2 #* GNU Lesser General Public License
4 #* This file is part of the GFDL Flexible Modeling System (FMS).
6 #* FMS is free software: you can redistribute it and/or modify it under
7 #* the terms of the GNU Lesser General Public License as published by
8 #* the Free Software Foundation, either version 3 of the License, or (at
9 #* your option) any later version.
11 #* FMS is distributed in the hope that it will be useful, but WITHOUT
12 #* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 #* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #* You should have received a copy of the GNU Lesser General Public
17 #* License along with FMS. If not, see <http://www.gnu.org/licenses/>.
18 #***********************************************************************
20 # This is the main configure file for the FMS package.
21 # Ed Hartnett 2/21/2019
22 # Seth Underwood 10/2/2019
26 # Initialize with name, version, and support email address.
27 AC_INIT([GFDL FMS Library],
29 [gfdl.climate.model.info@noaa.gov],
31 [https://www.github.com/NOAA-GFDL/FMS])
33 # Find out about the host we're building on.
37 # Find out about the target we're building for.
40 AC_CONFIG_MACRO_DIR([m4])
42 AM_INIT_AUTOMAKE([foreign dist-zip subdir-objects])
48 # If building on a Cray PE system, check if CRAYPE_LINK_TYPE is 'static'. If it
49 # is, then disable building shared libraries. Note, the user can still override
50 # this by using --enable-shared when running the configure script.
51 AS_IF([test x${CRAYPE_VERSION:+yes} = "xyes"],[
52 AS_IF([test x${CRAYPE_LINK_TYPE} = "xstatic"],
53 [AC_DISABLE_SHARED])])
56 # Process user optons.
58 [AS_HELP_STRING([--with-mpi],
59 [Build with MPI support. This option will be ignored if --disable-fortran-flag-setting is also given. (Default yes)])])
60 AS_IF([test ${with_mpi:-yes} = yes],
64 [AS_HELP_STRING([--with-yaml],
65 [Build with YAML support. This option will be ignored if --disable-fortran-flag-setting is also given. (Default no)])])
66 AS_IF([test ${with_yaml:-no} = no],
69 AC_ARG_ENABLE([setting-flags],
70 [AS_HELP_STRING([--enable-setting-flags],
71 [Allow configure to set some compiler flags. Disabling this will also disable any other --with or --enable options that set flags, and will only use user-provided falgs. (Default yes)])])
72 AS_IF([test ${enable_setting_flags:-yes} = yes],
73 [enable_setting_flags=yes],
74 [enable_setting_flags=no])
75 AC_ARG_ENABLE([code-coverage],
76 [AS_HELP_STRING([--enable-code-coverage],
77 [Allow configure to set flags and add check-code-coverage target for code coverage analysis (Default no)])])
78 AS_IF([test ${enable_code_coverage:-no} = no],
79 [enable_code_coverage=no],
80 [enable_code_coverage=yes])
81 # individual mixed precision overload macros
82 AC_ARG_ENABLE([overload-c4],
83 [AS_HELP_STRING([--enable-overload-c4],
84 [Enables the OVERLOAD_C4 macro to compile with 4 byte complex routine overloads. (Default no)])])
85 AS_IF([test ${enable_overload_c4:-no} = yes],
86 [enable_overload_c4=yes],
87 [enable_overload_c4=no])
88 AC_ARG_ENABLE([overload-c8],
89 [AS_HELP_STRING([--enable-overload-c8],
90 [Enables the OVERLOAD_C8 macro to compile with 8 byte real routine overloads. (Default no)])])
91 AS_IF([test ${enable_overload_c8:-no} = yes],
92 [enable_overload_c8=yes],
93 [enable_overload_c8=no])
94 AC_ARG_ENABLE([8byte-int],
95 [AS_HELP_STRING([--disable-8byte-int],
96 [Enables the no_8byte_integers macro to compile with only 4 byte integer routines. (Default no)])])
97 AS_IF([test ${enable_8byte_int:-no} = yes],
98 [enable_8byte_int=yes],
99 [enable_8byte_int=no])
101 AC_ARG_ENABLE([deprecated-io],
102 [AS_HELP_STRING([--enable-deprecated-io],
103 [Enables compilation of deprecated mpp_io and fms_io modules in addition to the updated fms2_io modules (default no)])])
104 AS_IF([test ${enable_deprecated_io:-no} = yes],
105 [enable_deprecated_io=yes],
106 [enable_deprecated_io=no])
108 AC_ARG_ENABLE([r8-default],
109 [AS_HELP_STRING([--disable-r8-default],
110 [Disables the build from adding the 8 byte default real kind flag during compilation (default no)])])
111 AS_IF([test ${enable_r8_default:-yes} = yes],
112 [enable_r8_default=yes],
113 [enable_r8_default=no])
115 # user enabled testing with input files
116 AC_MSG_CHECKING([whether to enable tests with input files])
117 AC_ARG_ENABLE([test-input],
118 [AS_HELP_STRING([--enable-test-input="path/to/input"],
119 [Enable tests using input netcdf files, if present in the given full directory.])])
120 AC_MSG_RESULT([$enable_test_input])
122 # require path to be given
123 AS_IF([test "x$enable_test_input" = "xyes"],
124 [AC_MSG_ERROR([Test input enabled, but no directory given with --enable-test-input=/path])],
125 [AS_IF([test "x$enable_test_input" != "xno"],
126 [TEST_INPUT_PATH="$enable_test_input"],[])]
129 # if set, check directory exists
130 AS_IF([test "$TEST_INPUT_PATH" = ""],
132 [AS_IF([test -d $TEST_INPUT_PATH],[],
133 [AC_MSG_ERROR([Test input enabled, but directory $TEST_INPUT_PATH not found]) ]
136 # substitute path for input
137 AC_SUBST([TEST_INPUT_PATH])
139 # Does the user want to build documentation?
140 AC_MSG_CHECKING([whether documentation should be built (requires doxygen)])
141 AC_ARG_ENABLE([docs],
142 [AS_HELP_STRING([--enable-docs],
143 [enable building of documentation with doxygen.])])
144 test "x$enable_docs" = xyes || enable_docs=no
145 AC_MSG_RESULT([$enable_docs])
146 AM_CONDITIONAL(BUILD_DOCS, [test "x$enable_docs" = xyes])
148 # Is doxygen installed?
149 AC_CHECK_PROGS([DOXYGEN], [doxygen])
150 if test -z "$DOXYGEN" -a "x$enable_docs" = xyes; then
151 AC_MSG_ERROR([Doxygen not found but --enable-docs used.])
154 # If building docs, process Doxyfile.in into Doxyfile.
155 if test "x$enable_docs" = xyes; then
156 AC_CONFIG_FILES([docs/Doxyfile])
159 # Find the C compiler.
165 # Find the Fortran compiler.
168 AC_FC_MODULE_EXTENSION
169 AC_FC_MODULE_OUTPUT_FLAG
171 # Find the install program.
174 # Check to see if any macros must be set to enable large (>2GB) files.
179 if test $with_mpi = yes; then
181 # We expect users to set CC and FC to MPI compiler wrappers, or that the correct
182 # CPPFLAGS, {C,FC}FLAGS, LDFLAGS and LIBS options are given.
187 if test $with_yaml = yes; then
188 AC_CHECK_HEADERS([yaml.h], [], [AC_MSG_ERROR(["Can't find the libYAML C header file. Set CC/CPPFLAGS/CFLAGS"])])
189 AC_SEARCH_LIBS([yaml_parser_initialize], [yaml], [], [AC_MSG_ERROR(["Can't find the libYAML C library. Set CC/LDFLAGS/LIBS"])])
191 #If the test pass, define use_yaml macro
192 AC_DEFINE([use_yaml], [1], [This is required to use yaml parser])
194 AM_CONDITIONAL([USING_YAML], true)
196 AM_CONDITIONAL([USING_YAML], false)
200 AC_CHECK_HEADERS([netcdf.h], [], [AC_MSG_ERROR([Can't find the netCDF C header file. Set CPPFLAGS/CFLAGS])])
201 AC_SEARCH_LIBS([nc_create], [netcdf], [], [AC_MSG_ERROR([Can't find the netCDF C library. Set LDFLAGS/LIBS])])
203 # Require netCDF-4 (with HDF5).
204 AC_MSG_CHECKING([if netCDF was built with HDF5])
205 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
206 #include <netcdf_meta.h>
208 #endif]])], [nc_has_nc4=yes], [nc_has_nc4=no])
209 AC_MSG_RESULT([$nc_has_nc4])
210 if test $nc_has_nc4 = no; then
211 AC_MSG_ERROR([NetCDF must be built with HDF5.])
214 # Check if ncdump is avaiable
215 AC_CHECK_PROG([USE_NCDUMP],[ncdump], [yes], [no])
216 if test $USE_NCDUMP = yes; then
217 AM_CONDITIONAL([SKIP_NCDUMP_CHECKS], true )
219 AM_CONDITIONAL([SKIP_NCDUMP_CHECKS], false )
222 # Check if Linux gettid is avaiable
223 AC_CHECK_FUNCS([gettid], [], [])
225 # Check if Linux sched_getaffinity is available
226 AC_CHECK_FUNCS([sched_getaffinity], [], [])
228 # Check if the compiler needs special OpenMP flags
232 # Fortran specific checks
233 AC_LANG_PUSH(Fortran)
234 if test $with_mpi = yes; then
237 GX_MPI_FC_LEGACY_INTERFACE()
238 # Determine if a flag is required to allow external procedure argument mismatch when
239 # an explicit interface does not exist
240 if test ! -z "$HAVE_MPI_FC_LEGACY"; then
241 GX_FC_ALLOW_ARG_MISMATCH([dnl
242 FCFLAGS="$FCFLAGS $FC_ALLOW_ARG_MISMATCH_FLAG"])
246 # check intel compiler and coverage tools are avaiable if code coverage is enabled
247 if test "$enable_code_coverage" = yes; then
248 if test ! -z "`$FC --version | grep ifort`"; then
249 AC_CHECK_PROGS([PROFMERGE],[profmerge])
250 AC_CHECK_PROGS([CODECOV], [codecov])
252 AC_MSG_ERROR([Intel compiler and coverage tools required for coverage report])
255 AM_CONDITIONAL(COV, [test "$enable_code_coverage" = yes])
258 GX_FC_CHECK_MOD([netcdf], [], [], [AC_MSG_ERROR([Can't find the netCDF Fortran module. Set CPPFLAGS/FCFLAGS])])
259 GX_FORTRAN_SEARCH_LIBS([nf90_create], [netcdff], [use netcdf], [iret = nf90_create('foo.nc', 1, ncid)], [],
260 [AC_MSG_ERROR([Can't find the netCDF Fortran library. Set LDFLAGS/LIBS])])
262 # Check if we get a floating point exception with netcdf
263 # this will only get triggered if you have FPE traps enabled via FCFLAGS
264 AC_MSG_CHECKING([if HDF5 version causes floating point exceptions with set flags])
265 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[
268 j = nf90_open("test.nc", NC_WRITE, i)
269 ]])], [hdf5_fpe_bug=no], [hdf5_fpe_bug=yes])
270 AC_MSG_RESULT([$hdf5_fpe_bug])
271 if test $hdf5_fpe_bug = yes; then
272 AC_MSG_ERROR([The HDF5 version used to build netcdf is incompatible with the set FCFLAGS. dnl
273 NetCDF must be built with a HDF5 version other than 1.14.3 to support floating point exception traps.])
277 # Check if Fortran compiler has the Class, Character array assign bug
278 GX_FC_CLASS_CHAR_ARRAY_BUG_CHECK()
280 # Check if Fortran compiler has Cray pointer support
281 GX_FC_CRAY_POINTER_FLAG()
283 # Check if Fortran compiler and system have quad precision support
284 GX_FC_QUAD_PRECISION()
286 # Check if Fortran compiler supports reading namelists from internal files
287 GX_FC_INTERNAL_FILE_NML()
289 # Check if the compiler needs special OpenMP flags
294 # We passed all the tests. Set the required defines.
295 if test $with_mpi = yes; then
296 AC_DEFINE([use_libMPI], [1], [This is required for the library to build])
299 # check if compiling old io
300 if test $enable_deprecated_io = yes; then
301 #If the test pass, define use_deprecated_io macro and skip it's unit tests
302 AC_DEFINE([use_deprecated_io], [1], [This is required to use mpp_io and fms_io modules])
303 # this macro was only removed from non-deprecated code so still needs to be set
304 AC_DEFINE([use_netCDF], [1], [This has been removed elsewhere but is still required to build with deprecated io])
305 AM_CONDITIONAL([SKIP_DEPRECATED_IO_TESTS], true)
307 AM_CONDITIONAL([SKIP_DEPRECATED_IO_TESTS], false)
310 # Builds with r8 default unless disable flag is given
311 if test $enable_r8_default = yes; then
312 AM_CONDITIONAL([SKIP_MOSAIC_TESTS], false)
314 AM_CONDITIONAL([SKIP_MOSAIC_TESTS], true)
317 # Set any required compile flags. This will not be done if the user wants to
318 # define all their own flags.
319 if test $enable_setting_flags = yes; then
320 # Make sure the compiler is seeing this as free-formatted, not
321 # fixed-formatted, fortran code.
324 # Check that long lines of Fortran code can be handled. This will add
325 # necessary fortran flags.
326 AC_FC_LINE_LENGTH([unlimited])
328 # Builds with r8 default unless disable flag is given
329 if test $enable_r8_default = yes; then
330 GX_FC_DEFAULT_REAL_KIND8_FLAG([dnl
331 FCFLAGS="$FCFLAGS $FC_DEFAULT_REAL_KIND8_FLAG"])
334 # individual mixed precision overloads
335 if test $enable_overload_c4 = yes; then
336 AC_DEFINE([OVERLOAD_C4], [1], [Set to overload with the C4 Fortran routines])
338 if test $enable_overload_c8 = yes; then
339 AC_DEFINE([OVERLOAD_C8], [1], [Set to overload with the C8 Fortran routines])
341 if test $enable_8byte_int = yes; then
342 AC_DEFINE([no_8byte_integers], [1], [Set to disable 8 byte integer Fortran routines])
345 # Add Cray Pointer support flag
346 if test ! -z "$FC_CRAY_POINTER_FLAG"; then
347 FCFLAGS="$FCFLAGS $FC_CRAY_POINTER_FLAG"
351 if test ! -z "$OPENMP_CFLAGS"; then
352 CFLAGS="$CFLAGS $OPENMP_CFLAGS"
353 CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
355 if test ! -z "$OPENMP_FCFLAGS"; then
356 FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS"
359 # Add code coverage flags
360 if test $enable_code_coverage = yes; then
361 FCFLAGS="$FCFLAGS -prof-gen=srcpos"
362 CFLAGS="$CFLAGS -prof-gen=srcpos"
365 if test $with_yaml = yes; then
366 LDFLAGS="$LDFLAGS -lyaml"
370 # Find which mpi launcher to use
371 AC_CHECK_PROGS([MPI_LAUNCHER],[srun aprun mpirun])
373 # Check if the launcher can oversubscribe the MPI processes
374 AS_IF([$MPI_LAUNCHER --oversubscribe hostname >/dev/null 2>&1], \
375 [ AC_SUBST([OVERSUBSCRIBE], [--oversubscribe])])
378 # Compiler with version information. This consists of the full path
379 # name of the compiler and the reported version number.
380 AC_SUBST([CC_VERSION])
381 # Strip anything that looks like a flag off of $CC
382 CC_NOFLAGS=`echo $CC | sed 's/ -.*//'`
384 if `echo $CC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
388 for x in `echo $PATH | sed -e 's/:/ /g'`; do
389 if test -x $x/$CC_NOFLAGS; then
395 if test -n "$cc_version_info"; then
396 CC_VERSION="$CC_VERSION ( $cc_version_info)"
399 AC_SUBST([FC_VERSION])
400 # Strip anything that looks like a flag off of $FC
401 FC_NOFLAGS=`echo $FC | sed 's/ -.*//'`
403 if `echo $FC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
407 for x in `echo $PATH | sed -e 's/:/ /g'`; do
408 if test -x $x/$FC_NOFLAGS; then
414 if test -n "$fc_version_info"; then
415 FC_VERSION="$FC_VERSION ( $fc_version_info )"
418 # Check if gcc is 11.1 for class(*) select type bug
419 AC_MSG_CHECKING([if using gcc 11.1.0])
420 if [ test -n "`$FC --version | grep GNU | grep 11\.1\..`" ]; then
422 AC_MSG_ERROR([Compilation with gcc and gfortran 11.1.0 is unsupported \
423 by this version of FMS due to a bug in the compiler. Please use a different version of gcc/gfortran.])
429 # Create output variables from various
430 # shell variables, for use in generating
431 # libnetcdf.settings.
433 AC_SUBST([enable_shared])
434 AC_SUBST([enable_static])
438 AC_SUBST([AM_CFLAGS])
439 AC_SUBST([AM_CPPFLAGS])
440 AC_SUBST([AM_LDFLAGS])
441 AC_SUBST([NOUNDEFINED])
443 # Define the directory where *.mod files will reside.
445 AC_SUBST([MODDIR],[\$\(top_builddir\)/.mods])
447 # These files will be created when the configure script is run.
453 time_manager/Makefile
461 tracer_manager/Makefile
465 monin_obukhov/Makefile
467 interpolator/Makefile
468 horiz_interp/Makefile
469 field_manager/Makefile
472 diag_manager/Makefile
473 data_override/Makefile
474 column_diagnostics/Makefile
475 block_control/Makefile
479 diag_integral/Makefile
480 sat_vapor_pres/Makefile
481 random_numbers/Makefile
485 string_utils/Makefile
487 test_fms/intel_coverage.sh
489 test_fms/astronomy/Makefile
490 test_fms/diag_manager/Makefile
491 test_fms/data_override/Makefile
492 test_fms/exchange/Makefile
493 test_fms/monin_obukhov/Makefile
494 test_fms/drifters/Makefile
495 test_fms/interpolator/Makefile
496 test_fms/fms2_io/Makefile
497 test_fms/fms/Makefile
498 test_fms/mpp/Makefile
499 test_fms/mpp_io/Makefile
500 test_fms/time_interp/Makefile
501 test_fms/time_manager/Makefile
502 test_fms/horiz_interp/Makefile
503 test_fms/field_manager/Makefile
504 test_fms/axis_utils/Makefile
505 test_fms/mosaic2/Makefile
506 test_fms/affinity/Makefile
507 test_fms/coupler/Makefile
508 test_fms/parser/Makefile
509 test_fms/string_utils/Makefile
510 test_fms/tridiagonal/Makefile
511 test_fms/sat_vapor_pres/Makefile
512 test_fms/diag_integral/Makefile
513 test_fms/tracer_manager/Makefile
514 test_fms/random_numbers/Makefile
515 test_fms/topography/Makefile
516 test_fms/column_diagnostics/Makefile