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.
57 AC_ARG_ENABLE([mixed-mode],
58 [AS_HELP_STRING([--enable-mixed-mode],
59 [Build using mixed mode. Enables both 64-bit and 32-bit reals in Fortran. This option will be ignored if --disable-fortran-flag-setting is also given.])])
60 AS_IF([test ${enable_mixed_mode:-no} = no],
61 [enable_mixed_mode=no],
62 [enable_mixed_mode=yes])
64 [AS_HELP_STRING([--with-mpi],
65 [Build with MPI support. This option will be ignored if --disable-fortran-flag-setting is also given. (Default yes)])])
66 AS_IF([test ${with_mpi:-yes} = yes],
70 [AS_HELP_STRING([--with-yaml],
71 [Build with YAML support. This option will be ignored if --disable-fortran-flag-setting is also given. (Default no)])])
72 AS_IF([test ${with_yaml:-no} = no],
75 AC_ARG_ENABLE([setting-flags],
76 [AS_HELP_STRING([--enable-setting-flags],
77 [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)])])
78 AS_IF([test ${enable_setting_flags:-yes} = yes],
79 [enable_setting_flags=yes],
80 [enable_setting_flags=no])
81 AC_ARG_ENABLE([code-coverage],
82 [AS_HELP_STRING([--enable-code-coverage],
83 [Allow configure to set flags and add check-code-coverage target for code coverage analysis (Default no)])])
84 AS_IF([test ${enable_code_coverage:-no} = no],
85 [enable_code_coverage=no],
86 [enable_code_coverage=yes])
87 # individual mixed precision overload macros
88 AC_ARG_ENABLE([overload-r4],
89 [AS_HELP_STRING([--enable-overload-r4],
90 [Enables the OVERLOAD_R4 macro to compile with 4 byte real routine overloads. (Default no)])])
91 AS_IF([test ${enable_overload_r4:-no} = yes],
92 [enable_overload_r4=yes],
93 [enable_overload_r4=no])
94 AC_ARG_ENABLE([overload-c4],
95 [AS_HELP_STRING([--enable-overload-c4],
96 [Enables the OVERLOAD_C4 macro to compile with 4 byte complex routine overloads. (Default no)])])
97 AS_IF([test ${enable_overload_c4:-no} = yes],
98 [enable_overload_c4=yes],
99 [enable_overload_c4=no])
100 AC_ARG_ENABLE([overload-c8],
101 [AS_HELP_STRING([--enable-overload-c8],
102 [Enables the OVERLOAD_C8 macro to compile with 8 byte real routine overloads. (Default no)])])
103 AS_IF([test ${enable_overload_c8:-no} = yes],
104 [enable_overload_c8=yes],
105 [enable_overload_c8=no])
106 AC_ARG_ENABLE([8byte-int],
107 [AS_HELP_STRING([--disable-8byte-int],
108 [Enables the no_8byte_integers macro to compile with only 4 byte integer routines. (Default no)])])
109 AS_IF([test ${enable_8byte_int:-no} = yes],
110 [enable_8byte_int=yes],
111 [enable_8byte_int=no])
113 # user enabled testing with input files
114 AC_MSG_CHECKING([whether to enable tests with input files])
115 AC_ARG_ENABLE([test-input],
116 [AS_HELP_STRING([--enable-test-input="path/to/input"],
117 [Enable tests using input netcdf files, if present in the given full directory.])])
118 AC_MSG_RESULT([$enable_test_input])
120 # require path to be given
121 AS_IF([test "x$enable_test_input" = "xyes"],
122 [AC_MSG_ERROR([Test input enabled, but no directory given with --enable-test-input=/path])],
123 [AS_IF([test "x$enable_test_input" != "xno"],
124 [TEST_INPUT_PATH="$enable_test_input"],[])]
127 # if set, check directory exists
128 AS_IF([test "$TEST_INPUT_PATH" = ""],
130 [AS_IF([test -d $TEST_INPUT_PATH],[],
131 [AC_MSG_ERROR([Test input enabled, but directory $TEST_INPUT_PATH not found]) ]
134 # substitute path for input
135 AC_SUBST([TEST_INPUT_PATH])
137 # Does the user want to build documentation?
138 AC_MSG_CHECKING([whether documentation should be built (requires doxygen)])
139 AC_ARG_ENABLE([docs],
140 [AS_HELP_STRING([--enable-docs],
141 [enable building of documentation with doxygen.])])
142 test "x$enable_docs" = xyes || enable_docs=no
143 AC_MSG_RESULT([$enable_docs])
144 AM_CONDITIONAL(BUILD_DOCS, [test "x$enable_docs" = xyes])
146 # Is doxygen installed?
147 AC_CHECK_PROGS([DOXYGEN], [doxygen])
148 if test -z "$DOXYGEN" -a "x$enable_docs" = xyes; then
149 AC_MSG_ERROR([Doxygen not found but --enable-docs used.])
152 # If building docs, process Doxyfile.in into Doxyfile.
153 if test "x$enable_docs" = xyes; then
154 AC_CONFIG_FILES([docs/Doxyfile])
157 # Find the C compiler.
163 # Find the Fortran compiler.
166 AC_FC_MODULE_EXTENSION
167 AC_FC_MODULE_OUTPUT_FLAG
169 # Find the install program.
172 # Check to see if any macros must be set to enable large (>2GB) files.
177 if test $with_mpi = yes; then
179 # We expect users to set CC and FC to MPI compiler wrappers, or that the correct
180 # CPPFLAGS, {C,FC}FLAGS, LDFLAGS and LIBS options are given.
185 if test $with_yaml = yes; then
186 AC_CHECK_HEADERS([yaml.h], [], [AC_MSG_ERROR(["Can't find the libYAML C header file. Set CC/CPPFLAGS/CFLAGS"])])
187 AC_SEARCH_LIBS([yaml_parser_initialize], [yaml], [], [AC_MSG_ERROR(["Can't find the libYAML C library. Set CC/LDFLAGS/LIBS"])])
189 #If the test pass, define use_yaml macro
190 AC_DEFINE([use_yaml], [1], [This is required to use yaml parser])
192 AM_CONDITIONAL([SKIP_PARSER_TESTS], false )
194 AM_CONDITIONAL([SKIP_PARSER_TESTS], true )
198 AC_CHECK_HEADERS([netcdf.h], [], [AC_MSG_ERROR([Can't find the netCDF C header file. Set CPPFLAGS/CFLAGS])])
199 AC_SEARCH_LIBS([nc_create], [netcdf], [], [AC_MSG_ERROR([Can't find the netCDF C library. Set LDFLAGS/LIBS])])
201 # Require netCDF-4 (with HDF5).
202 AC_MSG_CHECKING([if netCDF was built with HDF5])
203 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
204 #include <netcdf_meta.h>
207 #endif]])], [nc_has_nc4=yes], [nc_has_nc4=no])
208 AC_MSG_RESULT([$nc_has_nc4])
209 if test $nc_has_nc4 = no; then
210 AC_MSG_ERROR([NetCDF must be built with HDF5.])
213 # Check if ncdump is avaiable
214 AC_CHECK_PROG([USE_NCDUMP],[ncdump], [yes], [no])
215 if test $USE_NCDUMP = yes; then
216 AM_CONDITIONAL([SKIP_NCDUMP_CHECKS], true )
218 AM_CONDITIONAL([SKIP_NCDUMP_CHECKS], false )
221 # Check if Linux gettid is avaiable
222 AC_CHECK_FUNCS([gettid], [], [])
224 # Check if Linux sched_getaffinity is available
225 AC_CHECK_FUNCS([sched_getaffinity], [], [])
227 # Check if the compiler needs special OpenMP flags
231 # Fortran specific checks
232 AC_LANG_PUSH(Fortran)
233 if test $with_mpi = yes; then
236 GX_MPI_FC_LEGACY_INTERFACE()
237 # Determine if a flag is required to allow external procedure argument mismatch when
238 # an explicit interface does not exist
239 if test ! -z "$HAVE_MPI_FC_LEGACY"; then
240 GX_FC_ALLOW_ARG_MISMATCH([dnl
241 FCFLAGS="$FCFLAGS $FC_ALLOW_ARG_MISMATCH_FLAG"])
245 # check intel compiler and coverage tools are avaiable if code coverage is enabled
246 if test "$enable_code_coverage" = yes; then
247 if test ! -z "`$FC --version | grep ifort`"; then
248 AC_CHECK_PROGS([PROFMERGE],[profmerge])
249 AC_CHECK_PROGS([CODECOV], [codecov])
251 AC_MSG_ERROR([Intel compiler and coverage tools required for coverage report])
254 AM_CONDITIONAL(COV, [test "$enable_code_coverage" = yes])
257 GX_FC_CHECK_MOD([netcdf], [], [], [AC_MSG_ERROR([Can't find the netCDF Fortran module. Set CPPFLAGS/FCFLAGS])])
258 GX_FORTRAN_SEARCH_LIBS([nf90_create], [netcdff], [use netcdf], [iret = nf90_create('foo.nc', 1, ncid)], [],
259 [AC_MSG_ERROR([Can't find the netCDF Fortran library. Set LDFLAGS/LIBS])])
261 # Check if Fortran compiler has the Class, Character array assign bug
262 GX_FC_CLASS_CHAR_ARRAY_BUG_CHECK()
264 # Check if Fortran compiler has Cray pointer support
265 GX_FC_CRAY_POINTER_FLAG()
267 # Check if Fortran compiler and system have quad precision support
268 GX_FC_QUAD_PRECISION()
270 # Check if Fortran compiler supports reading namelists from internal files
271 GX_FC_INTERNAL_FILE_NML()
273 # Check if the compiler needs special OpenMP flags
278 # We passed all the tests. Set the required defines.
279 AC_DEFINE([use_netCDF], [1], [This is required for the library to build])
280 if test $with_mpi = yes; then
281 AC_DEFINE([use_libMPI], [1], [This is required for the library to build])
284 # Set any required compile flags. This will not be done if the user wants to
285 # define all their own flags.
286 if test $enable_setting_flags = yes; then
287 # Make sure the compiler is seeing this as free-formatted, not
288 # fixed-formatted, fortran code.
291 # Check that long lines of Fortran code can be handled. This will add
292 # necessary fortran flags.
293 AC_FC_LINE_LENGTH([unlimited])
295 # Will we build with default 64-bit reals in Fortran, or do mixed mode?
296 if test $enable_mixed_mode = yes; then
297 GX_FC_DEFAULT_REAL_KIND4_FLAG([dnl
298 FCFLAGS="$FCFLAGS $FC_DEFAULT_REAL_KIND8_FLAG"])
299 AC_DEFINE([OVERLOAD_R4], [1], [Set to overload the R4 Fortran routines])
300 AC_DEFINE([OVERLOAD_R8], [1], [Set to overload the R8 Fortran routines])
302 GX_FC_DEFAULT_REAL_KIND8_FLAG([dnl
303 FCFLAGS="$FCFLAGS $FC_DEFAULT_REAL_KIND8_FLAG"])
305 # individual mixed precision overloads
306 if test $enable_overload_r4 = yes; then
307 AC_DEFINE([OVERLOAD_R4], [1], [Set to overload with the R4 Fortran routines])
309 if test $enable_overload_c4 = yes; then
310 AC_DEFINE([OVERLOAD_C4], [1], [Set to overload with the C4 Fortran routines])
312 if test $enable_overload_c8 = yes; then
313 AC_DEFINE([OVERLOAD_C8], [1], [Set to overload with the C8 Fortran routines])
315 if test $enable_8byte_int = yes; then
316 AC_DEFINE([no_8byte_integers], [1], [Set to disable 8 byte integer Fortran routines])
319 # Add Cray Pointer support flag
320 if test ! -z "$FC_CRAY_POINTER_FLAG"; then
321 FCFLAGS="$FCFLAGS $FC_CRAY_POINTER_FLAG"
325 if test ! -z "$OPENMP_CFLAGS"; then
326 CFLAGS="$CFLAGS $OPENMP_CFLAGS"
327 CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
329 if test ! -z "$OPENMP_FCFLAGS"; then
330 FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS"
333 # Add code coverage flags
334 if test $enable_code_coverage = yes; then
335 FCFLAGS="$FCFLAGS -prof-gen=srcpos"
336 CFLAGS="$CFLAGS -prof-gen=srcpos"
339 if test $with_yaml = yes; then
340 LDFLAGS="$LDFLAGS -lyaml"
344 # Find which mpi launcher to use
345 AC_CHECK_PROGS([MPI_LAUNCHER],[srun aprun mpirun])
347 # Check if the launcher can oversubscribe the MPI processes
348 AS_IF([$MPI_LAUNCHER --oversubscribe hostname >/dev/null 2>&1], \
349 [ AC_SUBST([OVERSUBSCRIBE], [--oversubscribe])])
352 # Compiler with version information. This consists of the full path
353 # name of the compiler and the reported version number.
354 AC_SUBST([CC_VERSION])
355 # Strip anything that looks like a flag off of $CC
356 CC_NOFLAGS=`echo $CC | sed 's/ -.*//'`
358 if `echo $CC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
362 for x in `echo $PATH | sed -e 's/:/ /g'`; do
363 if test -x $x/$CC_NOFLAGS; then
369 if test -n "$cc_version_info"; then
370 CC_VERSION="$CC_VERSION ( $cc_version_info)"
373 AC_SUBST([FC_VERSION])
374 # Strip anything that looks like a flag off of $FC
375 FC_NOFLAGS=`echo $FC | sed 's/ -.*//'`
377 if `echo $FC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
381 for x in `echo $PATH | sed -e 's/:/ /g'`; do
382 if test -x $x/$FC_NOFLAGS; then
388 if test -n "$fc_version_info"; then
389 FC_VERSION="$FC_VERSION ( $fc_version_info )"
392 # Check if gcc is 11.1 for class(*) select type bug
393 AC_MSG_CHECKING([if using gcc 11.1.0])
394 if [ test -n "`$FC --version | grep GNU | grep 11\.1\..`" ]; then
396 AC_MSG_ERROR([Compilation with gcc and gfortran 11.1.0 is unsupported \
397 by this version of FMS due to a bug in the compiler. Please use a different version of gcc/gfortran.])
403 # Create output variables from various
404 # shell variables, for use in generating
405 # libnetcdf.settings.
407 AC_SUBST([enable_shared])
408 AC_SUBST([enable_static])
412 AC_SUBST([AM_CFLAGS])
413 AC_SUBST([AM_CPPFLAGS])
414 AC_SUBST([AM_LDFLAGS])
415 AC_SUBST([NOUNDEFINED])
417 # Define the directory where *.mod files will reside.
419 AC_SUBST([MODDIR],[\$\(top_builddir\)/.mods])
421 # These files will be created when the configure script is run.
427 time_manager/Makefile
435 tracer_manager/Makefile
439 monin_obukhov/Makefile
441 interpolator/Makefile
442 horiz_interp/Makefile
443 field_manager/Makefile
446 diag_manager/Makefile
447 data_override/Makefile
448 column_diagnostics/Makefile
449 block_control/Makefile
453 diag_integral/Makefile
454 sat_vapor_pres/Makefile
455 random_numbers/Makefile
459 string_utils/Makefile
461 test_fms/intel_coverage.sh
463 test_fms/diag_manager/Makefile
464 test_fms/data_override/Makefile
465 test_fms/exchange/Makefile
466 test_fms/monin_obukhov/Makefile
467 test_fms/drifters/Makefile
468 test_fms/interpolator/Makefile
469 test_fms/fms2_io/Makefile
470 test_fms/fms/Makefile
471 test_fms/mpp/Makefile
472 test_fms/mpp_io/Makefile
473 test_fms/time_interp/Makefile
474 test_fms/time_manager/Makefile
475 test_fms/horiz_interp/Makefile
476 test_fms/field_manager/Makefile
477 test_fms/axis_utils/Makefile
478 test_fms/mosaic/Makefile
479 test_fms/affinity/Makefile
480 test_fms/coupler/Makefile
481 test_fms/parser/Makefile
482 test_fms/string_utils/Makefile