-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
313 lines (257 loc) · 8.68 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
303
304
305
306
307
308
309
310
311
312
313
AC_INIT([ps3d], [0.1.3], [[email protected]], [], [https://github.com/matt-frey/ps3d])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AC_PROG_FC([gfortran])
AC_LANG(Fortran)
AM_PROG_AR
LT_INIT
# change file extension from *.f to *.f90
# (important for library tests since it autogenerates a file conftest.f90)
AC_FC_SRCEXT(f90)
FCFLAGS="-std=f2018 -fdefault-real-8 -fdefault-double-8 -cpp -mcmodel=large"
AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_HEADERS([src/utils/config.h])
AC_CONFIG_FILES([
Makefile
src/Makefile
src/mpi/Makefile
src/utils/Makefile
src/netcdf/Makefile
src/fft/Makefile
unit-tests/Makefile
tests/Makefile
])
#######################################################################################
##
## "--with" flags
##
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# NetCDF C
## 11 March 2021
## https://www.gnu.org/software/autoconf/manual/autoconf-2.60/html_node/External-Software.html
AC_ARG_WITH([netcdf-c],
[AS_HELP_STRING([--with-netcdf-c=<path>], [path to NetCDF C library @<:@default=$NETCDF_C_DIR@:>@])],
[NETCDF_C_DIR=$withval],
[])
if test -n "${NETCDF_C_DIR}"; then
CFLAGS="$CFLAGS -I$NETCDF_C_DIR/include"
LDFLAGS="$LDFLAGS -L$NETCDF_C_DIR/lib"
else
AC_MSG_ERROR([No NETCDF_C_DIR environment variable.])
fi
AC_LANG_PUSH([C])
AC_SEARCH_LIBS([nc_create], [netcdf], [], [], [])
AC_MSG_CHECKING([whether we can compile a NetCDF C program])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <netcdf.h>], [
int ncid;
nc_create("dummy.nc", NC_CLOBBER, &ncid);
])],
[netcdf_c_found=yes],
[netcdf_c_found=no])
AC_MSG_RESULT([$netcdf_c_found])
AC_LANG_POP([C])
if test "x$netcdf_c_found" = "xno"; then
AC_MSG_ERROR([Cannot compile a NetCDF C program])
fi
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# NetCDF Fortran
AC_ARG_WITH([netcdf-fortran],
[AS_HELP_STRING([--with-netcdf-fortran=<path>],
[path to NetCDF Fortran library @<:@default=$NETCDF_FORTRAN_DIR@:>@])],
[NETCDF_FORTRAN_DIR=$withval],
[])
if test -n "${NETCDF_FORTRAN_DIR}"; then
FCFLAGS="$FCFLAGS -I$NETCDF_FORTRAN_DIR/include"
LDFLAGS="$LDFLAGS -L$NETCDF_FORTRAN_DIR/lib"
else
AC_MSG_ERROR([No NETCDF_FORTRAN_DIR environment variable.])
fi
# 15 April 2023
#http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_prog_fc_mpi.m4
# We cannot use AC_SEARCH_LIBS
for lib in NONE netcdff; do
save_LIBS=$LIBS
if test x"$lib" = xNONE; then
AC_MSG_CHECKING([for function nf90_open])
else
AC_MSG_CHECKING([for function nf90_open in -l$lib])
LIBS="-l$lib $LIBS"
fi
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([], [
use netcdf
implicit none
integer :: ncerr, ncid
ncerr = nf90_open("dummy.nc", NF90_NOWRITE, ncid)])],
[netcdf_found=yes],
[netcdf_found=no])
AC_MSG_RESULT($netcdf_found)
if test "x$netcdf_found" = "xyes"; then
break;
fi
LIBS=$save_LIBS
done
AC_MSG_CHECKING([whether we can compile a NetCDF Fortran program])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([], [
use netcdf
implicit none])],
[netcdf_fortran_found=yes],
[netcdf_fortran_found=no])
AC_MSG_RESULT([$netcdf_fortran_found])
if test "x$netcdf_fortran_found" = "xno"; then
AC_MSG_ERROR([Cannot compile a NetCDF Fortran program])
fi
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# MPI
AC_ARG_WITH([mpi],
[AS_HELP_STRING([--with-mpi=<path>], [path to mpi library @<:@default=$MPI_DIR@:>@])],
[MPI_DIR=$withval],
[])
if test -n "${MPI_DIR}"; then
# mod file may also be in $MPI_DIR/lib
FCFLAGS="$FCFLAGS -I$MPI_DIR/include -I$MPI_DIR/lib"
LDFLAGS="$LDFLAGS -L$MPI_DIR/lib"
else
AC_MSG_ERROR([No MPI_DIR environment variable.])
fi
AC_SEARCH_LIBS([MPI_Init],
[mpi_usempif08 mpi_usempi_ignore_tkr mpi_mpifh mpichf90],
[],
[])
AC_SEARCH_LIBS([MPI_Win_lock],
[mpi_usempif08 mpi_usempi_ignore_tkr mpi_mpifh mpichf90],
[],
[])
for lib in NONE mpi_usempif08 mpi_usempi_ignore_tkr mpi_mpifh mpichf90; do
save_LIBS=$LIBS
if test x"$lib" = xNONE; then
AC_MSG_CHECKING([for module mpi_f08])
else
AC_MSG_CHECKING([for module mpi_f08 in -l$lib])
LIBS="-l$lib $LIBS"
fi
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([], [
use mpi_f08
implicit none
integer :: ierr
call MPI_Init(ierr)
call MPI_Finalize(ierr)])],
[mpi_found=yes],
[mpi_found=no])
AC_MSG_RESULT([$mpi_found])
if test "x$mpi_found" = "xyes"; then
break;
fi
LIBS=$save_LIBS
done
AC_MSG_CHECKING([for MPI Fortran library])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([], [
use mpi_f08
implicit none
integer :: ierr
call MPI_Init(ierr)
call MPI_Finalize(ierr)])],
[mpi_found=yes],
[mpi_found=no])
AC_MSG_RESULT([$mpi_found])
if test "x$mpi_found" = "xno"; then
AC_MSG_ERROR([Cannot find MPI Fortran library])
fi
#######################################################################################
##
## "--enable" flags
##
ENABLE_VERBOSE='no'
AC_ARG_ENABLE([verbose],
[AS_HELP_STRING([--enable-verbose], [enable verbose mode (default=no)])],
[ENABLE_VERBOSE=$enableval])
AM_CONDITIONAL([ENABLE_VERBOSE], [test "$ENABLE_VERBOSE" = "yes"])
AC_MSG_CHECKING([whether we are compiling in verbose mode])
if test "x$ENABLE_VERBOSE" = "xyes"; then
AC_MSG_RESULT([yes])
FCFLAGS="$FCFLAGS -DENABLE_VERBOSE"
else
AC_MSG_RESULT([no])
fi
ENABLE_BUOYANCY='no'
AC_ARG_ENABLE([buoyancy],
[AS_HELP_STRING([--enable-buoyancy], [enable buoyancy mode (default=no)])],
[ENABLE_BUOYANCY=$enableval])
AM_CONDITIONAL([ENABLE_BUOYANCY], [test "$ENABLE_BUOYANCY" = "yes"])
AC_MSG_CHECKING([whether we are enabling buoyancy])
if test "x$ENABLE_BUOYANCY" = "xyes"; then
AC_MSG_RESULT([yes])
FCFLAGS="$FCFLAGS -DENABLE_BUOYANCY"
else
AC_MSG_RESULT([no])
fi
ENABLE_BALANCE='no'
AC_ARG_ENABLE([balance],
[AS_HELP_STRING([--enable-balance], [enable balance mode (default=no)])],
[ENABLE_BALANCE=$enableval])
AM_CONDITIONAL([ENABLE_BALANCE], [test "$ENABLE_BALANCE" = "yes"])
AC_MSG_CHECKING([whether we are enabling balance])
if test "x$ENABLE_BALANCE" = "xyes"; then
AC_MSG_RESULT([yes])
FCFLAGS="$FCFLAGS -DENABLE_BALANCE"
if test "x$ENABLE_BUOYANCY" = "xno"; then
AC_MSG_ERROR([Add '--enable-buoyancy' for balance mode.])
fi
else
AC_MSG_RESULT([no])
fi
ENABLE_DEBUG='no'
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug], [compile in debug mode (default=no)])],
[ENABLE_DEBUG=$enableval])
AM_CONDITIONAL([ENABLE_DEBUG], [test "$ENABLE_DEBUG" = "yes"])
AC_MSG_CHECKING([whether we are compiling in debug mode])
if test "x$ENABLE_DEBUG" = "xyes"; then
AC_MSG_RESULT([yes])
FCFLAGS="$FCFLAGS -Wall -Wno-maybe-uninitialized -Werror -g -O0"
FCFLAGS="$FCFLAGS -fcheck=all -fbounds-check -fbacktrace -ffpe-trap=invalid,zero,overflow,underflow"
FCFLAGS="$FCFLAGS -Wno-unused-dummy-argument"
else
AC_MSG_RESULT([no])
FCFLAGS="$FCFLAGS -O3 -funroll-all-loops -flto -DNDEBUG"
fi
ENABLE_OPENMP='no'
AC_ARG_ENABLE([openmp],
[AS_HELP_STRING([--enable-openmp], [enable OpenMP (default=no)])],
[ENABLE_OPENMP=$enableval])
AM_CONDITIONAL([ENABLE_OPENMP], [test "$ENABLE_OPENMP" = "yes"])
AC_MSG_CHECKING([whether we are enabling OpenMP])
if test "x$ENABLE_OPENMP" = "xyes"; then
AC_MSG_RESULT([yes])
FCFLAGS="$FCFLAGS -fopenmp"
else
AC_MSG_RESULT([no])
fi
ENABLE_IW_TEST_CASE='no'
AC_ARG_ENABLE([iw-test-case],
[AS_HELP_STRING([--enable-iw-test-case], [enable IW test case (default=no)])],
[ENABLE_IW_TEST_CASE=$enableval])
AM_CONDITIONAL([ENABLE_IW_TEST_CASE], [test "$ENABLE_IW_TEST_CASE" = "yes"])
AC_MSG_CHECKING([whether we are enabling the IW test case])
if test "x$ENABLE_IW_TEST_CASE" = "xyes"; then
AC_MSG_RESULT([yes])
FCFLAGS="$FCFLAGS -DENABLE_IW_TEST_CASE -DENABLE_LINEAR_STRATIFICATION"
else
AC_MSG_RESULT([no])
fi
ENABLE_RT_TEST_CASE='no'
AC_ARG_ENABLE([rt-test-case],
[AS_HELP_STRING([--enable-rt-test-case], [enable RT test case (default=no)])],
[ENABLE_RT_TEST_CASE=$enableval])
AM_CONDITIONAL([ENABLE_RT_TEST_CASE], [test "$ENABLE_RT_TEST_CASE" = "yes"])
AC_MSG_CHECKING([whether we are enabling the RT test case])
if test "x$ENABLE_RT_TEST_CASE" = "xyes"; then
AC_MSG_RESULT([yes])
FCFLAGS="$FCFLAGS -DENABLE_RT_TEST_CASE"
else
AC_MSG_RESULT([no])
fi
AC_OUTPUT