-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
477 lines (404 loc) · 14.1 KB
/
Makefile
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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# AREPO Makefile
#
# If you add a new system below, also add that systype to Template-Makefile.systype
EXEC = Arepo
LIBRARY = arepo
CONFIG = Config.sh
BUILD_DIR = build
SRC_DIR = src
###################
#determine SYSTYPE#
###################
ifdef SYSTYPE
SYSTYPE := "$(SYSTYPE)"
-include Makefile.systype
else
include Makefile.systype
endif
MAKEFILES = Makefile config-makefile
ifeq ($(wildcard Makefile.systype), Makefile.systype)
MAKEFILES += Makefile.systype
endif
$(info Build configuration:)
$(info SYSTYPE: $(SYSTYPE))
$(info CONFIG: $(CONFIG))
$(info EXEC: $(EXEC))
$(info )
PYTHON = python
PERL = /usr/bin/perl
RESULT := $(shell CONFIG=$(CONFIG) PERL=$(PERL) BUILD_DIR=$(BUILD_DIR) make -f config-makefile)
CONFIGVARS := $(shell cat $(BUILD_DIR)/arepoconfig.h)
RESULT := $(shell SRC_DIR=$(SRC_DIR) BUILD_DIR=$(BUILD_DIR) ./git_version.sh)
# Default
MPICH_INCL =
MPICH_LIB = -lmpich
GMP_LIB = -lgmp
GSL_LIB = -lgsl -lgslcblas
MATH_LIB = -lm -lstdc++
HWLOC_LIB = -lhwloc
# e.g. Mac OS using MacPorts modules for openmpi, fftw, gsl, hdf5 and hwloc
ifeq ($(SYSTYPE),"Darwin")
# compiler and its optimization options
CC = mpicc # sets the C-compiler
OPTIMIZE = -std=c11 -ggdb -O3 -Wall -Wno-format-security -Wno-unknown-pragmas -Wno-unused-function
# overwrite default:
MPICH_LIB = -lmpi
GSL_INCL = -I/opt/local/include
GSL_LIB = -L/opt/local/lib -lgsl -lgslcblas
HWLOC_LIB = -L/opt/local/lib -lhwloc
# libraries that are included on demand, depending on Config.sh options
FFTW_INCL = -I/opt/local/include -I/usr/local/include
FFTW_LIBS = -L/opt/local/lib -I/usr/local/lib
HDF5_INCL = -I/opt/local/include -DH5_USE_16_API
HDF5_LIB = -L/opt/local/lib -lhdf5 -lz
HWLOC_INCL= -I/opt/local/include
endif
# end of Darwin
# Ubuntu Linux
ifeq ($(SYSTYPE),"Ubuntu")
# compiler and its optimization options
CC = mpicc
OPTIMIZE = -std=c11 -ggdb -O3 -Wall -Wno-format-security -Wno-unknown-pragmas -Wno-unused-function
# overwrite default:
MPICH_INCL= -I/home/alankar/comp_libs/mpich/include
MPICH_LIB = -L/home/alankar/comp_libs/mpich/lib -lmpi
GSL_INCL = -I/home/alankar/comp_libs/gsl/include
GSL_LIB = -L/home/alankar/comp_libs/gsl/lib -lgsl -lgslcblas
GMP_LIB = -L/home/alankar/comp_libs/gmp/lib -lgmp
HWLOC_LIB = -lhwloc
# libraries that are included on demand, depending on Config.sh options
FFTW_INCL = -I/home/alankar/comp_libs/fftw/parallel/include
FFTW_LIBS = -L/home/alankar/comp_libs/fftw/parallel/lib
HDF5_INCL = -I/home/alankar/comp_libs/hdf5/parallel/include -DH5_USE_16_API
HDF5_LIB = -L/home/alankar/comp_libs/hdf5/parallel/lib -lhdf5 -lz
HWLOC_INCL=
endif
# end of Ubuntu
# Aryabhatta cluster
ifeq ($(SYSTYPE),"Aryabhatta")
# # compiler and its optimization options
CC = mpiicc
OPTIMIZE = -std=c11 -ggdb -O3 -Wall -Wno-format-security -Wno-unknown-pragmas -Wno-unused-function
#
# # overwrite default:
MPICH_LIB = -lmpi
GSL_LIB = -lgsl -lgslcblas
GMP_LIB = -lgmp
HWLOC_LIB = -lhwloc
#
# # libraries that are included on demand, depending on Config.sh options
HDF5_INCL = -DH5_USE_16_API
HDF5_LIB = -lhdf5 -lz
endif
# # end of Aryabhatta cluster
# Chandra cluster
ifeq ($(SYSTYPE),"Chandra")
# # compiler and its optimization options
CC = mpicc
OPTIMIZE = -std=c11 -ggdb -O3 -Wall -Wno-format-security -Wno-unknown-pragmas -Wno-unused-function
#
# # # overwrite default:
MPICH_LIB = -lmpi
GSL_LIB = -lgsl -lgslcblas
GMP_LIB = -lgmp
HWLOC_LIB = -lhwloc
# #
# # # libraries that are included on demand, depending on Config.sh options
HDF5_INCL = -DH5_USE_16_API
HDF5_LIB = -lhdf5 -lz
endif
# # end of Chandra cluster
#
# Freya cluster
ifeq ($(SYSTYPE),"Freya")
# # compiler and its optimization options
CC = mpicc
OPTIMIZE = -std=c11 -ggdb -O3 -Wall -Wno-format-security -Wno-unknown-pragmas -Wno-unused-function -Wundef -march=native
#
# # # overwrite default:
MPICH_LIB = -lmpi -L/mpcdf/soft/SLE_15/packages/skylake/openmpi/gcc_10-10.3.0/4.0.7/lib
GSL_LIB = -lgsl -lgslcblas -L/mpcdf/soft/SLE_15/packages/skylake/gsl/gcc_10-10.3.0/2.4/lib
GMP_LIB = -lgmp
HWLOC_LIB = -lhwloc
# #
# # # libraries that are included on demand, depending on Config.sh options
HDF5_INCL = -I/mpcdf/soft/SLE_15/packages/skylake/hdf5/gcc_10-10.3.0-openmpi_4-4.0.7/1.12.0/include -DH5_USE_16_API
HDF5_LIB = -lhdf5 -lz -L/mpcdf/soft/SLE_15/packages/skylake/hdf5/gcc_10-10.3.0-openmpi_4-4.0.7/1.12.0/lib
GSL_INCL = -I/mpcdf/soft/SLE_15/packages/skylake/gsl/gcc_10-10.3.0/2.4/include
# libraries that are included on demand, depending on Config.sh options
FFTW_INCL = -I/mpcdf/soft/SLE_15/packages/skylake/fftw/gcc_10-10.3.0-openmpi_4-4.0.7/3.3.10/include
FFTW_LIBS = -lfftw3 -L/mpcdf/soft/SLE_15/packages/skylake/fftw/gcc_10-10.3.0-openmpi_4-4.0.7/3.3.10/lib
endif
# # end of Freya cluster
#
# insert the library paths for your system here, similar to SYSTYPE "Darwin" above
ifndef LINKER
LINKER = $(CC)
endif
##########################################
#determine the needed object/header files#
##########################################
SUBDIRS = . \
debug_md5 \
domain \
gitversion \
gravity \
gravity/pm \
hydro \
init \
io \
main \
mesh \
mesh/voronoi \
mpi_utils \
ngbtree \
pm \
star_formation \
time_integration \
utils
OBJS = debug_md5/calc_checksum.o \
debug_md5/Md5.o \
domain/domain.o \
domain/domain_balance.o \
domain/domain_box.o \
domain/domain_counttogo.o \
domain/domain_DC_update.o \
domain/domain_exchange.o \
domain/domain_rearrange.o \
domain/domain_sort_kernels.o \
domain/domain_toplevel.o \
domain/domain_vars.o \
domain/peano.o \
gravity/accel.o \
gravity/forcetree.o \
gravity/forcetree_ewald.o \
gravity/forcetree_optimizebalance.o \
gravity/forcetree_walk.o \
gravity/grav_external.o \
gravity/grav_softening.o \
gravity/gravdirect.o \
gravity/gravtree.o \
gravity/gravtree_forcetest.o \
gravity/longrange.o \
gravity/pm/pm_periodic2d.o \
gravity/pm/pm_periodic.o \
gravity/pm/pm_mpi_fft.o \
gravity/pm/pm_nonperiodic.o \
hydro/finite_volume_solver.o \
hydro/gradients.o \
hydro/riemann.o \
hydro/riemann_hllc.o \
hydro/riemann_hlld.o \
hydro/scalars.o \
hydro/update_primitive_variables.o \
hydro/wind.o \
init/begrun.o \
init/density.o \
init/init.o \
io/global.o \
io/hdf5_util.o \
io/io.o \
io/io_fields.o \
io/logs.o \
io/parameters.o \
io/read_ic.o \
io/restart.o \
main/allvars.o \
main/main.o \
main/run.o \
mesh/criterion_derefinement.o \
mesh/criterion_refinement.o \
mesh/refinement.o \
mesh/set_vertex_velocities.o \
mesh/voronoi/voronoi.o \
mesh/voronoi/voronoi_1d.o \
mesh/voronoi/voronoi_1d_spherical.o \
mesh/voronoi/voronoi_3d.o \
mesh/voronoi/voronoi_check.o \
mesh/voronoi/voronoi_derefinement.o \
mesh/voronoi/voronoi_dynamic_update.o \
mesh/voronoi/voronoi_exchange.o \
mesh/voronoi/voronoi_ghost_search.o \
mesh/voronoi/voronoi_gradients_lsf.o \
mesh/voronoi/voronoi_gradients_onedims.o \
mesh/voronoi/voronoi_refinement.o \
mesh/voronoi/voronoi_utils.o \
mpi_utils/checksummed_sendrecv.o \
mpi_utils/hypercube_allgatherv.o \
mpi_utils/mpi_util.o \
mpi_utils/myalltoall.o \
mpi_utils/sizelimited_sendrecv.o \
mpi_utils/pinning.o \
ngbtree/ngbtree.o \
ngbtree/ngbtree_search.o \
ngbtree/ngbtree_walk.o \
star_formation/sfr_eEOS.o \
star_formation/starformation.o \
time_integration/darkenergy.o \
time_integration/do_gravity_hydro.o \
time_integration/driftfac.o \
time_integration/predict.o \
time_integration/timestep.o \
time_integration/timestep_treebased.o \
utils/allocate.o \
utils/debug.o \
utils/mpz_extension.o \
utils/mymalloc.o \
utils/parallel_sort.o \
utils/system.o
INCL += debug_md5/Md5.h \
domain/bsd_tree.h \
domain/domain.h \
gitversion/version.h\
gravity/forcetree.h \
main/allvars.h \
main/proto.h \
mesh/mesh.h \
mesh/voronoi/voronoi.h \
time_integration/timestep.h \
utils/dtypes.h \
utils/generic_comm_helpers2.h \
utils/timer.h
ifeq (TWODIMS,$(findstring TWODIMS,$(CONFIGVARS)))
OBJS += mesh/voronoi/voronoi_2d.o
endif
ifeq (MYIBARRIER,$(findstring MYIBARRIER,$(CONFIGVARS)))
OBJS += mpi_utils/myIBarrier.o
INCL += mpi_utils/myIBarrier.h
endif
ifeq (MHD,$(findstring MHD,$(CONFIGVARS)))
OBJS += hydro/mhd.o
endif
ifeq (ADDBACKGROUNDGRID,$(findstring ADDBACKGROUNDGRID,$(CONFIGVARS)))
OBJS += add_backgroundgrid/add_bggrid.o \
add_backgroundgrid/calc_weights.o \
add_backgroundgrid/distribute.o
INCL += add_backgroundgrid/add_bggrid.h
SUBDIRS += add_backgroundgrid
endif
ifeq (COOLING,$(findstring COOLING,$(CONFIGVARS)))
OBJS += cooling/cooling.o
INCL += cooling/cooling_vars.h \
cooling/cooling_proto.h
SUBDIRS += cooling
endif
ifeq (FOF,$(findstring FOF,$(CONFIGVARS)))
OBJS += fof/fof.o \
fof/fof_distribute.o \
fof/fof_findgroups.o \
fof/fof_io.o \
fof/fof_nearest.o \
fof/fof_sort_kernels.o \
fof/fof_vars.o
INCL += fof/fof.h
SUBDIRS += fof
endif
ifeq (SUBFIND,$(findstring SUBFIND,$(CONFIGVARS)))
OBJS += subfind/subfind.o \
subfind/subfind_vars.o \
subfind/subfind_serial.o \
subfind/subfind_coll_tree.o \
subfind/subfind_properties.o \
subfind/subfind_so.o \
subfind/subfind_distribute.o \
subfind/subfind_collective.o \
subfind/subfind_findlinkngb.o \
subfind/subfind_nearesttwo.o \
subfind/subfind_loctree.o \
subfind/subfind_coll_domain.o \
subfind/subfind_coll_treewalk.o \
subfind/subfind_density.o \
subfind/subfind_io.o \
subfind/subfind_sort_kernels.o \
subfind/subfind_reprocess.o \
subfind/subfind_so_potegy.o
INCL += subfind/subfind.h
SUBDIRS += subfind
endif
################################
#determine the needed libraries#
################################
# we only need fftw if PMGRID is turned on, make sure variable is empty otherwise
FFTW_LIB =
ifeq (PMGRID, $(findstring PMGRID, $(CONFIGVARS)))
ifeq (DOUBLEPRECISION_FFTW,$(findstring DOUBLEPRECISION_FFTW,$(CONFIGVARS))) # test for double precision libraries
FFTW_LIB = $(FFTW_LIBS) -lfftw3
else
FFTW_LIB = $(FFTW_LIBS) -lfftw3f
endif
endif
ifneq (HAVE_HDF5,$(findstring HAVE_HDF5,$(CONFIGVARS)))
HDF5_INCL =
HDF5_LIB =
endif
ifneq (IMPOSE_PINNING,$(findstring IMPOSE_PINNING,$(CONFIGVARS)))
HWLOC_INCL =
HWLOC_LIB =
endif
##########################
#combine compiler options#
##########################
CFLAGS = $(OPTIMIZE) $(MPICH_INCL) $(HDF5_INCL) $(GSL_INCL) $(FFTW_INCL) $(HWLOC_INCL) -I$(BUILD_DIR)
LIBS = $(GMP_LIB) $(MATH_LIB) $(MPICH_LIB) $(HDF5_LIB) $(GSL_LIB) $(FFTW_LIB) $(HWLOC_LIB)
FOPTIONS = $(OPTIMIZE)
FFLAGS = $(FOPTIONS)
SUBDIRS := $(addprefix $(BUILD_DIR)/,$(SUBDIRS))
OBJS := $(addprefix $(BUILD_DIR)/,$(OBJS)) $(BUILD_DIR)/compile_time_info.o $(BUILD_DIR)/compile_time_info_hdf5.o $(BUILD_DIR)/version.o
INCL := $(addprefix $(SRC_DIR)/,$(INCL)) $(BUILD_DIR)/arepoconfig.h
TO_CHECK := $(addsuffix .check, $(OBJS) $(patsubst $(SRC_DIR)%, $(BUILD_DIR)%, $(INCL)) )
TO_CHECK += $(BUILD_DIR)/Makefile.check
CONFIG_CHECK = $(BUILD_DIR)/$(notdir $(CONFIG)).check
DOCS_CHECK = $(BUILD_DIR)/README.check
################
#create subdirs#
################
RESULT := $(shell mkdir -p $(SUBDIRS) )
#############
#build rules#
#############
all: check build
build: $(EXEC)
$(EXEC): $(OBJS)
$(LINKER) $(OPTIMIZE) $(OBJS) $(LIBS) -o $(EXEC)
lib$(LIBRARY).a: $(filter-out $(BUILD_DIR)/main/main.o,$(OBJS))
$(AR) -rcs lib$(LIBRARY).a $(OBJS)
clean:
@echo Cleaning all build files...
@rm -f $(OBJS) $(EXEC) lib$(LIBRARY).a
@rm -f $(BUILD_DIR)/compile_time_info.c $(BUILD_DIR)/compile_time_info_hdf5.c $(BUILD_DIR)/arepoconfig.h
@rm -f $(BUILD_DIR)/version.c
@rm -f $(TO_CHECK) $(CONFIG_CHECK)
@rm -rf $(BUILD_DIR)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(INCL) $(MAKEFILES)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/compile_time_info.o: $(BUILD_DIR)/compile_time_info.c $(MAKEFILES)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/compile_time_info_hdf5.o: $(BUILD_DIR)/compile_time_info_hdf5.c $(MAKEFILES)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cu $(INCL) $(MAKEFILES)
$(NVCC) -c $< -o $@
# sanity checks:
check: $(CONFIG_CHECK)
check_docs: $(DOCS_CHECK)
$(CONFIG_CHECK): $(TO_CHECK) $(CONFIG) check.py
@$(PYTHON) check.py 2 $(CONFIG) $(CONFIG_CHECK) defines_extra $(TO_CHECK)
$(BUILD_DIR)/%.o.check: $(SRC_DIR)/%.c Template-Config.sh defines_extra check.py
@$(PYTHON) check.py 1 $< $@ Template-Config.sh defines_extra
$(BUILD_DIR)/%.o.check: $(SRC_DIR)/%.F
touch $@
$(BUILD_DIR)/%.o.check: $(SRC_DIR)/%.f90
touch $@
$(BUILD_DIR)/%.o.check: $(SRC_DIR)/%.F90
touch $@
$(BUILD_DIR)/%.o.check: $(SRC_DIR)/%.cc
touch $@
$(BUILD_DIR)/%.h.check: $(SRC_DIR)/%.h Template-Config.sh defines_extra check.py
@$(PYTHON) check.py 1 $< $@ Template-Config.sh defines_extra
$(BUILD_DIR)/%.o.check: $(BUILD_DIR)/%.c Template-Config.sh defines_extra check.py
@$(PYTHON) check.py 1 $< $@ Template-Config.sh defines_extra
$(BUILD_DIR)/%.h.check: $(BUILD_DIR)/%.h Template-Config.sh defines_extra check.py
@$(PYTHON) check.py 1 $< $@ Template-Config.sh defines_extra
$(BUILD_DIR)/Makefile.check: Makefile Template-Config.sh defines_extra check.py
@$(PYTHON) check.py 3 $< $@ Template-Config.sh defines_extra
$(BUILD_DIR)/Config.check: Template-Config.sh check.py
@$(PYTHON) check.py 4 Template-Config.sh $@