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 AC_ARG_ENABLE([portable-kinds],
116 [AS_HELP_STRING([--enable-portable-kinds],
117 [Enables compilation with -DPORTABLE_KINDS with iso_c_binding KIND type parameters])])
118 AS_IF([test ${enable_portable_kinds:-no} = yes],
119 [enable_portable_kinds=yes],
120 [enable_portable_kinds=no])
122 # user enabled testing with input files
123 AC_MSG_CHECKING([whether to enable tests with input files])
124 AC_ARG_ENABLE([test-input],
125 [AS_HELP_STRING([--enable-test-input="path/to/input"],
126 [Enable tests using input netcdf files, if present in the given full directory.])])
127 AC_MSG_RESULT([$enable_test_input])
129 # require path to be given
130 AS_IF([test "x$enable_test_input" = "xyes"],
131 [AC_MSG_ERROR([Test input enabled, but no directory given with --enable-test-input=/path])],
132 [AS_IF([test "x$enable_test_input" != "xno"],
133 [TEST_INPUT_PATH="$enable_test_input"],[])]
136 # if set, check directory exists
137 AS_IF([test "$TEST_INPUT_PATH" = ""],
139 [AS_IF([test -d $TEST_INPUT_PATH],[],
140 [AC_MSG_ERROR([Test input enabled, but directory $TEST_INPUT_PATH not found]) ]
143 # substitute path for input
144 AC_SUBST([TEST_INPUT_PATH])
146 # Does the user want to build documentation?
147 AC_MSG_CHECKING([whether documentation should be built (requires doxygen)])
148 AC_ARG_ENABLE([docs],
149 [AS_HELP_STRING([--enable-docs],
150 [enable building of documentation with doxygen.])])
151 test "x$enable_docs" = xyes || enable_docs=no
152 AC_MSG_RESULT([$enable_docs])
153 AM_CONDITIONAL(BUILD_DOCS, [test "x$enable_docs" = xyes])
155 # Is doxygen installed?
156 AC_CHECK_PROGS([DOXYGEN], [doxygen])
157 if test -z "$DOXYGEN" -a "x$enable_docs" = xyes; then
158 AC_MSG_ERROR([Doxygen not found but --enable-docs used.])
161 # If building docs, process Doxyfile.in into Doxyfile.
162 if test "x$enable_docs" = xyes; then
163 AC_CONFIG_FILES([docs/Doxyfile])
166 # Find the C compiler.
172 # Find the Fortran compiler.
175 AC_FC_MODULE_EXTENSION
176 AC_FC_MODULE_OUTPUT_FLAG
178 # Find the install program.
181 # Check to see if any macros must be set to enable large (>2GB) files.
186 if test $with_mpi = yes; then
188 # We expect users to set CC and FC to MPI compiler wrappers, or that the correct
189 # CPPFLAGS, {C,FC}FLAGS, LDFLAGS and LIBS options are given.
194 if test $with_yaml = yes; then
195 AC_CHECK_HEADERS([yaml.h], [], [AC_MSG_ERROR(["Can't find the libYAML C header file. Set CC/CPPFLAGS/CFLAGS"])])
196 AC_SEARCH_LIBS([yaml_parser_initialize], [yaml], [], [AC_MSG_ERROR(["Can't find the libYAML C library. Set CC/LDFLAGS/LIBS"])])
198 #If the test pass, define use_yaml macro
199 AC_DEFINE([use_yaml], [1], [This is required to use yaml parser])
201 AM_CONDITIONAL([USING_YAML], true)
203 AM_CONDITIONAL([USING_YAML], false)
207 AC_CHECK_HEADERS([netcdf.h], [], [AC_MSG_ERROR([Can't find the netCDF C header file. Set CPPFLAGS/CFLAGS])])
208 AC_SEARCH_LIBS([nc_create], [netcdf], [], [AC_MSG_ERROR([Can't find the netCDF C library. Set LDFLAGS/LIBS])])
210 # Require netCDF-4 (with HDF5).
211 AC_MSG_CHECKING([if netCDF was built with HDF5])
212 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
213 #include <netcdf_meta.h>
215 #endif]])], [nc_has_nc4=yes], [nc_has_nc4=no])
216 AC_MSG_RESULT([$nc_has_nc4])
217 if test $nc_has_nc4 = no; then
218 AC_MSG_ERROR([NetCDF must be built with HDF5.])
221 # Check if ncdump is avaiable
222 AC_CHECK_PROG([USE_NCDUMP],[ncdump], [yes], [no])
223 if test $USE_NCDUMP = yes; then
224 AM_CONDITIONAL([SKIP_NCDUMP_CHECKS], true )
226 AM_CONDITIONAL([SKIP_NCDUMP_CHECKS], false )
229 # Check if Linux gettid is avaiable
230 AC_CHECK_FUNCS([gettid], [], [])
232 # Check if Linux sched_getaffinity is available
233 AC_CHECK_FUNCS([sched_getaffinity], [], [])
235 # Check if the compiler needs special OpenMP flags
239 # Fortran specific checks
240 AC_LANG_PUSH(Fortran)
241 if test $with_mpi = yes; then
244 GX_MPI_FC_LEGACY_INTERFACE()
245 # Determine if a flag is required to allow external procedure argument mismatch when
246 # an explicit interface does not exist
247 if test ! -z "$HAVE_MPI_FC_LEGACY"; then
248 GX_FC_ALLOW_ARG_MISMATCH([dnl
249 FCFLAGS="$FCFLAGS $FC_ALLOW_ARG_MISMATCH_FLAG"])
253 # check intel compiler and coverage tools are avaiable if code coverage is enabled
254 if test "$enable_code_coverage" = yes; then
255 if test ! -z "`$FC --version | grep ifort`"; then
256 AC_CHECK_PROGS([PROFMERGE],[profmerge])
257 AC_CHECK_PROGS([CODECOV], [codecov])
259 AC_MSG_ERROR([Intel compiler and coverage tools required for coverage report])
262 AM_CONDITIONAL(COV, [test "$enable_code_coverage" = yes])
265 GX_FC_CHECK_MOD([netcdf], [], [], [AC_MSG_ERROR([Can't find the netCDF Fortran module. Set CPPFLAGS/FCFLAGS])])
266 GX_FORTRAN_SEARCH_LIBS([nf90_create], [netcdff], [use netcdf], [iret = nf90_create('foo.nc', 1, ncid)], [],
267 [AC_MSG_ERROR([Can't find the netCDF Fortran library. Set LDFLAGS/LIBS])])
269 # Check if we get a floating point exception with netcdf
270 # this will only get triggered if you have FPE traps enabled via FCFLAGS
271 AC_MSG_CHECKING([if HDF5 version causes floating point exceptions with set flags])
272 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[
275 j = nf90_create("test.nc", NC_WRITE, i)
276 ]])], [hdf5_fpe_bug=no], [hdf5_fpe_bug=yes])
277 AC_MSG_RESULT([$hdf5_fpe_bug])
278 if test $hdf5_fpe_bug = yes; then
279 AC_MSG_ERROR([The HDF5 version used to build netcdf is incompatible with the set FCFLAGS. dnl
280 NetCDF must be built with a HDF5 version other than 1.14.3 to support floating point exception traps.])
285 # Check if we need a flag to not capitalize module output (needed with cray compiler)
286 GX_FC_MOD_CASE_FLAG([FCFLAGS="$FCFLAGS $FC_MOD_CASE_FLAG"])
288 # Check if new unit is supported
289 GX_FC_08_OPEN_NEWUNIT([], [AC_MSG_ERROR([Compiler support for use of newunit argument is required to build FMS])])
291 # Check if Fortran compiler has the Class, Character array assign bug
292 GX_FC_CLASS_CHAR_ARRAY_BUG_CHECK()
294 # Check if Fortran compiler has Cray pointer support
295 GX_FC_CRAY_POINTER_FLAG()
297 # Check if Fortran compiler and system have quad precision support
298 GX_FC_QUAD_PRECISION()
300 # Check if Fortran compiler supports reading namelists from internal files
301 GX_FC_INTERNAL_FILE_NML()
303 # Check if the compiler needs special OpenMP flags
308 # We passed all the tests. Set the required defines.
309 if test $with_mpi = yes; then
310 AC_DEFINE([use_libMPI], [1], [This is required for the library to build])
313 # check if compiling old io
314 if test $enable_deprecated_io = yes; then
315 #If the test pass, define use_deprecated_io macro and skip it's unit tests
316 AC_DEFINE([use_deprecated_io], [1], [This is required to use mpp_io and fms_io modules])
317 # this macro was only removed from non-deprecated code so still needs to be set
318 AC_DEFINE([use_netCDF], [1], [This has been removed elsewhere but is still required to build with deprecated io])
319 AM_CONDITIONAL([SKIP_DEPRECATED_IO_TESTS], true)
321 AM_CONDITIONAL([SKIP_DEPRECATED_IO_TESTS], false)
324 # Builds with r8 default unless disable flag is given
325 if test $enable_r8_default = yes; then
326 AM_CONDITIONAL([SKIP_MOSAIC_TESTS], false)
328 AM_CONDITIONAL([SKIP_MOSAIC_TESTS], true)
331 # Set any required compile flags. This will not be done if the user wants to
332 # define all their own flags.
333 if test $enable_setting_flags = yes; then
334 # Make sure the compiler is seeing this as free-formatted, not
335 # fixed-formatted, fortran code.
338 # Check that long lines of Fortran code can be handled. This will add
339 # necessary fortran flags.
340 AC_FC_LINE_LENGTH([unlimited])
342 # Builds with r8 default unless disable flag is given
343 if test $enable_r8_default = yes; then
344 GX_FC_DEFAULT_REAL_KIND8_FLAG([dnl
345 FCFLAGS="$FCFLAGS $FC_DEFAULT_REAL_KIND8_FLAG"])
348 # individual mixed precision overloads
349 if test $enable_overload_c4 = yes; then
350 AC_DEFINE([OVERLOAD_C4], [1], [Set to overload with the C4 Fortran routines])
352 if test $enable_overload_c8 = yes; then
353 AC_DEFINE([OVERLOAD_C8], [1], [Set to overload with the C8 Fortran routines])
355 if test $enable_8byte_int = yes; then
356 AC_DEFINE([no_8byte_integers], [1], [Set to disable 8 byte integer Fortran routines])
359 # Builds with C data types
360 if test $enable_portable_kinds = yes; then
361 AC_DEFINE([PORTABLE_KINDS], [1], [Set to define KIND parameters to iso_c_binding KIND parameters])
364 # Add Cray Pointer support flag
365 if test ! -z "$FC_CRAY_POINTER_FLAG"; then
366 FCFLAGS="$FCFLAGS $FC_CRAY_POINTER_FLAG"
370 if test ! -z "$OPENMP_CFLAGS"; then
371 CFLAGS="$CFLAGS $OPENMP_CFLAGS"
372 CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
374 if test ! -z "$OPENMP_FCFLAGS"; then
375 FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS"
378 # Add code coverage flags
379 if test $enable_code_coverage = yes; then
380 FCFLAGS="$FCFLAGS -prof-gen=srcpos"
381 CFLAGS="$CFLAGS -prof-gen=srcpos"
384 if test $with_yaml = yes; then
385 LDFLAGS="$LDFLAGS -lyaml"
389 # Find which mpi launcher to use
390 AC_CHECK_PROGS([MPI_LAUNCHER],[srun aprun mpirun])
392 # Check if the launcher can oversubscribe the MPI processes
393 AS_IF([$MPI_LAUNCHER --oversubscribe hostname >/dev/null 2>&1], \
394 [ AC_SUBST([OVERSUBSCRIBE], [--oversubscribe])])
397 # Compiler with version information. This consists of the full path
398 # name of the compiler and the reported version number.
399 AC_SUBST([CC_VERSION])
400 # Strip anything that looks like a flag off of $CC
401 CC_NOFLAGS=`echo $CC | sed 's/ -.*//'`
403 if `echo $CC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
407 for x in `echo $PATH | sed -e 's/:/ /g'`; do
408 if test -x $x/$CC_NOFLAGS; then
414 if test -n "$cc_version_info"; then
415 CC_VERSION="$CC_VERSION ( $cc_version_info)"
418 AC_SUBST([FC_VERSION])
419 # Strip anything that looks like a flag off of $FC
420 FC_NOFLAGS=`echo $FC | sed 's/ -.*//'`
422 if `echo $FC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
426 for x in `echo $PATH | sed -e 's/:/ /g'`; do
427 if test -x $x/$FC_NOFLAGS; then
433 if test -n "$fc_version_info"; then
434 FC_VERSION="$FC_VERSION ( $fc_version_info )"
437 # Check if gcc is 11.1 for class(*) select type bug
438 AC_MSG_CHECKING([if using gcc 11.1.0])
439 if [ test -n "`$FC --version | grep GNU | grep 11\.1\..`" ]; then
441 AC_MSG_ERROR([Compilation with gcc and gfortran 11.1.0 is unsupported \
442 by this version of FMS due to a bug in the compiler. Please use a different version of gcc/gfortran.])
448 # Create output variables from various
449 # shell variables, for use in generating
450 # libnetcdf.settings.
452 AC_SUBST([enable_shared])
453 AC_SUBST([enable_static])
457 AC_SUBST([AM_CFLAGS])
458 AC_SUBST([AM_CPPFLAGS])
459 AC_SUBST([AM_LDFLAGS])
460 AC_SUBST([NOUNDEFINED])
462 # Define the directory where *.mod files will reside.
464 AC_SUBST([MODDIR],[\$\(top_builddir\)/.mods])
466 # These files will be created when the configure script is run.
472 time_manager/Makefile
480 tracer_manager/Makefile
484 monin_obukhov/Makefile
486 interpolator/Makefile
487 horiz_interp/Makefile
488 field_manager/Makefile
491 diag_manager/Makefile
492 data_override/Makefile
493 column_diagnostics/Makefile
494 block_control/Makefile
498 diag_integral/Makefile
499 sat_vapor_pres/Makefile
500 random_numbers/Makefile
504 string_utils/Makefile
506 test_fms/intel_coverage.sh
508 test_fms/astronomy/Makefile
509 test_fms/diag_manager/Makefile
510 test_fms/data_override/Makefile
511 test_fms/exchange/Makefile
512 test_fms/monin_obukhov/Makefile
513 test_fms/drifters/Makefile
514 test_fms/interpolator/Makefile
515 test_fms/fms2_io/Makefile
516 test_fms/fms/Makefile
517 test_fms/mpp/Makefile
518 test_fms/mpp_io/Makefile
519 test_fms/time_interp/Makefile
520 test_fms/time_manager/Makefile
521 test_fms/horiz_interp/Makefile
522 test_fms/field_manager/Makefile
523 test_fms/axis_utils/Makefile
524 test_fms/mosaic2/Makefile
525 test_fms/affinity/Makefile
526 test_fms/coupler/Makefile
527 test_fms/parser/Makefile
528 test_fms/string_utils/Makefile
529 test_fms/tridiagonal/Makefile
530 test_fms/sat_vapor_pres/Makefile
531 test_fms/diag_integral/Makefile
532 test_fms/tracer_manager/Makefile
533 test_fms/random_numbers/Makefile
534 test_fms/topography/Makefile
535 test_fms/column_diagnostics/Makefile
536 test_fms/block_control/Makefile
542 if test $enable_deprecated_io = yes; then
543 AC_MSG_WARN(FMS_IO WILL BE DEPRECATED IN A FUTURE RLEASE. PLEASE UPDATE TO USE FMS2_IO AND REMOVE --enable-deprecated-io FROM YOUR CONFIGURE OPTIONS)