-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
193 lines (161 loc) · 5.54 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
#
#========================================================================
#
# T o m o f a s t - x
# -----------------------
#
# Authors: Vitaliy Ogarko, Jeremie Giraud, Roland Martin.
#
# (c) 2021 The University of Western Australia.
#
# The full text of the license is available in file "LICENSE".
#
#========================================================================
################################################################################
# Compiler and linker flags.
################################################################################
# Compiler choice: 1 - GCC, 2 - Intel.
COMPILER = 1
# Use MPI Fortran compiler and linker wrappers.
ifeq ($(COMPILER), 1)
FC = mpif90
else
FC = mpiifx # For Intel compiler (mpiifort is deprecated).
endif
# obj directory
OBJDIR = obj
# Executable name.
EXEC = tomofastx
ifeq ($(COMPILER), 1)
# GNU gfortran pseudo-optimized.
FFLAGS = -std=f2008 -fconvert=big-endian -O3 -fimplicit-none -frange-check -fmax-errors=10 -pedantic -pedantic-errors -Warray-temporaries -Waliasing -Wampersand -Wcharacter-truncation -Wline-truncation -Wsurprising -Wno-tabs -Wunderflow -DUSE_FLUSH6 -J $(OBJDIR)
# GNU gfortran with debug symbols and full debugging.
#FFLAGS = -std=f2008 -fconvert=big-endian -O0 -g -fimplicit-none -frange-check -fmax-errors=10 -pedantic -pedantic-errors -Warray-temporaries -Waliasing -Wampersand -Wcharacter-truncation -Wline-truncation -Wsurprising -Wno-tabs -Wunderflow -fbacktrace -Wunreachable-code -Wunused-label -Wunused-variable -Wimplicit-interface -Wall -fcheck=all -fbounds-check -ffpe-trap=invalid,zero,overflow,underflow,denormal -DUSE_FLUSH6 -J $(OBJDIR)
# GNU flags to output the vector optimizations report.
OPT_INFO = -ftree-vectorize -fopt-info-vec-optimized=vec.info
# Adding vectorisation report for GNU compiler.
#FFLAGS := $(OPT_INFO) $(FFLAGS)
else
# Intel compiler optimized for speed for production runs.
FFLAGS = -convert big_endian -implicitnone -assume buffered_io -assume byterecl -warn truncated_source -warn interfaces -warn unused -warn declarations -warn alignments -warn ignore_loc -warn usage -DUSE_FLUSH6 -ftz -fpe0 -check nobounds -O3 -xHost -module $(OBJDIR)
# Intel compiler with full checking options to debug (slow but very useful to check everything).
#FFLAGS = -convert big_endian -implicitnone -assume buffered_io -assume byterecl -warn truncated_source -warn interfaces -warn unused -warn declarations -warn alignments -warn ignore_loc -warn usage -DUSE_FLUSH6 -ftz -fpe0 -check all -debug -g -O0 -traceback -ftrapuv -module $(OBJDIR)
endif
# To print a variable run: make print-VARIABLE
print-% : ; @echo $* = $($*)
default: | $(OBJDIR) ${EXEC}
all: clean default
# EXECUTABLES:
LIBS_FULL =
# For the IPM linking.
#LIBS_FULL =-L/usr/local/lib -lipmf -lipm
# add paths to the search path for files
vpath %.f90 ./src
vpath %.F90 ./src
vpath %.f90 ./src/libs
vpath %.F90 ./src/libs
vpath %.c ./src/libs
vpath %.f90 ./src/forward
vpath %.F90 ./src/forward
vpath %.f90 ./src/forward/gravmag
vpath %.F90 ./src/forward/gravmag
vpath %.f90 ./src/forward/gravmag/grav
vpath %.F90 ./src/forward/gravmag/grav
vpath %.f90 ./src/forward/gravmag/mag
vpath %.F90 ./src/forward/gravmag/mag
vpath %.f90 ./src/inversion
vpath %.F90 ./src/inversion
vpath %.f90 ./src/utils
vpath %.F90 ./src/utils
vpath %.f90 ./src/tests
vpath %.F90 ./src/tests
# External libraries.
SRC_LIST_LIBS = \
ftnunit.f90
SRC_LIST_UTILS = \
mpi_tools.F90 \
costs.f90 \
vector.f90 \
string.f90 \
noise.f90 \
paraview.f90 \
parallel_tools.f90 \
memory_tools.f90 \
wavelet_transform.F90 \
sort.f90
# Source files for inversion.
SRC_LIST_INVERSION = \
parameters_inversion.f90 \
sparse_matrix.f90 \
wavelet_utils.F90 \
grid.F90 \
model.F90 \
model_IO.F90 \
inversion_arrays.f90 \
lsqr_solver2.F90 \
damping.F90 \
gradient.F90 \
cross_gradient.F90 \
admm_method.F90 \
clustering.F90 \
damping_gradient.F90 \
joint_inverse_problem.F90
# Source files for gravity and magnetism problems.
SRC_LIST_GRAVMAG = \
parameters_gravmag.f90 \
parameters_grav.f90 \
parameters_mag.f90 \
data_gravmag.f90 \
gravity_field.f90 \
magnetic_field.f90 \
weights_gravmag.f90 \
sensitivity_gravmag.F90
# Main routines.
SRC_LIST_MAIN = \
parameters_init.f90 \
problem_joint_gravmag.F90
# Unit tests.
SRC_LIST_TESTS = \
tests_inversion.f90 \
tests_lsqr.f90 \
tests_parallel_tools.f90 \
tests_sparse_matrix.f90 \
tests_wavelet_compression.f90 \
unit_tests.f90
# Note: inversion files precede the forward problem files,
# to make sure there are no dependencies.
SRC_LIST = \
global_typedefs.F90 \
$(SRC_LIST_LIBS) \
$(SRC_LIST_UTILS) \
$(SRC_LIST_INVERSION) \
$(SRC_LIST_GRAVMAG) \
$(SRC_LIST_MAIN) \
$(SRC_LIST_TESTS) \
program_tomofastx.F90
# Create object file lists from all source files list.
# First replace .F90 extension.
OBJ_LIST_1 = $(SRC_LIST:%.F90=$(OBJDIR)/%.o)
# Then replace .f90 extension.
OBJ_LIST_2 = $(OBJ_LIST_1:%.f90=$(OBJDIR)/%.o)
# Then replace .c extension.
OBJ_LIST = $(OBJ_LIST_2:%.c=$(OBJDIR)/%.o)
# Targets to create the object directory if it does not exist.
$(OBJ_LIST): | $(OBJDIR)
$(OBJDIR):
@test -d $(OBJDIR) || (rm -f $(OBJDIR); mkdir -p $(OBJDIR))
# Implicit rules for object files.
$(OBJDIR)/%.o: %.F90
$(FC) $(FFLAGS) -o $@ -c $<
$(OBJDIR)/%.o: %.f90
$(FC) $(FFLAGS) -o $@ -c $<
# Target to build the actual executable.
${EXEC}: $(OBJ_LIST)
$(FC) $(FFLAGS) -o ${EXEC} $(OBJ_LIST) $(LIBS_FULL)
clean:
rm -rf *.o *.mod ${EXEC} $(OBJDIR)
# targets to clean up all object directories
purge: clean
realclean: purge
deepclean: purge
mrproper: purge