-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathMakefile
More file actions
210 lines (188 loc) · 6.86 KB
/
Copy pathMakefile
File metadata and controls
210 lines (188 loc) · 6.86 KB
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
# Makefile for compiling fortran programs with automatic dependency
# generation and recognition of programs. Full support for parallel make.
#
# Object files are stored in $(OBJDIR)=.obj/
# Module files are stored in $(MODDIR)=.mod/
# Dependencies are stored in $(DEPDIR)=.dep/
#
# Known limitations:
# - Module/function/subroutine name must be equal to file name
# Include jorek-specific things and settings
include Makefile.inc
MODEL_NUMBER := $(subst model,,$(MODEL))
# Default rule needs to be first
main: jorek_model$(MODEL_NUMBER)
# Some defaults and parsing logic for makefile.inc
include defaults.mk
# Build the main executable with a different name from the source file jorek2_main.o
jorek_model$(MODEL_NUMBER): $(OBJDIR)/jorek2_main.o $(shell ./util/obj_deps $(DEPDIR)/jorek2_main.d)
$(FC) $(FLAGS) $(DEFINES) $(INCLUDES) -o $@ $^ $(LIBS)
.PHONY: clean cleanall cleandep duplicates
cleanall: clean cleandep
clean:
@echo ">> Deleting Object Files <<"
-@rm -r $(OBJDIR)
@echo ">> Deleting Module Files <<"
-@rm -r $(MODDIR)
-@find . -name '*.mod' -delete -or -name '*.o' -delete
-@rm mpiversion.mk
@echo ">> Deleting Dynamically Generated Header Files <<"
-@rm -f models/$(MODEL)/rhs_automatic.h
-@rm -f models/$(MODEL)/amat_automatic.h
-@rm -f models/$(MODEL)/aux_automatic.h
-@rm -f algexpr2fort
-@rm -f generate_code
cleandep:
@echo ">> Deleting Dependency Files <<"
-@rm -r $(DEPDIR)
-@find . -name '*.d' -delete 2>/dev/null
test: particle_test nrt_unit
doc docs:
-@rm -r doc/ # workaround for FORD bug
ford jorek.md --no-search $(INCLUDES)
# Directories containing sources, ordered by number of files
DIRS := diagnostics \
diagnostics/tests \
models \
communication \
communication/IMAS \
communication/tests \
grids/grid_utils \
grids/tests \
solvers \
models/$(MODEL) \
refinement \
matrix \
numerics \
particles \
particles/pushers \
particles/examples \
particles/diagnostics \
particles/tests \
particles/initialisers \
particles/postprocessors \
particles/postprocessors/spectra \
particles/postprocessors/lights \
particles/postprocessors/lens \
particles/postprocessors/filters \
particles/postprocessors/camera \
particles/postprocessors/examples \
particles/postprocessors/tests \
particles/postprocessors/utils \
particles/projection_functions \
particles/benchmarks/pusher_cartesian \
particles/benchmarks/pusher \
particles/benchmarks/projection \
elements \
elements/tests \
grids \
plots \
diagnostics/new_diag \
diagnostics/postproc \
tools \
tools/fruit \
tools/tests \
non_regression_tests/unit_tests \
datatypes \
benchmarks \
core \
core/tests \
. \
vacuum
DIRS+=$(EXTRA_DIRS) # Specified in Makefile.inc or commandline
# All .f90 files we should generate .d dependency files for
depends:=$(basename $(notdir $(shell find $(DIRS) -maxdepth 1 -iname '*.f90')))
depends:=$(foreach dep,$(depends),$(DEPDIR)/$(dep).d)
# Check for multiple files with the same name in $(DIRS)
duplicates:
@dups=`find $(DIRS) -maxdepth 1 -iname '*.f90' |\
xargs basename -s .f90 -a | sort | uniq -d`
@if [[ -z "${dups// }" ]]; then echo "No duplicates detected"; \
else echo "Duplicates found: ${dups}"; fi
printsettings:
@echo "FC = $(FC)"
@echo "CC = $(CC)"
@echo "DEBUG = $(DEBUG)"
@echo "FLAGS = $(FLAGS)"
@echo "FFLAGS = $(FFLAGS)"
@echo "F90FLAGS = $(F90FLAGS)"
@echo "F77FLAGS = $(F77FLAGS)"
@echo "CFLAGS = $(CFLAGS)"
@echo "DEFINES = $(DEFINES)"
@echo "INCLUDES = $(INCLUDES)"
@echo "LIBS = $(LIBS)"
$(OBJDIR)/mod_elt_matrix.o $(MODDIR)/mod_elt_matrix.mod: $(CGDEP)
$(OBJDIR)/mod_elt_matrix_fft.o $(MODDIR)/mod_elt_matrix_fft.mod: $(CGDEP)
# For each source dir add an explicit rule with the template
$(foreach dir,$(DIRS),$(eval $(call O_TEMPLATE,$(dir)/)))
# For each source dir add a rule to create dependency files
ifneq (cleanall,$(findstring cleanall,$(MAKECMDGOALS)))
ifneq (cleandep,$(findstring cleandep,$(MAKECMDGOALS)))
$(foreach dir,$(DIRS),$(eval $(call F90_D_TEMPLATE,$(dir)/)))
endif
endif
# Include the dependency files that can be generated by the rules above
-include $(depends) # Make will build all of these and re-execute
# The included programs are defined in the $(depends) files
# For each of these programs add the default template
$(foreach prog,$(PROGRAM_SOURCES),$(eval $(call PROGRAM_TEMPLATE,$(prog))))
# To compile all programs found in $(DIRS)
all: $(basename $(notdir $(PROGRAM_SOURCES)))
# A list of supported diagnostics, that should compile properly for regression
# testing to pass
most: jorek2_connection2 \
jorek2_connection_stan \
jorek2_connection_flux_aligned \
jorek2_diagno \
jorek2_diagno_spi \
jorek2_fieldlines_vtk \
jorek2_four \
jorek2_IDS \
CARIDDI_wall_curr \
jorek2_poincare \
jorek2_powers \
jorek2_target2vtk \
jorek2vtk_3d \
jorek2vtk \
jorek2vtk_GaussVortTerms \
test_gvec2jorek_import \
jorek_to_helena \
new_diag_demo \
jorek2_postproc \
rst_bin2hdf5 \
rst_hdf52bin \
jorek2_main
# Make all object files we know of
find_files = $(wildcard $(dir)/*.f90) $(wildcard $(dir)/*.c) $(wildcard $(dir)/*.f) $(wildcard $(dir)/*.cpp)
objs: $(foreach file,$(foreach dir,$(DIRS), $(find_files)), $(OBJDIR)/$(notdir $(basename $(file))).o)
generate_code: algexpr2fort
@echo ">> Generating evaluation statements for mod_elt_matrix <<"
@./algexpr2fort
@touch generate_code
# Special cases
# Add here: Global includes (as the line below)
INCLUDES += -Itools # for r3_info.h
INCLUDES += -Imodels
# C++ support
LIBS += -lstdc++
CXXFLAGS += -pedantic -Wall
# Rule-specific includes: an example
#jorek2_main: DEFINES+="-DMAIN "
eqdsk2jorek: LIBS+=$(LIBDIERCKX)
# Automatically download adas data for tungsten
particles/examples/%50_w.dat:
wget http://open.adas.ac.uk/download/adf11/$*50/$*50_w.dat -O $@
compare_mc_coronal: | particles/examples/acd50_w.dat particles/examples/scd50_w.dat
# We need the MPI_VERSION variable for conditional compilation, but
# unfortunately Fortran defines it as an integer parameter, which
# we cannot use as a preprocessor symbol. To overcome this problem,
# we create a small program that prints out the value of the
# MPI_VERSION parameter and use this to add -DMPI_VERSION=X to FFLAGS.
mpiversion.mk:
printf "include 'mpif.h'\nWRITE(*,fmt='(A22,I1)') 'FFLAGS+=-DMPI_VERSION=', MPI_VERSION\nEND" > $(OBJDIR)/mpi_version.f90
($(FC) $(FLAGS) $(DEFINES) $(INCLUDES) -o $(OBJDIR)/mpi_version $(OBJDIR)/mpi_version.f90 $(LIBS) && $(OBJDIR)/mpi_version | tail -n1 > mpiversion.mk) || echo FFLAGS+=-DMPI_VERSION=0 > mpiversion.mk
-include mpiversion.mk
eqdsk2jorek: LIBS+=$(LIBDIERCKX)
# Is this used by anyone? Otherwise we could remove it
# It is not updated to this format yet.
-include forcheck.mk