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])
43 AC_REQUIRE_AUX_FILE([tap-driver.sh])
49 # If building on a Cray PE system, check if CRAYPE_LINK_TYPE is 'static'. If it
50 # is, then disable building shared libraries. Note, the user can still override
51 # this by using --enable-shared when running the configure script.
52 AS_IF([test x${CRAYPE_VERSION:+yes} = "xyes"],[
53 AS_IF([test x${CRAYPE_LINK_TYPE} = "xstatic"],
54 [AC_DISABLE_SHARED])])
57 # Process user optons.
58 AC_ARG_ENABLE([mixed-mode],
59 [AS_HELP_STRING([--enable-mixed-mode],
60 [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.])])
61 AS_IF([test ${enable_mixed_mode:-no} = no],
62 [enable_mixed_mode=no],
63 [enable_mixed_mode=yes])
65 [AS_HELP_STRING([--with-mpi],
66 [Build with MPI support. This option will be ignored if --disable-fortran-flag-setting is also given. (Default yes)])])
67 AS_IF([test ${with_mpi:-yes} = yes],
71 [AS_HELP_STRING([--with-yaml],
72 [Build with YAML support. This option will be ignored if --disable-fortran-flag-setting is also given. (Default no)])])
73 AS_IF([test ${with_yaml:-no} = no],
76 AC_ARG_ENABLE([setting-flags],
77 [AS_HELP_STRING([--enable-setting-flags],
78 [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)])])
79 AS_IF([test ${enable_setting_flags:-yes} = yes],
80 [enable_setting_flags=yes],
81 [enable_setting_flags=no])
82 AC_ARG_ENABLE([code-coverage],
83 [AS_HELP_STRING([--enable-code-coverage],
84 [Allow configure to set flags and add check-code-coverage target for code coverage analysis (Default no)])])
85 AS_IF([test ${enable_code_coverage:-no} = no],
86 [enable_code_coverage=no],
87 [enable_code_coverage=yes])
88 # individual mixed precision overload macros
89 AC_ARG_ENABLE([overload-r4],
90 [AS_HELP_STRING([--enable-overload-r4],
91 [Enables the OVERLOAD_R4 macro to compile with 4 byte real routine overloads. (Default no)])])
92 AS_IF([test ${enable_overload_r4:-no} = yes],
93 [enable_overload_r4=yes],
94 [enable_overload_r4=no])
95 AC_ARG_ENABLE([overload-c4],
96 [AS_HELP_STRING([--enable-overload-c4],
97 [Enables the OVERLOAD_C4 macro to compile with 4 byte complex routine overloads. (Default no)])])
98 AS_IF([test ${enable_overload_c4:-no} = yes],
99 [enable_overload_c4=yes],
100 [enable_overload_c4=no])
101 AC_ARG_ENABLE([overload-c8],
102 [AS_HELP_STRING([--enable-overload-c8],
103 [Enables the OVERLOAD_C8 macro to compile with 8 byte real routine overloads. (Default no)])])
104 AS_IF([test ${enable_overload_c8:-no} = yes],
105 [enable_overload_c8=yes],
106 [enable_overload_c8=no])
107 AC_ARG_ENABLE([8byte-int],
108 [AS_HELP_STRING([--disable-8byte-int],
109 [Enables the no_8byte_integers macro to compile with only 4 byte integer routines. (Default no)])])
110 AS_IF([test ${enable_8byte_int:-no} = yes],
111 [enable_8byte_int=yes],
112 [enable_8byte_int=no])
114 # user enabled testing with input files
115 AC_MSG_CHECKING([whether to enable tests with input files])
116 AC_ARG_ENABLE([test-input],
117 [AS_HELP_STRING([--enable-test-input="path/to/input"],
118 [Enable tests using input netcdf files, if present in the given full directory.])])
119 AC_MSG_RESULT([$enable_test_input])
121 # require path to be given
122 AS_IF([test "x$enable_test_input" = "xyes"],
123 [AC_MSG_ERROR([Test input enabled, but no directory given with --enable-test-input=/path])],
124 [AS_IF([test "x$enable_test_input" != "xno"],
125 [TEST_INPUT_PATH="$enable_test_input"],[])]
128 # if set, check directory exists
129 AS_IF([test "$TEST_INPUT_PATH" = ""],
131 [AS_IF([test -d $TEST_INPUT_PATH],[],
132 [AC_MSG_ERROR([Test input enabled, but directory $TEST_INPUT_PATH not found]) ]
135 # substitute path for input
136 AC_SUBST([TEST_INPUT_PATH])
138 # Does the user want to build documentation?
139 AC_MSG_CHECKING([whether documentation should be built (requires doxygen)])
140 AC_ARG_ENABLE([docs],
141 [AS_HELP_STRING([--enable-docs],
142 [enable building of documentation with doxygen.])])
143 test "x$enable_docs" = xyes || enable_docs=no
144 AC_MSG_RESULT([$enable_docs])
145 AM_CONDITIONAL(BUILD_DOCS, [test "x$enable_docs" = xyes])
147 # Is doxygen installed?
148 AC_CHECK_PROGS([DOXYGEN], [doxygen])
149 if test -z "$DOXYGEN" -a "x$enable_docs" = xyes; then
150 AC_MSG_ERROR([Doxygen not found but --enable-docs used.])
153 # If building docs, process Doxyfile.in into Doxyfile.
154 if test "x$enable_docs" = xyes; then
155 AC_CONFIG_FILES([docs/Doxyfile])
158 # Find the C compiler.
164 # Find the Fortran compiler.
167 AC_FC_MODULE_EXTENSION
168 AC_FC_MODULE_OUTPUT_FLAG
170 # Find the install program.
173 # Check to see if any macros must be set to enable large (>2GB) files.
178 if test $with_mpi = yes; then
180 # We expect users to set CC and FC to MPI compiler wrappers, or that the correct
181 # CPPFLAGS, {C,FC}FLAGS, LDFLAGS and LIBS options are given.
182 AC_CHECK_HEADERS([mpi.h], [], [AC_MSG_ERROR([Can't find the MPI C header file. Set CC/CPPFLAGS/CFLAGS])])
183 AC_CHECK_FUNC([MPI_Init], [], [AC_MSG_ERROR([Can't find the MPI C library. Set CC/LDFLAGS/LIBS])])
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([SKIP_PARSER_TESTS], false )
196 AM_CONDITIONAL([SKIP_PARSER_TESTS], true )
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>
209 #endif]])], [nc_has_nc4=yes], [nc_has_nc4=no])
210 AC_MSG_RESULT([$nc_has_nc4])
211 if test $nc_has_nc4 = no; then
212 AC_MSG_ERROR([NetCDF must be built with HDF5.])
215 # Check if Linux gettid is avaiable
216 AC_CHECK_FUNCS([gettid], [], [])
218 # Check if Linux sched_getaffinity is available
219 AC_CHECK_FUNCS([sched_getaffinity], [], [])
221 # Check if the compiler needs special OpenMP flags
225 # Fortran specific checks
226 AC_LANG_PUSH(Fortran)
227 if test $with_mpi = yes; then
229 GX_FC_CHECK_MOD([mpi], [], [], [AC_MSG_ERROR([Can't find the MPI Fortran module. Set FC/CPPFLAGS/FCFLAGS])])
230 AC_CHECK_FUNC([MPI_init], [], [AC_MSG_ERROR([Can't find the MPI Fortran library. Set FC/LDFLAGS/LIBS])])
232 # check intel compiler and coverage tools are avaiable if code coverage is enabled
233 if test "$enable_code_coverage" = yes; then
234 if test ! -z "`$FC --version | grep ifort`"; then
235 AC_CHECK_PROGS([PROFMERGE],[profmerge])
236 AC_CHECK_PROGS([CODECOV], [codecov])
238 AC_MSG_ERROR([Intel compiler and coverage tools required for coverage report])
241 AM_CONDITIONAL(COV, [test "$enable_code_coverage" = yes])
244 GX_FC_CHECK_MOD([netcdf], [], [], [AC_MSG_ERROR([Can't find the netCDF Fortran module. Set CPPFLAGS/FCFLAGS])])
245 GX_FORTRAN_SEARCH_LIBS([nf90_create], [netcdff], [use netcdf], [iret = nf90_create('foo.nc', 1, ncid)], [],
246 [AC_MSG_ERROR([Can't find the netCDF Fortran library. Set LDFLAGS/LIBS])])
248 # Check if Fortran compiler has the Class, Character array assign bug
249 GX_FC_CLASS_CHAR_ARRAY_BUG_CHECK()
251 # Check if Fortran compiler has Cray pointer support
252 GX_FC_CRAY_POINTER_FLAG()
254 # Check if Fortran compiler and system have quad precision support
255 GX_FC_QUAD_PRECISION()
257 # Check if Fortran compiler supports reading namelists from internal files
258 GX_FC_INTERNAL_FILE_NML()
260 # Check if the compiler needs special OpenMP flags
265 # We passed all the tests. Set the required defines.
266 AC_DEFINE([use_netCDF], [1], [This is required for the library to build])
267 if test $with_mpi = yes; then
268 AC_DEFINE([use_libMPI], [1], [This is required for the library to build])
271 # Set any required compile flags. This will not be done if the user wants to
272 # define all their own flags.
273 if test $enable_setting_flags = yes; then
274 # Make sure the compiler is seeing this as free-formatted, not
275 # fixed-formatted, fortran code.
278 # Check that long lines of Fortran code can be handled. This will add
279 # necessary fortran flags.
280 AC_FC_LINE_LENGTH([unlimited])
282 # Will we build with default 64-bit reals in Fortran, or do mixed mode?
283 if test $enable_mixed_mode = yes; then
284 GX_FC_DEFAULT_REAL_KIND4_FLAG([dnl
285 FCFLAGS="$FCFLAGS $FC_DEFAULT_REAL_KIND8_FLAG"])
286 AC_DEFINE([OVERLOAD_R4], [1], [Set to overload the R4 Fortran routines])
287 AC_DEFINE([OVERLOAD_R8], [1], [Set to overload the R8 Fortran routines])
289 GX_FC_DEFAULT_REAL_KIND8_FLAG([dnl
290 FCFLAGS="$FCFLAGS $FC_DEFAULT_REAL_KIND8_FLAG"])
292 # individual mixed precision overloads
293 if test $enable_overload_r4 = yes; then
294 AC_DEFINE([OVERLOAD_R4], [1], [Set to overload with the R4 Fortran routines])
296 if test $enable_overload_c4 = yes; then
297 AC_DEFINE([OVERLOAD_C4], [1], [Set to overload with the C4 Fortran routines])
299 if test $enable_overload_c8 = yes; then
300 AC_DEFINE([OVERLOAD_C8], [1], [Set to overload with the C8 Fortran routines])
302 if test $enable_8byte_int = yes; then
303 AC_DEFINE([no_8byte_integers], [1], [Set to disable 8 byte integer Fortran routines])
306 # Add Cray Pointer support flag
307 if test ! -z "$FC_CRAY_POINTER_FLAG"; then
308 FCFLAGS="$FCFLAGS $FC_CRAY_POINTER_FLAG"
312 if test ! -z "$OPENMP_CFLAGS"; then
313 CFLAGS="$CFLAGS $OPENMP_CFLAGS"
314 CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
316 if test ! -z "$OPENMP_FCFLAGS"; then
317 FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS"
320 # Add code coverage flags
321 if test $enable_code_coverage = yes; then
322 FCFLAGS="$FCFLAGS -prof-gen=srcpos"
323 CFLAGS="$CFLAGS -prof-gen=srcpos"
327 # Find which mpi launcher to use
328 AC_CHECK_PROGS([MPI_LAUNCHER],[srun aprun mpirun])
330 # Check if the launcher can oversubscribe the MPI processes
331 AS_IF([$MPI_LAUNCHER --oversubscribe hostname >/dev/null 2>&1], \
332 [ AC_SUBST([OVERSUBSCRIBE], [--oversubscribe])])
335 # Compiler with version information. This consists of the full path
336 # name of the compiler and the reported version number.
337 AC_SUBST([CC_VERSION])
338 # Strip anything that looks like a flag off of $CC
339 CC_NOFLAGS=`echo $CC | sed 's/ -.*//'`
341 if `echo $CC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
345 for x in `echo $PATH | sed -e 's/:/ /g'`; do
346 if test -x $x/$CC_NOFLAGS; then
352 if test -n "$cc_version_info"; then
353 CC_VERSION="$CC_VERSION ( $cc_version_info)"
356 AC_SUBST([FC_VERSION])
357 # Strip anything that looks like a flag off of $FC
358 FC_NOFLAGS=`echo $FC | sed 's/ -.*//'`
360 if `echo $FC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
364 for x in `echo $PATH | sed -e 's/:/ /g'`; do
365 if test -x $x/$FC_NOFLAGS; then
371 if test -n "$fc_version_info"; then
372 FC_VERSION="$FC_VERSION ( $fc_version_info )"
375 # Check if gcc is 11.1 for class(*) select type bug
376 AC_MSG_CHECKING([if gcc 11.1.0 is loaded])
377 if [ test -n "`$FC --version | grep GNU | grep 11\.1\..`" ]; then
379 AC_MSG_ERROR([Compilation with gcc and gfortran 11.1.0 is unsupported \
380 by this version of FMS due to a bug in the compiler. Please use a different version of gcc/gfortran.])
384 # Check if gcc >=10 is used with mpich
385 # adds compiler arg needed for mpich compilation if found
386 AC_MSG_CHECKING([if gcc 10 or greater is loaded with mpich])
387 if [ test "`$FC --version | grep GNU | grep -E ' 1[0-9]\.[0-9]*\.[0-9]*$'`" -a "`which $FC | grep -i mpich`" ]; then
389 AC_MSG_WARN([Adding -fallow-argument-mismatch to FCFLAGS to allow compilation with gcc >=10 and mpich])
390 FCFLAGS="$FCFLAGS -fallow-argument-mismatch"
396 # Create output variables from various
397 # shell variables, for use in generating
398 # libnetcdf.settings.
400 AC_SUBST([enable_shared])
401 AC_SUBST([enable_static])
405 AC_SUBST([AM_CFLAGS])
406 AC_SUBST([AM_CPPFLAGS])
407 AC_SUBST([AM_LDFLAGS])
408 AC_SUBST([NOUNDEFINED])
410 # Define the directory where *.mod files will reside.
412 AC_SUBST([MODDIR],[\$\(top_builddir\)/.mods])
414 # These files will be created when the configure script is run.
420 time_manager/Makefile
428 tracer_manager/Makefile
432 monin_obukhov/Makefile
434 interpolator/Makefile
435 horiz_interp/Makefile
436 field_manager/Makefile
439 diag_manager/Makefile
440 data_override/Makefile
441 column_diagnostics/Makefile
442 block_control/Makefile
446 diag_integral/Makefile
447 sat_vapor_pres/Makefile
448 random_numbers/Makefile
452 string_utils/Makefile
454 test_fms/intel_coverage.sh
456 test_fms/diag_manager/Makefile
457 test_fms/data_override/Makefile
458 test_fms/exchange/Makefile
459 test_fms/monin_obukhov/Makefile
460 test_fms/drifters/Makefile
461 test_fms/interpolator/Makefile
462 test_fms/fms2_io/Makefile
463 test_fms/fms/Makefile
464 test_fms/mpp/Makefile
465 test_fms/mpp_io/Makefile
466 test_fms/time_interp/Makefile
467 test_fms/time_manager/Makefile
468 test_fms/horiz_interp/Makefile
469 test_fms/field_manager/Makefile
470 test_fms/axis_utils/Makefile
471 test_fms/mosaic/Makefile
472 test_fms/affinity/Makefile
473 test_fms/coupler/Makefile
474 test_fms/parser/Makefile
475 test_fms/string_utils/Makefile