-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure.ac
399 lines (360 loc) · 12.8 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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# Configure script for MIT IGSM. See DEVELOPERS.md
### Initialization
AC_PREREQ([2.66])
AC_INIT(igsm, [1.0], [[email protected]])
AM_INIT_AUTOMAKE([foreign subdir-objects])
# check that $srcdir points to the actual location of the source code
AC_CONFIG_SRCDIR([src/atm/atmosphere.F])
# …but that we are not in the top source directory
if test -z "$srcdir" -o "$srcdir" = "."; then
AC_MSG_ERROR([must be invoked from within a build directory. See
./build/README.])
fi
# generate ctrparam.h
AC_CONFIG_HEADERS([ctrparam.h])
### Package options
# This section defines the command-line options accepted by 'configure'. For
# usage instructions, run './configure --help'.
# Package option for model configurations
AC_ARG_WITH([setup],
[AS_HELP_STRING([--with-setup],
[model version to compile: either 'climate' (implies --without-tem), \
'historical' or 'fullchem' (default)])],
[if test $withval != climate -a $withval != historical -a $withval != fullchem; then
AC_MSG_ERROR([invalid value '$withval' for --with-setup; try --help])
else
model=$withval
fi],
[model=fullchem])
# Package option for ocean carbon
AC_ARG_ENABLE([ocncarbon],
[AS_HELP_STRING([--enable-ocncarbon],
[enable the ocean carbon model (default for --with-setup=historical and \
fullchem)])],
[ocncarbon=$enableval],
[if test $model != climate; then
ocncarbon=yes
else
ocncarbon=no
fi])
# Package option for the urban metamodel
AC_ARG_ENABLE([meta],
[AS_HELP_STRING([--enable-meta],
[enable the urban metamodel (default for --with-setup=fullchem)])],
[meta=$enableval],
[if test $model = fullchem; then
meta=yes
else
meta=no
fi])
# Package option for 2D or 3D ocean
AC_ARG_ENABLE([mitgcm],
[AS_HELP_STRING([--enable-mitgcm],
[instead of the 2D ocean, produce libraries suitable for linking with the \
MITgcm three-dimensional ocean model, and don't produce an igsm22 \
executable])],
[ocean=3D],
[ocean=2D])
# Package option for chemistry module
AC_ARG_WITH([chem],
[AS_HELP_STRING([--with-chem],
[select version of the atmospheric chemistry model: ARG=95 or 12 (default)])],
[CHEM_VERSION=$withval],
[CHEM_VERSION=12])
# Package option for CLM module
AC_ARG_ENABLE([clm],
[AS_HELP_STRING([--enable-clm],
[enable the Common Land Model v3.5 module (default); \
--disable-clm implies --disable-tem])],
[clm=$enableval],
[clm=yes])
# Package option for TEM version
AC_ARG_ENABLE([tem],
[AS_HELP_STRING([--enable-tem],
[enable the Terrestrial Ecosystem Model (default for \
--with-setup=historical and fullchem)])],
[tem=$enableval],
[if test $model = climate -o $clm = no; then
tem=no
else
tem=yes
fi])
# check that the user gave sensible arguments
if test $clm = no -a $tem = yes; then
AC_MSG_ERROR([cannot give both --disable-clm and --enable-tem])
fi
# Package option for tracers
AC_ARG_ENABLE([tracers],
[AS_HELP_STRING([--enable-tracers],
[enable non-reactive substances for tracing (default: disabled)])],
[tracers=$enableval],
[tracers=no])
### Build environment & language features
# This section checks whether certain common language features are available in
# the build environment. It was mostly generated by autoscan.
# TODO: examine individual checks like AC_FUNC_REALLOC and see whether the IGSM
# code actually responds to them. If not, remove.
# C++ compiler
AC_PROG_CXX([pgCC pgc++])
# TODO ugly hack; remove as soon as possible
if test $HOSTNAME = svante; then
IGSM_LDADD_EXTRA="-lstd -lC"
fi
# C compiler
AC_PROG_CC(pgcc)
# Fortran 77 compiler
AC_PROG_F77
# Fortran 90+ compiler
AC_PROG_FC(pgf90)
# FIXME: this is cheating. The IGSM modules atm, ocm, ocn_ml and meta contain
# Fortran files with the extension '.F', which typically denotes Fortran 77, but
# are actually Fortran 90 code with
F77=$FC
# TODO: the following three checks may not be necessary. Remove if possible.
AC_FC_DUMMY_MAIN
AC_FC_LIBRARY_LDFLAGS
AC_FC_MAIN
AC_SUBST([MPI_FC], [mpif90])
AC_PROG_RANLIB
AC_PROG_MAKE_SET
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_INLINE
# Checks for C library functions
AC_CHECK_FUNCS([modf pow])
# Checks for NetCDF C libraries.
AC_CHECK_PROG([HAVE_NCCONFIG], [nc-config], yes)
if test -z $HAVE_NCCONFIG; then
AC_MSG_ERROR([Cannot find NetCDF configuration utility 'nc-config'.])]
fi
CFLAGS+=" $(nc-config --cflags)"
CPPFLAGS+=" $(nc-config --cflags)"
LIBS+=" $(nc-config --libs)"
AC_CHECK_HEADER([netcdf.h], [AC_CHECK_LIB([netcdf], [nc_inq_libvers])])
# Checks for NetCDF Fortran libraries.
AC_CHECK_PROG([HAVE_NFCONFIG], [nf-config], yes)
if test -z $HAVE_NFCONFIG; then
AC_MSG_ERROR([Cannot find NetCDF configuration utility 'nf-config'.])]
fi
FFLAGS+=" $(nf-config --fflags)"
FCFLAGS+=" $(nf-config --fflags)"
LIBS+=" $(nf-config --flibs)"
AC_LANG_PUSH([Fortran])
AC_MSG_CHECKING([[for nf_inq_libvers in -lnetcdff]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(, [
include 'netcdf.inc'
print *, nf_inq_libvers()])],
[AC_MSG_RESULT([yes])], [AC_MSG_FAILURE([no])])
AC_MSG_CHECKING([[for nf90_inq_libvers in -lnetcdff]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(, [
use netcdf
print *, nf90_inq_libvers()])],
[AC_MSG_RESULT([yes])], [AC_MSG_FAILURE([cannot find netcdf.mod.])])
AC_LANG_POP([Fortran])
# NetCDF Fortran paths for CLM.
AC_SUBST(INC_NETCDF, $(nf-config --includedir))
AC_SUBST(LIB_NETCDF, $(nf-config --flibs | cut -d' ' -f1 | cut -dL -f2))
# Checks for OpenMPI libraries, used for 3D ocean only.
if test $ocean = 3D; then
AC_CHECK_PROG([HAVE_MPI], [ompi_info], yes)
if test -z $HAVE_MPI; then
AC_MSG_ERROR([cannot find OpenMPI configuration utility 'ompi_info'.])]
fi
INC_MPI=`ompi_info --parseable --path incdir | cut -d: -f 3`
LIB_MPI=`ompi_info --parseable --path libdir | cut -d: -f 3`
FCFLAGS+=" -I$INC_MPI"
AC_LANG_PUSH([Fortran])
AC_MSG_CHECKING([for mpif.h])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(,[
include 'mpif.h'])],
[AC_MSG_RESULT(yes)], [AC_MSG_ERROR(no)])
AC_LANG_POP
AC_SUBST(INC_MPI)
AC_SUBST(LIB_MPI)
fi
# Common compiler flags for all IGSM code.
FFLAGS+=" -r8 -i4"
CXXFLAGS+=" -Mscalarsse -fpic"
# Conditional for use in Makefiles
AM_CONDITIONAL([IGSM_2D], [test $ocean = 2D])
### Binaries and modules to build
# Based on the package options, this section controls whether individual modules
# of the IGSM are built or not by populating MODULE_DIRS (see src/Makefile.am).
# It also sets the libraries to link against (MODULE_LDADD). The order of these
# is important and should not be disturbed.
# 1. Multilayer 2D ocean, atmosphere, ocean carbon
if test $ocean = 2D; then
# only build the igsm22 executable if using the 2D ocean
BINARIES="igsm22"
MODULE_DIRS=" ocn_ml"
MODULE_LDADD="atm/libatm.a ocn_ml/libml.a"
# the ocm module is only for carbon in a 2D ocean
if test $ocncarbon = yes; then
# build an ocean spin-up executable
BINARIES+=" igsm22ocm"
MODULE_DIRS+=" ocm"
MODULE_LDADD+=" ocm/libocm.a"
fi
else
# only build the igsm23 executables if using the 3D ocean
BINARIES="igsm23_driver igsm23_ocean"
MODULE_DIRS=" ocn_3d"
# the 3D ocean module must be listed *before* libatm.a
MODULE_LDADD="ocn_3d/libocn_3d.a atm/libatm.a"
fi
# 2. Community Land Model
if test $clm = yes; then
MODULE_DIRS+=" clm"
MODULE_LDADD+=" clm/libclm.a"
# give CLM35_TEM a default value; overwritten in the next section if TEM
# actually is enabled
CLM35_TEM="off"
# commented...
# the CLM directory must be symlinked from within the build tree, because CLM
# has its own build system
#AC_CONFIG_LINKS([clm:clm])
# ...copy the source instead
AC_CONFIG_COMMANDS([clm],
[mkdir -p src/clm && cp -r $srcdir/src/clm/* src/clm])
# 3. Terrestrial Ecosystem Model
if test $tem = yes; then
MODULE_DIRS+=" tem"
MODULE_LDADD+=" tem/libtem.a"
CLM35_TEM="on"
fi
AC_SUBST(CLM35_TEM)
AC_CONFIG_FILES([src/clm/Makefile])
fi
# 4. Atmospheric chemistry model
if test $model = fullchem; then
MODULE_DIRS+=" chem"
MODULE_LDADD+=" chem/libchem.a"
fi
# 5. Urban airshed metamodel
if test $meta = yes; then
MODULE_DIRS+=" meta"
MODULE_LDADD+=" meta/libmeta.a"
fi
# 6. Tracers
if test $tracers = yes; then
MODULE_DIRS+=" tracers"
MODULE_LDADD+=" tracers/libtracers.a"
fi
# substitute the resulting variables in src/Makefile.am
AC_SUBST(BINARIES)
AC_SUBST(MODULE_DIRS)
AC_SUBST(MODULE_LDADD)
AC_SUBST(IGSM_LDADD_EXTRA)
### Defines.
# This section sets the C/C++/Fortran preprocessor symbols (#define) that are
# written to ctrparam.h.
# Common defines for all model configurations
AC_DEFINE(N_LAT, 46, [Number of latitudinal grid points])
AC_DEFINE(N_LEV, 11, [Number of vertical pressure layers])
AC_DEFINE(N_LEVOCEAN, 11, [Number of vertical layers in diffusive ocean model
(either 11 or 12)]) #code here not properly if-defed, always include
AC_DEFINE(N_LON0, 72, [Number of longitudinal grid points; unused, but must be
must be 72 for N_LAT=46 (per atm/check_settings.F)])
AC_DEFINE(NYR_CHEM, 1, [Number of year of chemistry model integration (124 for
period from 1977 to 2100)]) #this need in chem common blocks, always included
AC_DEFINE(O3_TOP_SPARC, 1, [Use sparc stratospheric ozone in radiation module])
# Defines when using CLM and TEM
if test $clm = yes; then
AC_DEFINE(CLM, 1, [Coupling CLM])
AC_DEFINE(CLM35, 1, [Coupling CLM 3.5])
if test $tem = yes; then
AC_DEFINE(CPL_TEM, 1, [Coupling chemistry])
AC_DEFINE(CPL_NEM, 1, [Coupling natural emission model])
fi
fi
# Defines depending on 2D vs. 3D ocean
if test $ocean = 2D; then
AC_DEFINE(ML_2D, 1, [Two-dimensional ocean])
else
AC_DEFINE(OCEAN_3D, 1, [Three-dimensional ocean])
fi
# the ocm module is for carbon in 2D or 3D oceans
if test $ocncarbon = yes; then
AC_DEFINE(CPL_OCEANCO2, 1, [Coupling ocean CO2 model])
fi
# Defines that depend on whether chemistry is included
if test $model = fullchem; then
AC_DEFINE(CPL_CHEM, 1, [Coupling chemistry])
# NYR_CHEM, PREDICTED_* always accompany CPL_CHEM
AC_DEFINE(PREDICTED_GASES, 1, [Use predicted concentrations of chemical
species by chemistry model to calculate radiative forcing (ifghgpredict)])
AC_DEFINE(PREDICTED_AEROSOL, 1, [Use predicted aerosol concentrations by
chemistry model to calculate radiative forcing (ifaerpredict)])
AC_DEFINE(PREDICTED_BC, 1, [Use predicted black carbon concentrations by
chemistry model to calculate radiative forcing])
# OLD_CHEM only for the old version
if test $CHEM_VERSION = 95; then
AC_DEFINE(OLD_CHEM, 1, [Old (1995) version of the atmospheric chemistry
model is in use])
fi
# more options for chemistry runs only
AC_DEFINE(INC_3GASES, 1, [Including "3 gases"])
AC_DEFINE(O3_RAD, 1, [Use predicted ozone in radiation module])
if test $meta = yes; then
AC_DEFINE(CPL_META, 1, [Coupling parameterized urban airshed model (meta)])
fi
fi
# Defines for climate or historical mode
if test $model = climate -o $model = historical ; then
AC_DEFINE(O3_FORCED, 1, [Use forced ozone scenario (ifo3forced)])
fi
# Defines for historical mode only
if test $model = historical; then
AC_DEFINE(SVI_ALBEDO, 1, [Modify albedo to simulate sulfate aerosol forcing
(ifsulfalb)])
fi
# Defines for historical or fullchem mode
if test $model = historical -o $model = fullchem; then
AC_DEFINE(VOL_AER, 1, [Include aerosol forcing due to volcanic activitiy])
fi
# Unusual defines. See DEVELOPERS.md for information on how to use these.
if true; then
# always ON
AC_DEFINE(IPCC_FORCING, 1, [Use IPCC Forcings rather than GISS])
else
# always OFF
AC_DEFINE(ORBITAL_FOR, 1, [Use radiative forcing adjusted for Earth's
orbital parameters. If undefined, the default from a (which?) NASA GISS
model is used])
AC_DEFINE(ACCRI, 1, [Include GHG emissions from aviation. Requires accri_data
and accri_scaling defined in eppaemis.dat])
AC_DEFINE(DATA4TEM, 1, [Save data for offline simulations with CLM/TEM])
AC_DEFINE(FIXED_FOR, 1, [Run model with fixed GHG forcing. TEM and OCM will
see changing CO2, while radiation code uses GHGs in the start year (yeargt
in name.dat)])
AC_DEFINE(FIXED_PCO2, 1, [Fix CO2 for TEM and OCM])
AC_DEFINE(GHS_ALB, 1, [TODO: remove this symbol (1 reference in
atm/r95mit.F)])
AC_DEFINE(HR_DATA, 1, [(with DATA4TEM) write data hourly])
AC_DEFINE(IPCC_EMI, 1, [Use a simple carbon model with carbon emissions from
the file specified by co2_data in name.dat])
AC_DEFINE(OLD_LAPGAS, 1, [Use an old way of handling greenhouse effects of
different gases in atm/radia0.F (for backwards compatibility)])
AC_DEFINE(WR_RADMN, 1, [Write yz concentration used in radiation])
fi
### Output Makefiles
AC_CONFIG_FILES([Makefile
src/Makefile
src/atm/Makefile
src/chem/Makefile
src/inc/AGRID.h
src/inc/Makefile
src/meta/Makefile
src/ocm/Makefile
src/ocn_3d/Makefile
src/ocn_3d/options.sh
src/ocn_ml/Makefile
src/tem/Makefile
src/tracers/Makefile
util/Makefile
util/analysis/Makefile
util/eppa/Makefile])
AC_OUTPUT