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.gfdl.noaa.gov/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])
83 # Does the user want to build documentation?
84 AC_MSG_CHECKING([whether documentation should be build (requires doxygen)])
86 [AS_HELP_STRING([--enable-docs],
87 [enable building of documentation with doxygen.])])
88 test "x$enable_docs" = xyes || enable_docs=no
89 AC_MSG_RESULT([$enable_docs])
90 AM_CONDITIONAL(BUILD_DOCS, [test "x$enable_docs" = xyes])
92 # Is doxygen installed?
93 AC_CHECK_PROGS([DOXYGEN], [doxygen])
94 if test -z "$DOXYGEN" -a "x$enable_docs" = xyes; then
95 AC_MSG_ERROR([Doxygen not found but --enable-docs used.])
98 # If building docs, process Doxyfile.in into Doxyfile.
99 if test "x$enable_docs" = xyes; then
100 AC_CONFIG_FILES([docs/Doxyfile])
103 # Find the C compiler.
109 # Find the Fortran compiler.
112 AC_FC_MODULE_EXTENSION
113 AC_FC_MODULE_OUTPUT_FLAG
115 # Find the install program.
118 # Check to see if any macros must be set to enable large (>2GB) files.
123 if test $with_mpi = yes; then
125 # We expect users to set CC and FC to MPI compiler wrappers, or that the correct
126 # CPPFLAGS, {C,FC}FLAGS, LDFLAGS and LIBS options are given.
127 AC_CHECK_HEADERS([mpi.h], [], [AC_MSG_ERROR([Can't find the MPI C header file. Set CC/CPPFLAGS/CFLAGS])])
128 AC_CHECK_FUNC([MPI_Init], [], [AC_MSG_ERROR([Can't find the MPI C library. Set CC/LDFLAGS/LIBS])])
132 if test $with_yaml = yes; then
133 AC_CHECK_HEADERS([yaml.h], [], [AC_MSG_ERROR(["Can't find the libYAML C header file. Set CC/CPPFLAGS/CFLAGS"])])
134 AC_SEARCH_LIBS([yaml_parser_initialize], [yaml], [], [AC_MSG_ERROR(["Can't find the libYAML C library. Set CC/LDFLAGS/LIBS"])])
136 #If the test pass, define use_yaml macro
137 AC_DEFINE([use_yaml], [1], [This is required to use yaml parser])
139 AM_CONDITIONAL([SKIP_PARSER_TESTS], false )
141 AM_CONDITIONAL([SKIP_PARSER_TESTS], true )
145 AC_CHECK_HEADERS([netcdf.h], [], [AC_MSG_ERROR([Can't find the netCDF C header file. Set CPPFLAGS/CFLAGS])])
146 AC_SEARCH_LIBS([nc_create], [netcdf], [], [AC_MSG_ERROR([Can't find the netCDF C library. Set LDFLAGS/LIBS])])
148 # Require netCDF-4 (with HDF5).
149 AC_MSG_CHECKING([if netCDF was built with HDF5])
150 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
151 #include <netcdf_meta.h>
154 #endif]])], [nc_has_nc4=yes], [nc_has_nc4=no])
155 AC_MSG_RESULT([$nc_has_nc4])
156 if test $nc_has_nc4 = no; then
157 AC_MSG_ERROR([NetCDF must be built with HDF5.])
160 # Check if Linux gettid is avaiable
161 AC_CHECK_FUNCS([gettid], [], [])
163 # Check if Linux sched_getaffinity is available
164 AC_CHECK_FUNCS([sched_getaffinity], [], [])
166 # Check if the compiler needs special OpenMP flags
170 # Fortran specific checks
171 AC_LANG_PUSH(Fortran)
172 if test $with_mpi = yes; then
174 GX_FC_CHECK_MOD([mpi], [], [], [AC_MSG_ERROR([Can't find the MPI Fortran module. Set FC/CPPFLAGS/FCFLAGS])])
175 AC_CHECK_FUNC([MPI_init], [], [AC_MSG_ERROR([Can't find the MPI Fortran library. Set FC/LDFLAGS/LIBS])])
179 GX_FC_CHECK_MOD([netcdf], [], [], [AC_MSG_ERROR([Can't find the netCDF Fortran module. Set CPPFLAGS/FCFLAGS])])
180 GX_FORTRAN_SEARCH_LIBS([nf90_create], [netcdff], [use netcdf], [iret = nf90_create('foo.nc', 1, ncid)], [],
181 [AC_MSG_ERROR([Can't find the netCDF Fortran library. Set LDFLAGS/LIBS])])
183 # Check if Fortran compiler has the Class, Character array assign bug
184 GX_FC_CLASS_CHAR_ARRAY_BUG_CHECK()
186 # Check if Fortran compiler has Cray pointer support
187 GX_FC_CRAY_POINTER_FLAG()
189 # Check if Fortran compiler and system have quad precision support
190 GX_FC_QUAD_PRECISION()
192 # Check if Fortran compiler supports reading namelists from internal files
193 GX_FC_INTERNAL_FILE_NML()
195 # Check if the compiler needs special OpenMP flags
200 # We passed all the tests. Set the required defines.
201 AC_DEFINE([use_netCDF], [1], [This is required for the library to build])
202 if test $with_mpi = yes; then
203 AC_DEFINE([use_libMPI], [1], [This is required for the library to build])
206 # Set any required compile flags. This will not be done if the user wants to
207 # define all their own flags.
208 if test $enable_setting_flags = yes; then
209 # Make sure the compiler is seeing this as free-formatted, not
210 # fixed-formatted, fortran code.
213 # Check that long lines of Fortran code can be handled. This will add
214 # necessary fortran flags.
215 AC_FC_LINE_LENGTH([unlimited])
217 # Will we build with default 64-bit reals in Fortran, or do mixed mode?
218 if test $enable_mixed_mode = yes; then
219 GX_FC_DEFAULT_REAL_KIND4_FLAG([dnl
220 FCFLAGS="$FCFLAGS $FC_DEFAULT_REAL_KIND8_FLAG"])
221 AC_DEFINE([OVERLOAD_R4], [1], [Set to overload the R4 Fortran routines])
222 AC_DEFINE([OVERLOAD_R8], [1], [Set to overload the R8 Fortran routines])
224 GX_FC_DEFAULT_REAL_KIND8_FLAG([dnl
225 FCFLAGS="$FCFLAGS $FC_DEFAULT_REAL_KIND8_FLAG"])
228 # Add Cray Pointer support flag
229 if test ! -z "$FC_CRAY_POINTER_FLAG"; then
230 FCFLAGS="$FCFLAGS $FC_CRAY_POINTER_FLAG"
234 if test ! -z "$OPENMP_CFLAGS"; then
235 CFLAGS="$CFLAGS $OPENMP_CFLAGS"
236 CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
238 if test ! -z "$OPENMP_FCFLAGS"; then
239 FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS"
243 # Define an AM_CONDITIONAL to determine if you are on a CRAY
244 AM_CONDITIONAL([CRAY], [test `env | grep CRAY | wc -l` -gt 0])
246 # Find which mpi launcher to use
247 AC_CHECK_PROGS([MPI_LAUNCHER],[srun aprun mpirun])
249 # Check if the launcher can oversubscribe the MPI processes
250 AS_IF([$MPI_LAUNCHER --oversubscribe hostname >/dev/null 2>&1], \
251 [ AC_SUBST([OVERSUBSCRIBE], [--oversubscribe])])
254 # Compiler with version information. This consists of the full path
255 # name of the compiler and the reported version number.
256 AC_SUBST([CC_VERSION])
257 # Strip anything that looks like a flag off of $CC
258 CC_NOFLAGS=`echo $CC | sed 's/ -.*//'`
260 if `echo $CC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
264 for x in `echo $PATH | sed -e 's/:/ /g'`; do
265 if test -x $x/$CC_NOFLAGS; then
271 if test -n "$cc_version_info"; then
272 CC_VERSION="$CC_VERSION ( $cc_version_info)"
275 AC_SUBST([FC_VERSION])
276 # Strip anything that looks like a flag off of $FC
277 FC_NOFLAGS=`echo $FC | sed 's/ -.*//'`
279 if `echo $FC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
283 for x in `echo $PATH | sed -e 's/:/ /g'`; do
284 if test -x $x/$FC_NOFLAGS; then
290 if test -n "$fc_version_info"; then
291 FC_VERSION="$FC_VERSION ( $fc_version_info )"
294 # Check if gcc is 11.1 for class(*) select type bug
295 AC_MSG_CHECKING([if gcc 11.1.0 is loaded])
296 if [ test -n "`$FC --version | grep GNU | grep 11\.1\..`" ]; then
298 AC_MSG_ERROR([Compilation with gcc and gfortran 11.1.0 is unsupported \
299 by this version of FMS due to a bug in the compiler. Please use a different version of gcc/gfortran.])
305 # Create output variables from various
306 # shell variables, for use in generating
307 # libnetcdf.settings.
309 AC_SUBST([enable_shared])
310 AC_SUBST([enable_static])
314 AC_SUBST([AM_CFLAGS])
315 AC_SUBST([AM_CPPFLAGS])
316 AC_SUBST([AM_LDFLAGS])
317 AC_SUBST([NOUNDEFINED])
319 # Define the directory where *.mod files will reside.
321 AC_SUBST([MODDIR],[\$\(top_builddir\)/.mods])
323 # These files will be created when the configure script is run.
329 time_manager/Makefile
336 tracer_manager/Makefile
340 monin_obukhov/Makefile
342 interpolator/Makefile
343 horiz_interp/Makefile
344 field_manager/Makefile
347 diag_manager/Makefile
348 data_override/Makefile
349 column_diagnostics/Makefile
350 block_control/Makefile
354 diag_integral/Makefile
355 sat_vapor_pres/Makefile
356 random_numbers/Makefile
360 test_fms/test_common.sh
362 test_fms/diag_manager/Makefile
363 test_fms/data_override/Makefile
364 test_fms/exchange/Makefile
365 test_fms/monin_obukhov/Makefile
366 test_fms/drifters/Makefile
367 test_fms/interpolator/Makefile
368 test_fms/fms2_io/Makefile
369 test_fms/fms/Makefile
370 test_fms/mpp/Makefile
371 test_fms/mpp_io/Makefile
372 test_fms/time_interp/Makefile
373 test_fms/time_manager/Makefile
374 test_fms/horiz_interp/Makefile
375 test_fms/field_manager/Makefile
376 test_fms/axis_utils/Makefile
377 test_fms/mosaic/Makefile
378 test_fms/affinity/Makefile
379 test_fms/coupler/Makefile
380 test_fms/parser/Makefile