-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
239 lines (229 loc) · 7.91 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
#-----------------------------------------------------------------------
# Copyright 2011-2016 Lasse Lambrecht (Ruhr-Universität Bochum, GER)
# Copyright 2014-2020 Thomas Möller (Ruhr-Universität Bochum, GER)
# Copyright 2014-2020 Marc S. Boxberg (RWTH Aachen University, GER)
#
# This file is part of NEXD 1D.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEXD 2D. If not, see <http://www.gnu.org/licenses/>.
#-----------------------------------------------------------------------
# General definitions
#
# Check Operating system:
OS := $(shell uname)
#
# set the SHELL
# MSB MSB: Actually nothing should be specified here! (or SHELL = /bin/sh if really necessary for any reason...)
SHELL = /bin/tcsh
# Paths
bindir = ./bin
obsdir = ./obj
moduledir = ./mod
srcdir = ./src
AR = ar
# Choose your compiler:
gf = gfortran
#gf = ifort
F95 = mpif90
ifeq ($(notdir $(F95)),g95)
FFLAGS = -O3 -Wunused -fmod=$(moduledir)
else ifeq ($(gf),gfortran)
# ==================================================================
# GFORTRAN COMPILER
# ==================================================================
# Choose a suitable set of compiler flags for gfortran. The default
# flags are explained in the following...
# required:
# -J$(moduledir)
# -fimplicit-none
# -ffixed-line-length-none
# -ffree-line-length-none
# optional:
# -O3 : The compiler tries to optimize the code to
# make it faster. Level 3 is the most
# optimization available.
# -Og : Enables optimizations that do not interfere
# with debugging. It should be the
# optimization level of choice for the
# standard edit-compile-debug cycle.
# -funroll-all-loops : This might increase the speed of the code
# as well.
# -fbounds-check : Add a check that the array index is within
# the bounds of the array every time an array
# element is accessed.
# This substantially slows down a program
# using it, but is a very useful way to find
# bugs related to arrays.
# -fbacktrace : If the program crashes, a backtrace will be
# produced if possible.
# -Wall : gfortran will generate warnings about many
# common sources of bugs.
# -Wpedantic : Generate warnings about language features
# that are supported by gfortran but are not
# part of the official Fortran 95 standard.
# -Wextra : This enables some extra warning flags that
# are not enabled by -Wall. Note,
# -Wunused-parameter (part of -Wextra) has a
# problem to correctly work with constants.h.
# recommended flags for developers:
# FFLAGS = -Og -J$(moduledir) -fimplicit-none -ffixed-line-length-none -ffree-line-length-none -fbounds-check -fbacktrace -Wall -Wpedantic -Wextra
# recommended flags for profiling (CP CP):
# FFLAGS = -O3 -J$(moduledir) -fimplicit-none -ffixed-line-length-none -ffree-line-length-none -funroll-all-loops -pg -g -no-pie
# recommended flags for users:
FFLAGS = -O3 -J$(moduledir) -fimplicit-none -ffixed-line-length-none -ffree-line-length-none -funroll-all-loops
else ifeq ($(gf),ifort)
# ==================================================================
# INTEL COMPILER (ifort)
# ==================================================================
# Choose a suitable set of compiler flags for ifort. The default
# flags are explained in the following...
# required:
# -module $(moduledir)
# -implicitnone
# -132
# optional:
# -O3 : The compiler tries to optimize the code to
# make it faster. Level 3 is the most
# optimization available. Level 0 (-O0) is
# recommended for developers.
# -funroll-loops : This might increase the speed of the code
# as well.
# -nowarn : Suppresses all warnings.
# developers:
# FFLAGS = -O0 -module $(moduledir) -implicitnone -132
# users:
FFLAGS = -O3 -module $(moduledir) -implicitnone -132 -funroll-loops -nowarn
endif
obj_solver = \
solverPro.o \
constantsMod.o \
parameterMod.o \
matrixMod.o \
mesh1DMod.o \
gllMod.o \
jacobiMod.o \
vandermonde1DMod.o \
localOperatorsMod.o \
rosettaGammaMod.o \
materials1DMod.o \
outputMod.o \
riemannflux1Dmod.o \
rhsElastic1DMod.o \
rhsPoroelastic1DMod.o \
rhsSlipInterface1DMod.o \
errorMessage.o \
realloc.o \
sourcesMod.o \
slipInterfaceMod.o \
genericMaterial.o \
analyticalSolutionMod.o \
slopeLimiterMod.o \
receiverMod.o \
boundaryConditionsMod.o \
calendar.o \
convert_time.o
obj_analyticalSol = \
analyticalSolution.o \
constantsMod.o \
parameterMod.o \
matrixMod.o \
slipInterfaceMod.o \
errorMessage.o \
materials1DMod.o \
realloc.o
obj_test = testprogramm.o \
#-------------------------------------------------------
# Direcory search
#
vpath %.o $(obsdir)
vpath %.f90 $(srcdir) ./src/include
vpath %.f $(srcdir) ./src/include
vpath %.c $(srcdir) ./src/include
#--------------------------------------------------------
# additional directories to be searched for module or include dependencies
# default is search in ./ only
#
DEPDIRS = $(srcdir) ./src/include
#-------------------------------------------------------
# Implicit rule to compile .o files from .f90 files.
# Because of vpath, targets and dependencies need not be
# in the current directory.
#
%.o: %.f90
$(gf) -c $(FFLAGS) $< -o $(obsdir)/$@
%.o: %.f
$(gf) -c $(FFLAGS) -fimplicit-none -ffixed-line-length-132 $< -o $(obsdir)/$@
%.o: %.c
gcc -c $(CFLAGS) $< -o $(obsdir)/$@
#--------------------------------------------------------------
# Object string for linking:
# Adds object dir as prefix and removes directory part
# of $^ (all dependencies)
#
obstring = $(addprefix $(obsdir)/,$(notdir $^))
obstringtest = $(addprefix $(obsdir)/,$(notdir $^))
#
# End of generic part of Makefile
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# Library paths
ifeq ($(OS), Linux)
pgplot = -lpgplot -L/usr/lib -lpng -lz -lX11
endif
ifeq ($(OS), Darwin)
pgplot = -lpgplot -L/usr/local/lib -lpng -lz -L/usr/X11/lib -lX11
endif
la = -llapack -lblas
#lib = metis-4.0.3/libmetis.a
#---------------------------------------------------------
.PHONY: all
#
# create dependencies on modules
# make.incdep is a Makefile because it is included. Such files are first updated
# before anything else and make starts from anew including all updated makefiles
#
make.incdep:
./makeDepFromUseInclude.py $(DEPDIRS) > $@
-include make.incdep
#
cleanlsi:
rm -f $(bindir)/solver $(moduledir)/*.mod $(obsdir)/*.o make.incdep
#
clean:
rm -f $(bindir)/solver $(bindir)/analytical $(moduledir)/*.mod $(obsdir)/*.o make.incdep
#
solver: $(obj_solver)
$(gf) $(FFLAGS) -o $(bindir)/$@ $(obstring) $(la) $(pgplot)
analytical: $(obj_analyticalSol)
$(gf) $(FFLAGS) -o $(bindir)/$@ $(obstring) $(la)
test: $(obj_test)
$(gf) $(FFLAGS) -o $(bindir)/$@ $(obstring) $(la)
bin:
mkdir -p $(bindir)
#
mod:
mkdir -p $(moduledir)
#
obj:
mkdir -p $(obsdir)
#
required: mod obj bin
#
DEFAULT = \
required \
solver
#
default: $(DEFAULT)
#
all: default