-
Notifications
You must be signed in to change notification settings - Fork 6
/
SPECfile
300 lines (268 loc) · 12.7 KB
/
SPECfile
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
# The hierarchy among the source tree is roughly as follows:
# 1. inputlist contains the input namelists for SPEC and a routine to initialize their default values.
# 2. global contains the global workspace ("state") of the SPEC computation as well as the readin() and preset() routines
# required to initialize the workspace based on input variables.
# 3. sphdf5 contains the HDF5 output file writing routines. It depends on global and inputlist and therefore needs to be separately listed.
# 4. afiles ..
# .. ffiles contains the main physics wisdom of SPEC.
# 5. sfiles contains externally provided libraries, e.g. for quadrature, minimization, etc.
# 6. xspech contains the stand-alone main SPEC program.
###############################################################################################################################################################
# basis of SPEC: input variables, global workspace, HDF5 output file writing
# these are split off since they require special treatment (needed by all others and/or special macros)
BASEFILES=inputlist global
IOFILES=sphdf5
# (most of) physics part of SPEC
afiles=preset manual rzaxis packxi volume coords basefn memory
bfiles=metrix ma00aa matrix spsmat spsint mp00ac ma02aa packab tr00ab curent df00ab lforce intghs mtrxhs lbpol
cfiles=brcast dfp100 dfp200 dforce newton
dfiles=casing bnorml
efiles=jo00aa pp00aa pp00ab bfield stzxyz
ffiles=hesian ra00aa numrec
# externally provided libraries
# below assumes the .f files are double precision; the CFLAGS = -r8 option is not required;
sfiles=dcuhre minpack iqpack rksuite i1mach d1mach ilut iters
###############################################################################################################################################################
# all of SPEC except BASEFILES
SPECFILES=$(afiles) $(bfiles) $(cfiles) $(dfiles) $(efiles) $(ffiles)
# all of "our" (vs. contributed) files needed for the "core" of SPEC
ALLSPEC=$(BASEFILES) $(IOFILES) $(SPECFILES)
# *ALL* files needed for the main SPEC executable
ALLFILES=$(sfiles) $(ALLSPEC) xspech
###############################################################################################################################################################
MACROS=src/macros
###############################################################################################################################################################
# if want to use gfortran: make BUILD_ENV=gfortran (x/d)spec
# default: use Intel compiler
BUILD_ENV?=intel
# to enable OpenMP acceleration within volume, set OMP=yes, otherwise set OMP=no
OMP=yes
ifeq ($(BUILD_ENV),intel)
# Intel Defaults
# At PPPL, you can use the following commands
# module use /p/focus/modules
# module load spec
FC=mpif90
CFLAGS=-r8 -DIFORT
RFLAGS=-mcmodel=large -O3 -m64 -unroll0 -fno-alias -ip -traceback
DFLAGS=-O0 -g -traceback -check bounds -check format -check output_conversion -check pointers -check uninit -debug full -D DEBUG
LIBS=-I${MKLROOT}/include/intel64/lp64 -I${MKLROOT}/include # MKL include
LIBS+=-I$(HDF5_HOME)/include # HDF5 include
LINKS=-L$(HDF5_HOME)/lib -lhdf5_fortran -lhdf5 -lhdf5hl_fortran # HDF5 link
LIBS+=-I$(FFTW_HOME)/include # FFTW include
LINKS+=-L$(FFTW_HOME)/lib -lfftw3 # FFTW link
LINKS+=${MKLROOT}/lib/intel64/libmkl_blas95_lp64.a ${MKLROOT}/lib/intel64/libmkl_lapack95_lp64.a \
-Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a \
${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl # MKL link
endif
ifeq ($(BUILD_ENV),gfortran)
# At PPPL, you can use the following commands
# module use /p/focus/modules
# module load spec/gcc
FC=mpif90
FLAGS=-fPIC
RFLAGS=-O3 -w -ffree-line-length-none -fexternal-blas # -fallow-argument-mismatch # only used for GCC-10
DFLAGS=-O0 -g -w -ffree-line-length-none -Wextra -Wtarget-lifetime -fbacktrace -fbounds-check -fexternal-blas \
-fcheck=all -DDEBUG #-ffpe-trap=invalid,zero,overflow,underflow,inexact # for some reason this will cause crash
CFLAGS=-fdefault-real-8
LINKS=-L$(LAPACK_HOME) -llapack #-lgfortran
LIBS=-I$(HDF5_HOME)/include
LINKS+=-L$(HDF5_HOME)/lib -lhdf5hl_fortran -lhdf5 -lhdf5_fortran -lhdf5 -lpthread -lz -lm
LIBS+=-I$(FFTW_HOME)/include
LINKS+=-L$(FFTW_HOME)/lib -lfftw3
LINKS+=-L$(OPENBLAS_HOME)/lib -lopenblas
endif
ifeq ($(BUILD_ENV),gfortran_ubuntu)
# You should install the following packages
# sudo apt install gfortran
# sudo apt install libopenmpi-dev
# sudo apt install liblapack-dev
# sudo apt install m4
# sudo apt install libfftw3-dev
# sudo apt install libhdf5-dev
FC=mpif90
FLAGS=-fPIC
CFLAGS=-fdefault-real-8
LINKS=-Wl,-rpath -Wl,/usr/lib/lapack -llapack -lblas
LIBS=-I/usr/include/hdf5/serial
LINKS+=-L/usr/lib/x86_64-linux-gnu/hdf5/serial -lhdf5_fortran -lhdf5 -lpthread -lz -lm
LIBS+=-I/usr/include
LINKS+=-lfftw3
RFLAGS=-O2 -ffixed-line-length-none -ffree-line-length-none -fexternal-blas
DFLAGS=-g -fbacktrace -fbounds-check -ffree-line-length-none -fexternal-blas -DDEBUG
endif
ifeq ($(BUILD_ENV),gfortran_debian)
# You should install the following packages
# sudo apt install gfortran
# sudo apt install libopenmpi-dev
# sudo apt install liblapack-dev
# sudo apt install m4
# sudo apt install libfftw3-dev
# sudo apt install libhdf5-dev
FC=mpif90
FLAGS=-fPIC
CFLAGS=-fdefault-real-8
RFLAGS=-O2 -ffixed-line-length-none -ffree-line-length-none -fexternal-blas
DFLAGS=-g -fbacktrace -fbounds-check -ffree-line-length-none -fexternal-blas -DDEBUG
LINKS=-llapack -lblas
LIBS=-I/usr/include/hdf5/serial
LINKS+=-L/usr/lib/x86_64-linux-gnu/hdf5/serial -lhdf5_fortran -lhdf5 -lpthread -lz -lm
LIBS+=-I/usr/include
LINKS+=-lfftw3
endif
ifeq ($(BUILD_ENV),gfortran_arch)
# configuration for Arch Linux
# traps for numerical errors: https://stackoverflow.com/a/29827243
FC=mpif90
FLAGS=-fPIC -Wall -Wextra
CFLAGS=-fdefault-real-8 -fallow-argument-mismatch
LINKS=-llapack -lblas
LIBS=
LINKS+=-lhdf5_fortran -lhdf5 -lpthread -lz -lm
LINKS+=-lfftw3
RFLAGS=-O3 -ffixed-line-length-none -ffree-line-length-none -fexternal-blas
DFLAGS=-g -fbacktrace -fbounds-check -ffree-line-length-none -fexternal-blas -DDEBUG -ffpe-trap=invalid,zero,overflow,underflow
endif
ifeq ($(BUILD_ENV),gfortran_centos)
# configuration for CentOS Linux
OPENMPI_LIB=/usr/lib64/openmpi/lib
OPENMPI_INC=/usr/lib64/gfortran/modules/openmpi
FC=mpif90
FLAGS=-fPIC
RFLAGS=-O2 -ffixed-line-length-none -ffree-line-length-none -fexternal-blas # -fallow-argument-mismatch # only used for GCC-10
DFLAGS=-O0 -g -w -ffree-line-length-none -Wextra -Wtarget-lifetime -fbacktrace -fbounds-check -fexternal-blas \
-fcheck=all -DDEBUG #-ffpe-trap=invalid,zero,overflow,underflow,inexact # for some reason this will cause crash
CFLAGS=-fdefault-real-8
LINKS=-L/opt/OpenBLAS/lib -lopenblas #-lblas #-lgfortran
LIBS=-I$(OPENMPI_INC)
LINKS+=-L$(OPENMPI_LIB) -lhdf5hl_fortran -lhdf5 -lhdf5_fortran -lhdf5 -lpthread -lz -lm
LIBS+=-I/usr/lib64/gfortran/modules/
LIBS+=-I/usr/include
LINKS+=-lfftw3
LINKS+=
endif
ifeq ($(BUILD_ENV),gfortran_mac)
# works on Ksenia's laptop
FC=mpif90
FLAGS=-fPIC
CFLAGS=-fdefault-real-8
LINKS=-L/usr/local/Cellar/lapack/3.8.0_1/lib -llapack -Wl,-rpath -Wl,/usr/local/Cellar/lapack/3.8.0_1/lib -lblas -L/usr/local/Cellar/openblas/0.3.7 -lgfortran -Wl,-rpath -Wl,/usr/local/Cellar/openblas/0.3.7/lib
LIBS=-I/Applications/HDF_Group/HDF5/1.10.5/include/static
LINKS+=-L/Applications/HDF_Group/HDF5/1.10.5/lib -lhdf5_f90cstub -lhdf5_fortran -lhdf5 -lpthread -lz -lm -Wl,-rpath -Wl,/Applications/HDF_Group/HDF5/1.10.5/lib
LIBS+=-I/usr/local/Cellar/fftw/3.3.8/include
LINKS+=-L/usr/local/Cellar/fftw/3.3.8/lib -lfftw3 -Wl,-rpath -Wl,/usr/local/Cellar/fftw/3.3.8/lib
RFLAGS=-O2 -ffixed-line-length-none -ffree-line-length-none -fexternal-blas
DFLAGS=-g -fbacktrace -fbounds-check -ffree-line-length-none -fexternal-blas -DDEBUG
endif
ifeq ($(BUILD_ENV),lff95)
# LF95 SAL
# Not checked
CFLAGS=--dbl
RFLAGS=--ap -O -I.
DFLAGS=-Cpp -DDEBUG
LINKS=-L$(LINKS_ROOT) -lnag -L$(LAPACKHOME) -llapack -L$(BLASHOME) -lblas
LIBS=-I$(FFTWHOME)/include
LINKS+=-L$(FFTWHOME)/lib -lfftw3
endif
ifeq ($(BUILD_ENV),intel_spc)
FC=mpif90
FFTW_DIR=/usr/local/fftw3
CFLAGS=-r8 -DIFORT
RFLAGS=-O2 -ip -no-prec-div -xHost -fPIC
DFLAGS=-traceback -D DEBUG -g
LINKS=-L${MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl
LIBS=-I$(FFTW_DIR)/include
LINKS+=-L$(FFTW_DIR)/lib -lfftw3
LIBS+=-I$(HDF5_serial)/include
LINKS+=-L$(HDF5_serial)/lib -lhdf5_fortran -lhdf5 -lpthread -lz -lm -Wl,-rpath -Wl,$(HDF5_serial)/lib
endif
ifeq ($(BUILD_ENV),gfort_spc) # deprecated
FC=mpif90
FLAGS=-fPIC
CFLAGS=-fdefault-real-8
RFLAGS=-O2 -ffixed-line-length-none -ffree-line-length-none -fexternal-blas
DFLAGS=-g -fbacktrace -fbounds-check -ffree-line-length-none -fexternal-blas -DDEBUG
LINKS=-L/lib -lmkl_rt -lpthread -lm -ldl -Wl,-rpath
LINKS+=-L$(FFTW_DIR)/lib -lfftw3
LINKS+=-L/usr/local/hdf5-1.8.18-gcc6.3/lib -lhdf5_fortran -lhdf5 -lz
LIBS=-I$(FFTW_DIR)/include
LIBS+=-I/usr/local/hdf5-1.8.18-gcc6.3/include
endif
ifeq ($(BUILD_ENV),intel_ipp)
# tested on draco with the following modules:
# intel/18.0.3 impi/2018.3 mkl/2018.3 hdf5-serial/1.8.21 fftw-mpi/3.3.8
# and on cobra with the following modules:
# intel/19.0.4 impi/2019.4 mkl/2019.4 hdf5-serial/1.8.21 fftw-mpi/3.3.8
FC=mpiifort
CFLAGS=-r8 -DIFORT
RFLAGS=-O2 -ip -no-prec-div -xHost -fPIC
DFLAGS=-traceback -D DEBUG
LINKS=-L${MKLROOT}/lib/intel64 -lmkl_rt -lpthread -lm -ldl -Wl,-rpath -Wl,${MKLROOT}/lib/intel64
LIBS=-I$(HDF5_HOME)/include
LINKS+=-L$(HDF5_HOME)/lib -lhdf5_fortran -lhdf5 -lpthread -lz -lm -Wl,-rpath -Wl,$(HDF5_HOME)/lib
LIBS+=-I$(FFTW_HOME)/include
LINKS+=-L$(FFTW_HOME)/lib -lfftw3 -Wl,-rpath -Wl,$(FFTW_HOME)/lib
endif
ifeq ($(BUILD_ENV),gfortran_ipp)
# tested on draco with the following modules:
# gcc/8 impi/2018.3 mkl/2018.3 hdf5-mpi/1.10.5 fftw-mpi/3.3.8
FC=mpif90
FLAGS=-fPIC
CFLAGS=-fdefault-real-8
RFLAGS=-O2 -fPIC -ffree-line-length-none
DFLAGS=-g -fbacktrace -fbounds-check -DDEBUG -ffree-line-length-none
LINKS=-L${MKLROOT}/lib/intel64 -lmkl_rt -lpthread -lm -ldl -Wl,-rpath -Wl,${MKLROOT}/lib/intel64
LIBS=-I$(HDF5_HOME)/include
LINKS+=-L$(HDF5_HOME)/lib -lhdf5_fortran -lhdf5 -lpthread -lz -lm -Wl,-rpath -Wl,$(HDF5_HOME)/lib
LIBS+=-I$(FFTW_HOME)/include
LINKS+=-L$(FFTW_HOME)/lib -lfftw3 -Wl,-rpath -Wl,$(FFTW_HOME)/lib
endif
ifeq ($(BUILD_ENV),intel_gadi)
#module load intel-compiler/2019.3.199
#module load intel-mkl/2019.3.199
#module load openmpi/3.1.4
#module load fftw3-mkl/2019.3.199
#module load hdf5/1.10.5
FC=mpif90
CFLAGS=-r8 -DIFORT
LINKS=-L${MKLROOT}/lib/intel64 -mkl=parallel -liomp5
LIBS=-I$(HDF5_BASE)/include
LINKS+=-L$(HDF5_BASE)/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lpthread -lz -lm
RFLAGS=-mcmodel=large -O3 -m64 -unroll0 -fno-alias -ip -traceback -fPIC
DFLAGS=-check bounds -check format -check output_conversion -check pointers -check uninit -debug full -D DEBUG
endif
ifeq ($(BUILD_ENV),intel_stellar)
# PPPL stellar cluster intel compiler
# module use /home/caoxiang/module
# module load spec
FC=mpiifort
CFLAGS=-r8 -DIFORT
RFLAGS=-mcmodel=large -O3 -m64 -unroll0 -fno-alias -ip -traceback -fPIC
DFLAGS=-O0 -g -traceback -check bounds -check format -check output_conversion -check pointers -check uninit -debug full -D DEBUG
LIBS=-I${MKLROOT}/include/intel64/lp64 # MKL include
LIBS+=-I$(HDF5DIR)/include # HDF5 include
LINKS=-L$(HDF5DIR)/lib -lhdf5_fortran -lhdf5 # HDF5 link
LIBS+=-I$(FFTW3DIR)/include # FFTW include
LINKS+=-L$(FFTW3DIR)/lib -lfftw3 # FFTW link
LINKS+= ${MKLROOT}/lib/intel64/libmkl_blas95_lp64.a ${MKLROOT}/lib/intel64/libmkl_lapack95_lp64.a -L${MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm -ldl
endif
ifeq ($(BUILD_ENV),intel_marconi)
# Added by Samuel Lazerson ([email protected])
FC=mpiifort
CFLAGS=-r8
RFLAGS=-mcmodel=large -O3 -m64 -unroll0 -fno-alias -ip -traceback
DFLAGS=-O0 -g -traceback -check bounds -check format -check output_conversion -check pointers -check uninit -debug full -D DEBUG
LIBS=-I${MKLROOT}/include/intel64/lp64 -I${MKLROOT}/include # MKL include
LIBS+=-I$(HDF5_HOME)/include # HDF5 include
LINKS=-L$(HDF5_HOME)/lib -lhdf5_fortran -lhdf5 -lpthread -lz -lm # HDF5 link
LIBS+=-I$(FFTW_HOME)/include # FFTW include
LINKS+=-L$(FFTW_HOME)/lib -lfftw3 # FFTW link
LINKS+=${MKLROOT}/lib/intel64/libmkl_blas95_lp64.a ${MKLROOT}/lib/intel64/libmkl_lapack95_lp64.a \
-Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a \
${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl # MKL link
endif
ifeq ($(OMP),yes)
RFLAGS+=-DOPENMP -fopenmp
DFLAGS+=-DOPENMP -fopenmp
LINKS+=-lgomp
endif