-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
349 lines (281 loc) · 12.9 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
# =====================================
# The executable name (EXECPREFIX_MODEL)
# =====================================
EXECPREFIX = MG_PICOLA
# ========================================
# Choose the machine you are running on.
# Set paths to mpicc, FFTW3 and GSL below
# ========================================
#MACHINE = SCIAMA2
#MACHINE = OKEANOS
MACHINE = WINTHERMACBOOK
# ========================
# Options for optimization
# ========================
OPTIMIZE = -O3 -Wall -std=c99
# ==================================
# Fetch any options from commandline
# ==================================
ifndef OPT
OPTIONS =
else
OPTIONS = $(OPT)
endif
# ====================================================================
# Select model. For LCDM sims one can use any of the below, but
# without scaledependent is faster so use this
# ====================================================================
ifndef MODEL
# DGP gravity
MODEL = DGP
# f(R) gravity
#MODEL = FOFR
# f(R) gravity with LCDM LPT growth factors
#MODEL = FOFR_LCDM
# General m(a),beta(a) model
#MODEL = MBETA
# Jordan-Brans-Dicke model
#MODEL = BRANSDICKE
# Massive neutrino and f(R) gravity
#MODEL = FOFRNU
endif
EXEC = $(EXECPREFIX)_$(MODEL)
$(info )
$(info =====================================================)
$(info MODEL = [${MODEL}] EXEC = [${EXEC}])
$(info External options = [${OPT}])
$(info =====================================================)
$(info )
ifeq ($(MODEL), FOFR)
# Hu-Sawicky f(R) model
MGMODEL = -DFOFRGRAVITY
OPTIONS += $(MGMODEL)
OPTIONS += -DSCALEDEPENDENT
MODELISDEFINED = TRUE
endif
ifeq ($(MODEL), FOFR_LCDM)
# f(R) for using non-scaledependent (LCDM) growth-factors
MGMODEL = -DFOFRGRAVITY
OPTIONS += $(MGMODEL)
MODELISDEFINED = TRUE
endif
ifeq ($(MODEL), DGP)
# Normal branch DGP model
MGMODEL = -DDGPGRAVITY
SMOOTHINGFILTER = -DGAUSSIANFILTER
OPTIONS += $(MGMODEL)
OPTIONS += $(SMOOTHINGFILTER)
MODELISDEFINED = TRUE
endif
ifeq ($(MODEL), BRANSDICKE)
# Brans-Dicke model
MGMODEL = -DBRANSDICKE
OPTIONS += $(MGMODEL)
MODELISDEFINED = TRUE
endif
ifeq ($(MODEL), MBETA)
# General (m,beta) parametrisation
MGMODEL = -DMBETAMODEL
OPTIONS += $(MGMODEL)
OPTIONS += -DSCALEDEPENDENT
MODELISDEFINED = TRUE
endif
ifeq ($(MODEL), FOFRNU)
# Massive neutrino and f(R) gravity
MGMODEL = -DFOFRGRAVITY
OPTIONS += $(MGMODEL)
OPTIONS += -DMASSIVE_NEUTRINOS -DSCALEDEPENDENT
MODELISDEFINED = TRUE
endif
ifndef MODELISDEFINED
$(error ERROR: MODEL is not recognized)
endif
# ====================================================================
# Various C preprocessor directives that change the way the code is made
# ====================================================================
GAUSSIAN = -DGAUSSIAN # Switch this if you want gaussian initial conditions (fnl otherwise)
OPTIONS += $(GAUSSIAN)
# ====================================================================
MEMORY_MODE = -DMEMORY_MODE # Save memory by making sure to allocate and deallocate arrays only when we need them
OPTIONS += $(MEMORY_MODE) # and by making the particle data single precision
# ====================================================================
GADGET_STYLE = -DGADGET_STYLE # If we are running snapshots this writes all the output in Gadget's '1' style format,
# with the corresponding header
OPTIONS += $(GADGET_STYLE) # This option is incompatible with LIGHTCONE simulations.
# For binary outputs with LIGHTCONE simulations use the UNFORMATTED option.
# ====================================================================
#READICFROMFILE = -DREADICFROMFILE # Read Gadget/Ramses/ascii IC files instead of creating it in the code
#OPTIONS += $(READICFROMFILE) # Needs extra parameters in the parameterfile
# ====================================================================
#MASSIVE_NEUTRINOS = -DMASSIVE_NEUTRINOS
#OPTIONS += $(MASSIVE_NEUTRINOS) # Include support for massive neutrinos
#OPTIONS += -DSCALEDEPENDENT # Massive neutrinos require scale-dependent version
# Needs extra parameters in the parameterfile
# ====================================================================
#COMPUTE_POFK = -DCOMPUTE_POFK # Compute P(k) in the code and output
#OPTIONS += $(COMPUTE_POFK) # Needs extra parameters in the parameterfile
# ====================================================================
#MATCHMAKER = -DMATCHMAKER_HALOFINDER # Switch this on to do FoF halo-finding on the fly using MatchMaker (David Alonso)
#OPTIONS += $(MATCHMAKER) # Needs extra parameters in the parameterfile
# ====================================================================
#SINGLE_PRECISION = -DSINGLE_PRECISION # Single precision floats and FFTW (else use double precision)
#OPTIONS += $(SINGLE_PRECISION)
# ====================================================================
#PARTICLE_ID = -DPARTICLE_ID # Assigns unsigned long long ID's to each particle and outputs them. This adds
#OPTIONS += $(PARTICLE_ID) # an extra 8 bytes to the storage required for each particle
# ====================================================================
#LIGHTCONE = -DLIGHTCONE # Builds a lightcone based on the run parameters and only outputs particles
#OPTIONS += $(LIGHTCONE) # at a given timestep if they have entered the lightcone
# ====================================================================
#LOCAL_FNL = -DLOCAL_FNL # Switch this if you want only local non-gaussianities
#OPTIONS += $(LOCAL_FNL) # NOTE this option is only for invariant inital power spectrum
# for local with ns != 1 use DGENERIC_FNL and input_kernel_local.txt
# ====================================================================
#EQUIL_FNL = -DEQUIL_FNL # Switch this if you want equilateral Fnl
#OPTIONS += $(EQUIL_FNL) # NOTE this option is only for invariant inital power spectrum
# for local with ns != 1 use DGENERIC_FNL and input_kernel_equil.txt
# ====================================================================
#ORTHO_FNL = -DORTHO_FNL # Switch this if you want ortogonal Fnl
#OPTIONS += $(ORTHO_FNL) # NOTE this option is only for invariant inital power spectrum
# for local with ns != 1 use DGENERIC_FNL and input_kernel_ortog.txt
# ====================================================================
#GENERIC_FNL += -DGENERIC_FNL # Switch this if you want generic Fnl implementation
#OPTIONS += $(GENERIC_FNL) # This option allows for ns != 1 and should include an input_kernel_file.txt
# containing the coefficients for the generic kernel
# see README and Manera et al astroph/NNNN.NNNN
# For local, equilateral and orthogonal models you can use the provided files
# input_kernel_local.txt, input_kernel_equil.txt, input_kernel_orthog.txt
# ====================================================================
#UNFORMATTED = -DUNFORMATTED # If we are running lightcones this writes all the output in binary.
# All the particles are output in chunks with each
#OPTIONS += $(UNFORMATTED) # chunk preceded by the number of particles in the chunk. With the chunks we output all the data
# (id, position and velocity) for a given particle contiguously
# ====================================================================
# =================================================================================================================
# Nothing below here should need changing unless you are adding in/modifying libraries for existing or new machines
# =================================================================================================================
# =======================================
# Run some checks on option compatability
# =======================================
ifdef GAUSSIAN
ifdef LOCAL_FNL
$(error ERROR: GAUSSIAN AND LOCAL_FNL are not compatible, change Makefile)
endif
ifdef EQUIL_FNL
$(error ERROR: GAUSSIAN AND EQUIL_FNL are not compatible, change Makefile)
endif
ifdef ORTHO_FNL
$(error ERROR: GAUSSIAN AND ORTHO_FNL are not compatible, change Makefile)
endif
else
ifndef LOCAL_FNL
ifndef EQUIL_FNL
ifndef ORTHO_FNL
ifndef GENERIC_FNL
$(error ERROR: if not using GAUSSIAN then must select some type of non-gaussianity (LOCAL_FNL, EQUIL_FNL, ORTHO_FNL, GENERIC_FNL), change Makefile)
endif
endif
endif
endif
endif
ifdef GENERIC_FNL
ifdef LOCAL_FNL
$(error ERROR: GENERIC_FNL AND LOCAL_FNL are not compatible, choose one in Makefile)
endif
ifdef EQUIL_FNL
$(error ERROR: GENERIC_FNL AND EQUIL_FNL are not compatible, choose one in Makefile)
endif
ifdef ORTHO_FNL
$(error ERROR: GENERIC_FNL AND ORTHO_FNL are not compatible, choose one in Makefile)
endif
endif
ifdef LOCAL_FNL
ifdef EQUIL_FNL
$(error ERROR: LOCAL_FNL AND EQUIL_FNL are not compatible, choose one or the other in Makefile)
endif
ifdef ORTHO_FNL
$(error ERROR: LOCAL_FNL AND ORTHO_FNL are not compatible, choose one or the other in Makefile)
endif
endif
ifdef EQUIL_FNL
ifdef ORTHO_FNL
$(error ERROR: EQUIL_FNL AND ORTHO_FNL are not compatible, choose one or the other in Makefile)
endif
endif
ifdef PARTICLE_ID
ifdef LIGHTCONE
$(warning WARNING: LIGHTCONE output does not output particle IDs)
endif
endif
ifdef GADGET_STYLE
ifdef LIGHTCONE
$(error ERROR: LIGHTCONE AND GADGET_STYLE are not compatible, for binary output with LIGHTCONE simulations please choose the UNFORMATTED option.)
endif
endif
ifdef UNFORMATTED
ifndef LIGHTCONE
$(error ERROR: UNFORMATTED option is incompatible with snapshot simulations, for binary output with snapshot simulations please choose the GADGET_STYLE option.)
endif
endif
ifdef SCALEDEPENDENT
ifdef LIGHTCONE
$(error ERROR: LIGHTCONE AND SCALEDEPENDENT are not compatible. Use LCDM growth-factors for LIGHTCONE simulations.)
endif
endif
# ====================================
# Setup libraries and compile the code
# ====================================
ifeq ($(MACHINE),SCIAMA2)
CC = mpicc
ifdef SINGLE_PRECISION
FFTW_INCL = -I/opt/gridware/pkg/libs/fftw3_float/3.3.3/gcc-4.4.7+openmpi-1.8.1/include/
FFTW_LIBS = -L/opt/gridware/pkg/libs/fftw3_float/3.3.3/gcc-4.4.7+openmpi-1.8.1/lib/ -lfftw3f_mpi -lfftw3f
else
FFTW_INCL = -I/opt/gridware/pkg/libs/fftw3_double/3.3.3/gcc-4.4.7+openmpi-1.8.1/include/
FFTW_LIBS = -L/opt/gridware/pkg/libs/fftw3_double/3.3.3/gcc-4.4.7+openmpi-1.8.1/lib/ -lfftw3_mpi -lfftw3
endif
GSL_INCL = -I/opt/apps/libs/gsl/2.1/gcc-4.4.7/include/
GSL_LIBS = -L/opt/apps/libs/gsl/2.1/gcc-4.4.7/lib/ -lgsl -lgslcblas
MPI_INCL = -I/opt/gridware/pkg/mpi/openmpi/1.8.1/gcc-4.4.7/include
MPI_LIBS = -L/opt/gridware/pkg/mpi/openmpi/1.8.1/gcc-4.4.7/lib/ -lmpi
endif
ifeq ($(MACHINE),WINTHERMACBOOK)
CC = mpicc-openmpi-gcc6 # Add your MPI compiler here
ifdef SINGLE_PRECISION
FFTW_INCL = -I/Users/hans/local/include/
FFTW_LIBS = -L/Users/hans/local/lib/ -lfftw3f_mpi -lfftw3f
else
FFTW_INCL = -I/Users/hans/local/include/ # Add paths to your FFTW3 library here
FFTW_LIBS = -L/Users/hans/local/lib/ -lfftw3_mpi -lfftw3
endif
GSL_INCL = -I/opt/local/include/gsl/ # Add paths to your GSL library here
GSL_LIBS = -L/opt/local/lib/ -lgsl -lgslcblas
MPI_INCL = -I/opt/local/include
MPI_LIBS = -L/opt/local/lib/ -lmpi
endif
ifeq ($(MACHINE),OKEANOS)
CC = cc
GSL_INCL = -I/lustre/tetyda/home/winther/local/include
GSL_LIBS = -L/lustre/tetyda/home/winther/local/lib -lgsl -lgslcblas
endif
LIBS = -lm $(MPI_LIBs) $(FFTW_LIBS) $(GSL_LIBS)
CFLAGS = $(OPTIMIZE) $(FFTW_INCL) $(GSL_INCL) $(MPI_INCL) $(OPTIONS)
OBJS = src/main.o src/cosmo.o src/auxPM.o src/2LPT.o src/power.o src/vars.o src/read_param.o src/timer.o src/msg.o src/wrappers.o src/jbd.o
OBJS += src/compute_pofk.o src/readICfromfile.c
ifdef GENERIC_FNL
OBJS += src/kernel.o
endif
ifdef LIGHTCONE
OBJS += src/lightcone.o
endif
INCL = src/vars.h src/proto.h src/mg.h src/user_defined_functions.h src/wrappers.h Makefile
INCL += src/read_CAMB_data.h
ifdef MATCHMAKER
OBJS += src/mm_main.o src/mm_msg.o src/mm_fof.o src/mm_snap_io.o
INCL += src/mm_common.h
endif
all: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $(EXEC)
$(OBJS): $(INCL)
clean:
rm -f src/*.o src/*~ *~ $(EXEC)