revert: log_diag_field_info argument changes (#1136)
[FMS.git] / configure.ac
blob7f3a1c0087597069d5a3d6a77a400b6c15e3c714
1 #***********************************************************************
2 #*                   GNU Lesser General Public License
3 #*
4 #* This file is part of the GFDL Flexible Modeling System (FMS).
5 #*
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
14 #* for more details.
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
24 AC_PREREQ([2.69])
26 # Initialize with name, version, and support email address.
27 AC_INIT([GFDL FMS Library],
28   [2022.04.00-dev],
29   [gfdl.climate.model.info@noaa.gov],
30   [FMS],
31   [https://www.github.com/NOAA-GFDL/FMS])
33 # Find out about the host we're building on.
34 AC_CANONICAL_HOST
35 AC_CANONICAL_BUILD
37 # Find out about the target we're building for.
38 AC_CANONICAL_TARGET
40 AC_CONFIG_MACRO_DIR([m4])
42 AM_INIT_AUTOMAKE([foreign dist-zip subdir-objects])
44 # Set up libtool.
45 LT_PREREQ([2.4])
46 LT_INIT()
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])
63 AC_ARG_WITH([mpi],
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],
67   [with_mpi=yes],
68   [with_mpi=no])
69 AC_ARG_WITH([yaml],
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],
73   [with_yaml=no],
74   [with_yaml=yes])
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" = ""],
129   [],
130   [AS_IF([test -d $TEST_INPUT_PATH],[],
131     [AC_MSG_ERROR([Test input enabled, but directory $TEST_INPUT_PATH not found]) ]
132   )])
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.
158 AC_PROG_CC
159 AM_PROG_CC_C_O
160 AC_C_CONST
161 AC_PROG_CPP
163 # Find the Fortran compiler.
164 AC_PROG_FC
165 AC_FC_MODULE_FLAG
166 AC_FC_MODULE_EXTENSION
167 AC_FC_MODULE_OUTPUT_FLAG
169 # Find the install program.
170 AC_PROG_INSTALL
172 # Check to see if any macros must be set to enable large (>2GB) files.
173 AC_SYS_LARGEFILE
175 # C specific checks
176 AC_LANG_PUSH(C)
177 if test $with_mpi = yes; then
178   # Require MPI
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.
181   GX_MPI()
184 # Require yaml
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 )
193 else
194   AM_CONDITIONAL([SKIP_PARSER_TESTS], true )
197 # Require netCDF
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>
205 #if !(NC_HAS_NC4)
206       choke me
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 )
217 else
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
228 AC_OPENMP()
229 AC_LANG_POP(C)
231 # Fortran specific checks
232 AC_LANG_PUSH(Fortran)
233 if test $with_mpi = yes; then
234   # Require MPI
235   GX_MPI()
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"])
242   fi
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])
250   else
251     AC_MSG_ERROR([Intel compiler and coverage tools required for coverage report])
252   fi
254 AM_CONDITIONAL(COV, [test "$enable_code_coverage" = yes])
256 # Require netCDF
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
274 AC_OPENMP()
276 AC_LANG_POP(Fortran)
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.
289   AC_FC_FREEFORM()
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])
301   else
302     GX_FC_DEFAULT_REAL_KIND8_FLAG([dnl
303       FCFLAGS="$FCFLAGS $FC_DEFAULT_REAL_KIND8_FLAG"])
304   fi
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])
308   fi
309   if test $enable_overload_c4 = yes; then
310     AC_DEFINE([OVERLOAD_C4], [1], [Set to overload with the C4 Fortran routines])
311   fi
312   if test $enable_overload_c8 = yes; then
313     AC_DEFINE([OVERLOAD_C8], [1], [Set to overload with the C8 Fortran routines])
314   fi
315   if test $enable_8byte_int = yes; then
316     AC_DEFINE([no_8byte_integers], [1], [Set to disable 8 byte integer Fortran routines])
317   fi
319   # Add Cray Pointer support flag
320   if test ! -z "$FC_CRAY_POINTER_FLAG"; then
321     FCFLAGS="$FCFLAGS $FC_CRAY_POINTER_FLAG"
322   fi
324   # Add OpenMP flags
325   if test ! -z "$OPENMP_CFLAGS"; then
326     CFLAGS="$CFLAGS $OPENMP_CFLAGS"
327     CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
328   fi
329   if test ! -z "$OPENMP_FCFLAGS"; then
330     FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS"
331   fi
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"
337   fi
338   # add yaml flag
339   if test $with_yaml = yes; then
340     LDFLAGS="$LDFLAGS -lyaml"
341   fi
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
359   CC_VERSION="$CC"
360 else
361   CC_VERSION="$CC";
362   for x in `echo $PATH | sed -e 's/:/ /g'`; do
363     if test -x $x/$CC_NOFLAGS; then
364       CC_VERSION="$x/$CC"
365       break
366     fi
367   done
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
378   FC_VERSION="$FC"
379 else
380   FC_VERSION="$FC";
381   for x in `echo $PATH | sed -e 's/:/ /g'`; do
382     if test -x $x/$FC_NOFLAGS; then
383       FC_VERSION="$x/$FC"
384       break
385     fi
386   done
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
395   AC_MSG_RESULT([yes])
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.])
398 else
399   AC_MSG_RESULT([no])
402 #####
403 # Create output variables from various
404 # shell variables, for use in generating
405 # libnetcdf.settings.
406 #####
407 AC_SUBST([enable_shared])
408 AC_SUBST([enable_static])
409 AC_SUBST([CFLAGS])
410 AC_SUBST([CPPFLAGS])
411 AC_SUBST([LDFLAGS])
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.
418 # Used in Makefiles.
419 AC_SUBST([MODDIR],[\$\(top_builddir\)/.mods])
421 # These files will be created when the configure script is run.
422 AC_CONFIG_FILES([
423   Makefile
424   affinity/Makefile
425   amip_interp/Makefile
426   time_interp/Makefile
427   time_manager/Makefile
428   constants/Makefile
429   constants4/Makefile
430   platform/Makefile
431   fms/Makefile
432   fms2_io/Makefile
433   mpp/Makefile
434   tridiagonal/Makefile
435   tracer_manager/Makefile
436   topography/Makefile
437   mosaic/Makefile
438   mosaic2/Makefile
439   monin_obukhov/Makefile
440   memutils/Makefile
441   interpolator/Makefile
442   horiz_interp/Makefile
443   field_manager/Makefile
444   exchange/Makefile
445   drifters/Makefile
446   diag_manager/Makefile
447   data_override/Makefile
448   column_diagnostics/Makefile
449   block_control/Makefile
450   axis_utils/Makefile
451   astronomy/Makefile
452   coupler/Makefile
453   diag_integral/Makefile
454   sat_vapor_pres/Makefile
455   random_numbers/Makefile
456   libFMS/Makefile
457   docs/Makefile
458   parser/Makefile
459   string_utils/Makefile
460   test_fms/test-lib.sh
461   test_fms/intel_coverage.sh
462   test_fms/Makefile
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
483   FMS.pc
484   ])
486 AC_OUTPUT()