-
Notifications
You must be signed in to change notification settings - Fork 28
/
configure.ac
302 lines (265 loc) · 10.4 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#***********************************************************************
# GNU Lesser General Public License
#
# This file is part of the GFDL FRE NetCDF tools package (FRE-NCTools).
#
# FRE-NCTools is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# FRE-NCTools is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with FRE-NCTools (LICENSE.md). If not, see
# <http://www.gnu.org/licenses/>.
#***********************************************************************
# Prelude
AC_PREREQ([2.63])
AC_INIT(
[FRE NCTools],
[2024.05],
[https://github.com/NOAA-GFDL/FRE-NCtools/issues],
[fre-nctools],
[https://github.com/NOAA-GFDL/FRE-NCtools])
# Place the git description information in the configure script
m4_define([git_revision],
[m4_esyscmd_s([git describe --tags --always --dirty 2> /dev/null || echo "unknown version"])])
AC_REVISION([git_revision])
m4_define([git_hashval],
[m4_esyscmd_s([git rev-parse HEAD 2> /dev/null || echo "unknown git hash"])])
AC_REVISION([git_hashval])
m4_define([git_date],
[m4_esyscmd_s([git show --no-patch --format=%as HEAD 2> /dev/null || date +%Y-%m-%d])])
AC_REVISION([git_date])
m4_define([copyright_year],
[m4_substr(git_date, 0, 4)])
AC_CONFIG_SRCDIR([src/land_utils/combine-ncc.F90])
AC_CONFIG_MACRO_DIR([m4])
AC_REQUIRE_AUX_FILE([tap-driver.sh])
# Remove -Werror from automake options until OS vendors brings in a newer
# version of automake.
AM_INIT_AUTOMAKE([foreign -Wall -Woverride tar-pax subdir-objects])
AM_EXTRA_RECURSIVE_TARGETS([docs install-docs])
# Check for programs
AC_PROG_RANLIB
AM_PROG_AR
AC_ARG_ENABLE([quad-precision],
[AS_HELP_STRING([--enable-quad-precision],
[build using higher (quad) precision])],
[],
[enable_quad_precision=no])
AC_PROG_CC([icc gcc nvc])
AM_PROG_CC_C_O
## When autoconf v2.70 is more available, this can be replaced with:
##AC_C__GENERIC
GX_C__GENERIC
AS_IF([test $gx_cv_c__Generic = no],
AC_MSG_ERROR([The C compiler does not support the generic selection C-11 standard. Please use a C-11 compliant compiler.])
)
AC_PROG_FC([ifort gfortran nvfortran])
AC_PROG_FC_C_O
AC_FC_SRCEXT([f90])
AC_FC_SRCEXT([F90])
AC_FC_LINE_LENGTH([unlimited])
AC_FC_FREEFORM()
AC_FC_MODULE_EXTENSION()
AC_FC_MODULE_FLAG()
AC_FC_MODULE_OUTPUT_FLAG()
GX_FC_DEFAULT_REAL_KIND8_FLAG()
GX_FC_DEFAULT_REAL_KIND4_FLAG()
AC_SEARCH_LIBS([ceil],[m])
# Check for the MPI compilers
# Default MPI build is off
build_mpi=no
LX_FIND_MPI()
AS_IF([test x"$with_mpi" = x"yes" && test x"$have_C_mpi" = x"no"], [
AC_MSG_ERROR([MPI build requested but no MPI compiler found.])
])
AM_CONDITIONAL([WITH_MPI], [test x"$with_mpi" = x"yes"])
AM_CONDITIONAL([WITH_MPI_TESTS], [test x"$with_mpi" = x"yes" && test -z "$SKIP_MPI_TEST"])
# Build with OpenACC support. Default is 'no'
AC_ARG_ENABLE([gpu],
[AS_HELP_STRING([--enable-gpu],
[Builds with OpenACC. This will result in a second executable for fregrid, fregrid_gpu. (default no)])])
AS_IF([test ${enable_gpu:-no} = yes],
[enable_gpu=yes],
[enable_gpu=no])
# check compile flags
AS_IF([test ${enable_gpu} = yes],
[GX_OPENACC_FLAGS()])
AM_CONDITIONAL([ENABLE_GPU], [test "$enable_gpu" = "yes"])
AC_CHECK_FUNCS(gettid, [], [])
# Check if Fortran compiler has Cray pointer support
GX_FC_CRAY_POINTER_FLAG()
# Add Cray Pointer support flag
if test ! -z "$FC_CRAY_POINTER_FLAG"; then
FCFLAGS="$FCFLAGS $FC_CRAY_POINTER_FLAG"
fi
# Check for programs
AC_PROG_GREP
AC_PROG_EGREP
AC_PROG_SED
AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
if test -n "$ASCIIDOC"; then
AC_MSG_CHECKING([for asciidoc version])
asciidoc_version=`$ASCIIDOC --version 2>/dev/null`
case "${asciidoc_version}" in
asciidoc' '8*)
AC_MSG_RESULT([${asciidoc_version}])
;;
*)
AC_MSG_RESULT([${asciidoc_version} (unknown)])
;;
esac
fi
AM_CONDITIONAL([WITH_ASCIIDOC], [test -n "$ASCIIDOC"])
AC_CHECK_PROGS(BATS, [bats])
AC_CHECK_PROGS(PROVE, [prove])
AM_CONDITIONAL([WITH_CHECK_PROGS], [test -n "$PROVE" -a -n "$BATS"])
# Although these are supplied with the NetCDF C library, we'll double
# check that ncgen and ncdump are available
AC_ARG_VAR([NCGEN], [Path to ncgen])
AC_PATH_PROG(NCGEN, [ncgen])
AS_IF([test -z "$NCGEN"],
[AC_MSG_ERROR([Cannot find ncgen. Please ensure ncgen is in PATH or set the environment variable NCGEN to the full path.])])
AC_ARG_VAR([NCDUMP], [Path to ncdump])
AC_PATH_PROG(NCDUMP, [ncdump])
AS_IF([test -z "$NCDUMP"],
[AC_MSG_ERROR([Cannot find ncdump. Please ensure ncdump is in PATH or set the environment variable NCDUMP to the full path.])])
AC_ARG_VAR([NCRCAT], [Path to ncrcat])
AC_PATH_PROG(NCRCAT, [ncrcat])
AS_IF([test -z "$NCRCAT"],
[AC_MSG_ERROR([Cannot find ncrcat. Please ensure ncrcat is in PATH or set the environment variable NCRCAT to the full path.])])
AC_ARG_VAR([NCATTED], [Path to ncatted])
AC_PATH_PROG(NCATTED, [ncatted])
AS_IF([test -z "$NCATTED"],
[AC_MSG_ERROR([Cannot find ncatted. Please ensure ncatted is in PATH or set the environment variable NCATTED to the full path.])])
AC_ARG_VAR([NCKS], [Path to ncks])
AC_PATH_PROG(NCKS, [ncks])
AS_IF([test -z "$NCKS"],
[AC_MSG_ERROR([Cannot find ncks. Please ensure ncks is in PATH or set the environment variable NCKS to the full path.])])
AC_ARG_VAR([PERL], [Path to perl])
AC_PATH_PROG(PERL, [perl])
AX_PROG_PERL_MODULES([List::MoreUtils], dnl
eval AS_TR_CPP(HAVE_PLMOD_LIST_MOREUTILS)=yes,
AC_MSG_WARN([Perl module List::MoreUtils not found. Some applications will not be installed.]))
AM_CONDITIONAL([HAVE_PLMOD_LIST_MOREUTILS], [test x$HAVE_PLMOD_LIST_MOREUTILS = xyes])
AX_PYTHON_MODULE([xarray],[],[python3])
if test ${HAVE_PYMOD_XARRAY} = yes; then
AM_CONDITIONAL([SKIP_XARRAY_TESTS], false )
else
AM_CONDITIONAL([SKIP_XARRAY_TESTS], true )
fi
# Look for mpirun, mpiexec, srun application
AC_ARG_VAR([MPIRUN], [Path to mpirun])
AS_IF([test x"$with_mpi" = x"yes"], [
AC_CHECK_PROGS(MPIRUN, [srun aprun mpirun mpiexec])
AS_IF([test -z "$MPIRUN"],
[AC_MSG_WARN([Cannot find a suitable MPI launch application. MPI tests will be skipped.])])
])
# Check if openacc.h exists
if test "$enable_gpu" = yes ; then
AC_CHECK_HEADERS([openacc.h], [], [AC_MSG_ERROR(["Cannot find OpenACC header file"])] )
AC_MSG_WARN(Currently only NVIDIA compilers are supported to compile with OpenACC in FRE-NCTOOLS)
fi
# Check for getrusage.
AC_CHECK_FUNCS([getrusage])
# Check for library
AX_LIB_NETCDF()
if test "$with_netcdf" = "no"; then
AC_MSG_ERROR([Unable to find NetCDF c library.])
fi
AC_LANG_PUSH([Fortran])
AX_LIB_NETCDFF()
if test "$with_netcdf_fortran" = "no"; then
AC_MSG_ERROR([Unable to find NetCDF Fortran library.])
fi
AC_LANG_POP([Fortran])
# Check if Linux sched_getaffinity is available
AC_CHECK_FUNCS([sched_getaffinity], [], [])
# Check for typedefs, structures, and compiler characteristics
# Check if the C compiler supports a working `long double` with more range
# or precision than `double`.
AS_IF([test ${enable_quad_precision:-no} = yes], [
AC_TYPE_LONG_DOUBLE_WIDER
AS_IF([test $ac_cv_type_long_double_wider = no],
[AC_MSG_ERROR([system does not support quad precision. Try setting --enable-mixed-precision=no])
])
])
# Check for library functions
# Check if Test25-input link points to an existing directory
AM_CONDITIONAL([HAVE_TEST25_INPUT], [test -e ${srcdir}/t/Test25-input/grid_spec.nc])
# Set macros
AS_VAR_SET([GIT_REVISION], ["git_revision"])dnl
AC_DEFINE([GIT_REVISION], ["git_revision"],
[Holds the 'git describe' information if configure ran within a git working directory])dnl
AC_SUBST(GIT_REVISION)dnl
AS_VAR_SET([GIT_HEADHASH], ["git_hashval"])dnl
AC_DEFINE([GIT_HEADHASH], ["git_hashval"],
[Holds the 'git rev-parse HEAD' information if configure ran within a git working directory])dnl
AC_SUBST(GIT_HEADHASH)dnl
AS_VAR_SET([COPYRIGHT_YEAR], ["copyright_year"])dnl
AC_DEFINE([COPYRIGHT_YEAR], ["copyright_year"],
[Year to place in Copyright notices printed with --version information])dnl
AC_SUBST(COPYRIGHT_YEAR)dnl
# Code for setting rpath based ncview's configure.in code.
AS_IF([test x$ac_compiler_gnu = xyes], [RPATH_FLAGS=""
for word in $NETCDF_LDFLAGS $NETCDF_FCLDFLAGS
do
if test `expr $word : -L/` -eq 3
then
RPDIR=${word:2}
regex=".*$RPDIR.*"
if test `expr "$RPATH_FLAGS" : $regex` -eq 0
then
# RPDIR not in RPATH_FLAGS
RPATH_FLAGS="$RPATHFLAGS -Wl,-rpath,$RPDIR"
fi
fi
done])
AC_SUBST(RPATH_FLAGS) dnl
# Output files
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile
lib/libnfu/Makefile
man/Makefile
src/Makefile
tests/Makefile
tools/libfrencutils/Makefile
tools/libfrencutils_gpu/Makefile
tools/check_mask/Makefile
tools/cubic_utils/Makefile
tools/fregrid/Makefile
tools/fregrid_gpu/Makefile
tools/make_coupler_mosaic/Makefile
tools/make_hgrid/Makefile
tools/make_land_domain/Makefile
tools/make_quick_mosaic/Makefile
tools/make_regional_mosaic/Makefile
tools/make_solo_mosaic/Makefile
tools/make_topog/Makefile
tools/make_vgrid/Makefile
tools/mppncscatter/Makefile
tools/ncexists/Makefile
tools/nc_null_check/Makefile
tools/remap_land/Makefile
tools/river_regrid/Makefile
tools/runoff_regrid/Makefile
tools/transfer_to_mosaic_grid/Makefile
tools/simple_hydrog/Makefile
tools/simple_hydrog/postp/Makefile
tools/simple_hydrog/lakes/Makefile
tools/simple_hydrog/rmvpr/Makefile
tools/simple_hydrog/libfmslite/Makefile
t/Makefile
t_gpu/Makefile
t_gpu/test_read_remap_file/Makefile
t_gpu/test_get_grid_cell_struct/Makefile
t_gpu/test_get_upbound_nxcells_2dx2d/Makefile
t_gpu/test_get_interp_order1/Makefile
])
AC_OUTPUT