forked from SPECFEM/specfem2d
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.in
251 lines (202 loc) · 7.13 KB
/
Makefile.in
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
#========================================================================
#
# S P E C F E M 2 D Version 7 . 0
# --------------------------------
#
# Main historical authors: Dimitri Komatitsch and Jeroen Tromp
# Princeton University, USA
# and CNRS / University of Marseille, France
# (there are currently many more authors!)
# (c) Princeton University and CNRS / University of Marseille, April 2014
#
# This software is a computer program whose purpose is to solve
# the two-dimensional viscoelastic anisotropic or poroelastic wave equation
# using a spectral-element method (SEM).
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and Inria at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The full text of the license is available in file "LICENSE".
#
#========================================================================
#
# @configure_input@
#######################################
FC = @FC@
FCFLAGS = @FCFLAGS@
MPIFC = @MPIFC@
MPILIBS = @MPILIBS@
CC = @CC@
DEF_FFLAGS = @DEF_FFLAGS@ -I${SETUP}
CPPFLAGS = @CPPFLAGS@ $(COND_MPI_CPPFLAGS)
CFLAGS = @CFLAGS@ $(CPPFLAGS) -I${SETUP}
FC_MODEXT = @FC_MODEXT@
FC_MODDIR = @FC_MODDIR@
## serial or parallel
@COND_MPI_TRUE@F90 = $(MPIFC) $(FCFLAGS) @FC_DEFINE@USE_MPI @FC_DEFINE@USE_SCOTCH -I"@SCOTCH_INCLUDEDIR@" $(MPILIBS)
@COND_MPI_FALSE@F90 = $(FC) $(FCFLAGS)
USE_BUNDLED_SCOTCH = @USE_BUNDLED_SCOTCH@
SCOTCH_DIR = @SCOTCH_DIR@
SCOTCH_INCLUDEDIR = @SCOTCH_INCLUDEDIR@
SCOTCH_LIBDIR = @SCOTCH_LIBDIR@
LIB =
## scotch libraries
@COND_MPI_TRUE@LIB += -L"@SCOTCH_LIBDIR@" -lscotch -lscotcherr
@COND_MPI_FALSE@LIB +=
LINK = $(F90)
#######################################
####
#### CUDA
#### with configure: ./configure --with-cuda=cuda5 CUDA_FLAGS=.. CUDA_LIB=.. CUDA_INC=.. MPI_INC=.. ..
####
#######################################
@COND_CUDA_TRUE@CUDA = yes
@COND_CUDA_FALSE@CUDA = no
@COND_CUDA5_TRUE@CUDA5 = yes
@COND_CUDA5_FALSE@CUDA5 = no
# default cuda libraries
# runtime library -lcudart -lcuda and -lcublas needed
CUDA_FLAGS = @CUDA_FLAGS@
CUDA_INC = @CUDA_CPPFLAGS@ -I${SETUP}
CUDA_LINK = @CUDA_LDFLAGS@ @CUDA_LIBS@
@COND_CUDA_TRUE@NVCC = nvcc
@COND_CUDA_FALSE@NVCC = @CC@
# GPU architecture
# CUDA architecture / code version
# Fermi: -gencode=arch=compute_10,code=sm_10 not supported
# Tesla (default): -gencode=arch=compute_20,code=sm_20
# Geforce GT 650m: -gencode=arch=compute_30,code=sm_30
# Kepler (cuda5) : -gencode=arch=compute_35,code=sm_35
GENCODE_20 = -gencode=arch=compute_20,code=\"sm_20,compute_20\"
GENCODE_30 = -gencode=arch=compute_30,code=\"sm_30,compute_30\"
GENCODE_35 = -gencode=arch=compute_35,code=\"sm_35,compute_35\"
# CUDA version 5.x
@COND_CUDA_TRUE@@COND_CUDA5_TRUE@GENCODE = $(GENCODE_35)
# CUDA version 4.x
@COND_CUDA_TRUE@@COND_CUDA5_FALSE@GENCODE = $(GENCODE_20)
# CUDA flags and linking
@COND_CUDA_TRUE@NVCC_FLAGS_BASE = $(CUDA_FLAGS) $(CUDA_INC) $(COND_MPI_CPPFLAGS)
@COND_CUDA_TRUE@@COND_CUDA5_TRUE@NVCC_FLAGS = $(NVCC_FLAGS_BASE) -DCUDA $(GENCODE) -ftz=true
@COND_CUDA_TRUE@@COND_CUDA5_FALSE@NVCC_FLAGS = $(NVCC_FLAGS_BASE) -DCUDA -DUSE_OLDER_CUDA4_GPU $(GENCODE)
@COND_CUDA_TRUE@@COND_CUDA5_TRUE@NVCCLINK_BASE = $(NVCC) $(CUDA_INC) $(COND_MPI_CPPFLAGS) -DCUDA
@COND_CUDA_TRUE@@COND_CUDA5_TRUE@NVCCLINK = $(NVCCLINK_BASE) -dlink $(GENCODE)
@COND_CUDA_TRUE@@COND_CUDA5_FALSE@NVCCLINK = $(NVCCLINK_BASE) -DUSE_OLDER_CUDA4_GPU $(GENCODE)
@COND_CUDA_FALSE@NVCC_FLAGS = $(COND_MPI_CPPFLAGS)
@COND_CUDA_FALSE@NVCCLINK = $(NVCC) $(NVCC_FLAGS)
#######################################
####
#### directories
####
#######################################
## compilation directories
# B : build directory
B = @top_builddir@
# E : executables directory
E = $B/bin
# O : objects directory
O = $B/obj
# L : libraries directory
L = $B/lib
# setup file directory
SETUP = $B/setup
# output file directory
OUTPUT = $B/OUTPUT_FILES
# S_TOP : source file root directory
S_TOP = @top_srcdir@
#######################################
####
#### targets
####
#######################################
# code subdirectories
SUBDIRS = \
meshfem2D \
shared \
cuda \
specfem2D \
tomography/postprocess_sensitivity_kernels \
auxiliaries \
$(EMPTY_MACRO)
# default targets for the pure Fortran version
DEFAULT = \
xmeshfem2D \
xspecfem2D \
xadj_seismogram \
xcheck_quality_external_mesh \
xconvolve_source_timefunction \
$(EMPTY_MACRO)
default: $(DEFAULT)
all: default auxiliaries postprocess
ifdef CLEAN
clean:
@echo "cleaning by CLEAN"
-rm -f $(foreach dir, $(CLEAN), $($(dir)_OBJECTS) $($(dir)_MODULES) $($(dir)_SHARED_OBJECTS) $($(dir)_TARGETS))
-rm -f ${E}/*__genmod.*
-rm -f ${O}/*__genmod.*
else
clean:
@echo "cleaning all"
-rm -f $(foreach dir, $(SUBDIRS), $($(dir)_OBJECTS) $($(dir)_MODULES) $($(dir)_TARGETS))
-rm -f ${E}/*__genmod.*
-rm -f ${O}/*__genmod.*
endif
realclean: clean
@echo "cleaning bundled Scotch in directory: ${SCOTCH_DIR}/src"
$(MAKE) -C ${SCOTCH_DIR}/src realclean
-rm -rf $E/* $O/*
help:
@echo "usage: make [executable]"
@echo ""
@echo "supported executables:"
@echo " xspecfem2D"
@echo " xmeshfem2D"
@echo " xadj_seismogram"
@echo " xcheck_quality_external_mesh"
@echo " xconvolve_source_timefunction"
@echo ""
.PHONY: all default backup clean realclean help
#######################################
# Get dependencies and rules for building stuff
include $(patsubst %, ${S_TOP}/src/%/rules.mk, $(SUBDIRS))
#######################################
##
## Shortcuts
##
# Shortcut for: <prog>/<xprog> -> bin/<xprog>
define target_shortcut
$(patsubst $E/%, %, $(1)): $(1)
.PHONY: $(patsubst $E/%, %, $(1))
$(patsubst $E/x%, %, $(1)): $(1)
.PHONY: $(patsubst $E/x%, %, $(1))
endef
# Shortcut for: dir -> src/dir/<targets in here>
define shortcut
$(1): $($(1)_TARGETS)
.PHONY: $(1)
$$(foreach target, $$(filter $E/%,$$($(1)_TARGETS)), $$(eval $$(call target_shortcut,$$(target))))
endef
$(foreach dir, $(SUBDIRS), $(eval $(call shortcut,$(dir))))
# Other old shortcuts
mesh : $E/xmeshfem2D
spec : $E/xspecfem2D
.PHONY: mesh spec