-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathGMaestro.mak
344 lines (258 loc) · 10.6 KB
/
GMaestro.mak
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
# A set of useful macros for putting together a MAESTRO application.
# system blas
BLAS_LIBRARY ?= -lopenblas
# check the version number -- this comes from the GNU Make cookbook
NEED := 3.81
OK := $(filter $(NEED),$(firstword $(sort $(MAKE_VERSION) $(NEED))))
ifndef OK
$(error your version of GNU make is too old. You need atleast version $(NEED))
endif
# Make sure we have FBoxLib and that the build system will find it
ifdef FBOXLIB_HOME
ifeq ($(findstring ~, $(FBOXLIB_HOME)), ~)
$(error you cannot include the ~ character in your FBOXLIB_HOME variable)
endif
else
$(error Maestro requires FBoxLib. Please ensure that you have downloaded it and set $$FBOXLIB_HOME appropriately)
endif
# include the main Makefile stuff
include $(FBOXLIB_HOME)/Tools/F_mk/GMakedefs.mak
# default target (make just takes the one that appears first)
ALL: main.$(suf).exe
#-----------------------------------------------------------------------------
# core AMREX directories
FBOXLIB_CORE := Src/BaseLib \
Src/MultiGrid
# include the random number generator stuff
RANDOM := t
#-----------------------------------------------------------------------------
# core MAESTRO directories
MAESTRO_CORE :=
# path to SDC files -- note this must come before Source/ in the vpath
SDC_CORE :=
ifdef SDC
SDC_CORE += $(MAESTRO_TOP_DIR)/Source_SDC
endif
# next look for the files in Source/ itself
#
# Note: a unit test (UNIT_TEST := t) tests only a single component
# of the MAESTRO algorithm, so we don't, in general, want to build
# all of the source in the MAESTRO/Source directory. So, for unit
# tests, we leave it off the list of core directories, but do
# include it in the VPATH
#
# Setting FBOXLIB_ONLY := t means that we don't even want the
# MAESTRO/Source directory in our VPATH
ifndef UNIT_TEST
ifndef FBOXLIB_ONLY
MAESTRO_CORE += Source
endif
endif
#-----------------------------------------------------------------------------
# core extern directories needed by every MAESTRO build
UTIL_CORE :=
ifndef FBOXLIB_ONLY
UTIL_CORE := Util/model_parser
endif
UTIL_CORE += Util/simple_log
#-----------------------------------------------------------------------------
# microphysics
# default to $(MICROPHYSICS_HOME) for the EOS unless we are gamma_law_general
ifeq ($(EOS_DIR), gamma_law_general)
EOS_TOP_DIR := $(MAESTRO_HOME)/Microphysics/EOS
else
EOS_TOP_DIR := $(MICROPHYSICS_HOME)/EOS
endif
# we need all the thermodynamics
FPP_DEFINES += -DEXTRA_THERMO
# we are not using the CUDA stuff
FPP_DEFINES += -DAMREX_DEVICE=""
# support sparse Jacobian interface in Microphysics
ifeq ($(USE_REACT_SPARSE_JACOBIAN), TRUE)
FPP_DEFINES += -DREACT_SPARSE_JACOBIAN
# The following is sometimes useful to turn on for debugging sparse J indices
# (if a get/set/scale is called with (row, col) not in the sparse J, stop)
# Otherwise, set/scale do nothing, and get returns 0.
ifeq ($(USE_SPARSE_STOP_ON_OOB), TRUE)
FPP_DEFINES += -DSPARSE_STOP_ON_OOB
endif
endif
ifeq ($(EOS_DIR), helmeos)
EOS_DIR := helmholtz
$(info EOS_DIR = helmeos is deprecated. Please use helmholtz instead)
endif
# the helmeholtz eos has an include file -- also add a target to link
# the table into the problem directory.
ifeq ($(findstring helmholtz, $(EOS_DIR)), helmholtz)
EOS_PATH := $(EOS_TOP_DIR)/helmholtz
ALL: table
endif
table:
@if [ ! -f helm_table.dat ]; then echo ${bold}Linking helm_table.dat${normal}; ln -s $(EOS_PATH)/helm_table.dat .; fi
# For the URCA network in Microphysics, link the rate tables
ifeq ($(findstring URCA-simple, $(NETWORK_DIR)), URCA-simple)
ALL: urcatables
endif
urcatables:
@if [ ! -f 23Ne-23Na_betadecay.dat ]; then echo ${bold}Linking 23Ne-23Na_betadecay.dat${normal}; ln -s $(NETWORK_TOP_DIR)/$(NETWORK_DIR)/23Ne-23Na_betadecay.dat .; fi
@if [ ! -f 23Na-23Ne_electroncapture.dat ]; then echo ${bold}Linking 23Na-23Ne_electroncapture.dat${normal}; ln -s $(NETWORK_TOP_DIR)/$(NETWORK_DIR)/23Na-23Ne_electroncapture.dat .; fi
# All networks except general_null should pull in the Microphysics repository.
ifneq ($(findstring general_null, $(NETWORK_DIR)), general_null)
NETWORK_TOP_DIR := $(MICROPHYSICS_HOME)/networks
include $(NETWORK_TOP_DIR)/GNetwork.mak
else
NETWORK_TOP_DIR := $(MAESTRO_TOP_DIR)/Microphysics/networks
MICROPHYS_CORE += $(NETWORK_TOP_DIR) $(NETWORK_TOP_DIR)/$(NETWORK_DIR)
endif
ifdef SYSTEM_BLAS
libraries += $(BLAS_LIBRARY)
endif
# are we using the stellar conductivity?
ifeq ($(findstring stellar, $(CONDUCTIVITY_DIR)), stellar)
CONDUCTIVITY_TOP_DIR := $(MICROPHYSICS_HOME)/conductivity
endif
ifndef CONDUCTIVITY_TOP_DIR
CONDUCTIVITY_TOP_DIR := $(MAESTRO_TOP_DIR)/Microphysics/conductivity
endif
# add in the network, EOS, and conductivity
MICROPHYS_CORE += $(MAESTRO_TOP_DIR)/Microphysics/EOS \
$(MAESTRO_TOP_DIR)/Microphysics/networks \
$(EOS_TOP_DIR) \
$(EOS_TOP_DIR)/$(EOS_DIR) \
$(MAESTRO_TOP_DIR)/Microphysics/conductivity \
$(CONDUCTIVITY_TOP_DIR)/$(CONDUCTIVITY_DIR)
#-----------------------------------------------------------------------------
# extra directory
ifndef EXTRA_TOP_DIR
EXTRA_TOP_DIR := $(MAESTRO_TOP_DIR)/
endif
EXTRAS := $(addprefix $(EXTRA_TOP_DIR)/, $(EXTRA_DIR))
ifndef EXTRA_TOP_DIR2
EXTRA_TOP_DIR2 := $(MAESTRO_TOP_DIR)/
endif
EXTRAS += $(addprefix $(EXTRA_TOP_DIR2)/, $(EXTRA_DIR2))
#-----------------------------------------------------------------------------
# compile in support for particles
PARTICLES := t
#-----------------------------------------------------------------------------
# If we are using OpenACC, add the corresponding preprocessor macro.
ifdef ACC
ifeq ($(ACC), t)
FPP_DEFINES += -DACC
endif
endif
#-----------------------------------------------------------------------------
# Fmpack is the list of all the GPackage.mak files that we need to
# include into the build system to define the list of source files.
#
# Fmlocs is the list of all the directories that we want to search
# for the source files in -- this is usually going to be the
# same as the list of directories containing GPackage.mak defined
# above.
#
# Fincs is the list of directories that have include files that
# we need to tell the compiler about.
# SDC
Fmpack := $(foreach dir, $(SDC_CORE), $(dir)/GPackage.mak)
Fmlocs := $(foreach dir, $(SDC_CORE), $(dir))
# Maestro and Util modules
Fmdirs += $(UTIL_CORE) \
$(MAESTRO_CORE)
Fmpack += $(foreach dir, $(Fmdirs), $(MAESTRO_TOP_DIR)/$(dir)/GPackage.mak)
Fmlocs += $(foreach dir, $(Fmdirs), $(MAESTRO_TOP_DIR)/$(dir))
# Microphysics
Fmpack += $(foreach dir, $(MICROPHYS_CORE), $(dir)/GPackage.mak)
Fmlocs += $(foreach dir, $(MICROPHYS_CORE), $(dir))
# Extras
Fmpack += $(foreach dir, $(EXTRAS), $(dir)/GPackage.mak)
Fmlocs += $(foreach dir, $(EXTRAS), $(dir))
# FBoxLib
Fmpack += $(foreach dir, $(FBOXLIB_CORE), $(FBOXLIB_HOME)/$(dir)/GPackage.mak)
Fmlocs += $(foreach dir, $(FBOXLIB_CORE), $(FBOXLIB_HOME)/$(dir))
# any include directories
Fmincs :=
# vpath defines the directories to search for the source files
# we always want to search the MAESTRO/Source directory, even for
# unit tests, since they may build individual files there.
ifdef UNIT_TEST
VPATH_LOCATIONS += $(MAESTRO_TOP_DIR)/Source
endif
# Note: GMakerules.mak will include '.' at the start of the
# VPATH_LOCATIONS to first search in the problem directory
VPATH_LOCATIONS += $(Fmlocs) $(EXTRA_LOCATIONS)
# include the necessary GPackage.mak files that define this setup
# but do this after VPATH_LOCATIONS
include $(Fmpack)
# list of directories to put in the Fortran include path
FINCLUDE_LOCATIONS += $(Fmincs)
#-----------------------------------------------------------------------------
# define the build instructions for the executable
main.$(suf).exe: $(objects)
$(HPCLINK) $(LINK.f90) -o main.$(suf).exe $(objects) $(libraries)
@echo SUCCESS
#-----------------------------------------------------------------------------
# runtime parameter stuff (probin.f90)
# template used by write_probin.py to build probin.f90
ifndef FBOXLIB_ONLY
PROBIN_TEMPLATE := $(MAESTRO_TOP_DIR)/Source/probin.template
else
PROBIN_TEMPLATE := $(MAESTRO_TOP_DIR)/Util/parameters/dummy.probin.template
endif
# list of the directories to search for _parameters files
PROBIN_PARAMETER_DIRS = ./
ifndef FBOXLIB_ONLY
PROBIN_PARAMETER_DIRS += $(MAESTRO_TOP_DIR)/Source
endif
# list of all valid _parameters files for probin
PROBIN_PARAMETERS := $(shell $(FBOXLIB_HOME)/Tools/F_scripts/findparams.py $(PROBIN_PARAMETER_DIRS))
# list of all valid _parameters files for extern
EXTERN_PARAMETER_DIRS += $(MICROPHYS_CORE) $(NETWORK_TOP_DIR)
EXTERN_PARAMETERS := $(shell $(FBOXLIB_HOME)/Tools/F_scripts/findparams.py $(EXTERN_PARAMETER_DIRS))
probin.f90: $(PROBIN_PARAMETERS) $(EXTERN_PARAMETERS) $(PROBIN_TEMPLATE)
@echo " "
@echo "${bold}WRITING probin.f90${normal}"
$(FBOXLIB_HOME)/Tools/F_scripts/write_probin.py \
-t $(PROBIN_TEMPLATE) -o probin.f90 -n probin \
--pa "$(PROBIN_PARAMETERS)" --pb "$(EXTERN_PARAMETERS)"
@echo " "
#-----------------------------------------------------------------------------
# build_info stuff
deppairs: build_info.f90
build_info.f90:
@echo " "
@echo "${bold}WRITING build_info.f90${normal}"
$(FBOXLIB_HOME)/Tools/F_scripts/makebuildinfo.py \
--modules "$(Fmdirs) $(MICROPHYS_CORE)" \
--FCOMP "$(COMP)" \
--FCOMP_version "$(FCOMP_VERSION)" \
--f90_compile_line "$(COMPILE.f90)" \
--f_compile_line "$(COMPILE.f)" \
--C_compile_line "$(COMPILE.c)" \
--link_line "$(LINK.f90)" \
--fboxlib_home "$(FBOXLIB_HOME)" \
--source_home "$(MAESTRO_TOP_DIR)" \
--extra_home "$(MICROPHYSICS_HOME)" \
--network "$(NETWORK_DIR)" \
--eos "$(EOS_DIR)" \
--conductivity "$(CONDUCTIVITY_DIR)"
@echo " "
$(odir)/build_info.o: build_info.f90
$(COMPILE.f90) $(OUTPUT_OPTION) build_info.f90
rm -f build_info.f90
#-----------------------------------------------------------------------------
# include the FBoxLib Makefile rules
include $(FBOXLIB_HOME)/Tools/F_mk/GMakerules.mak
#-----------------------------------------------------------------------------
# for debugging. To see the value of a Makefile variable,
# e.g. Fmlocs, simply do "make print-Fmlocs". This will
# print out the value.
print-%: ; @echo $* is $($*)
#-----------------------------------------------------------------------------
# cleaning. Add more actions to 'clean' and 'realclean' to remove
# probin.f90 and build_info.f90 -- this is where the '::' in make comes
# in handy
clean::
$(RM) probin.f90
$(RM) build_info.f90
realclean ::
$(RM) helm_table.dat