-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
283 lines (228 loc) · 10.1 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
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
# This Makefile tests the applicability of compilers for a project of developing optimization solvers.
#
# Coded by Zaikun Zhang (www.zhangzk.net).
#
# Started: Dec 2021
#
# Last Modified: Dec 16, 2021
.PHONY: test clean
####################################################################################################
# Variables
# Fortran standard to follow. We aim to $(MAKE) the code compatible with F2003, F2008, and F2018.
FS = 03
FSTD = 20$(FS)
# Default options for all the compilers.
FFLAGS = -g -O0
# Common directories.
COMMON = ./common
# Headers.
HEADERS = $(COMMON)/*.h
# Solver directories.
SOLVERS = ./solvers
# Test suite directory
TESTSUITE = ./testsuite
####################################################################################################
# All the tests
test:
$(MAKE) atest
$(MAKE) gtest
$(MAKE) itest
$(MAKE) ntest
$(MAKE) stest
$(MAKE) xtest
$(MAKE) test_empty
$(MAKE) test_flang # flang, aflang, nvfortran: fail
$(MAKE) test_intel # ifort, ifx: false positive of unused variable
$(MAKE) test_ieee # ifort, ifx: crash
$(MAKE) dtest # Fail: Array, Implied do, Alloc, Solve
$(MAKE) ftest # Fail: Array, Implied do, Alloc, Solve
$(MAKE) vtest # Fail: Array, Implied do, Alloc, Empty, Solve
$(MAKE) ltest # Fail
$(MAKE) 9test # Fail
####################################################################################################
# Here are the compilers to test. We impose all the options that are actually used in the project.
# G95
9tes%: FC = g95 -std=f$(FSTD) -pedantic -Wall -Wextra \
-Wimplicit-none -Wline-truncation -Wprecision-loss -Wunused-module-vars -Wunused-vars -Wunset-vars \
-fimplicit-none -fbounds-check -ftrace=full
# Absoft af95
ates%: FC = af95 -m1 -en -et -Rb -Rc -Rs -Rp
# AMD AOCC Flang
AFLANG := $(shell find /opt/AMD \( -type l -o -type f \) -executable -name flang -print 2>/dev/null | sort | tail -n 1 || echo AFLANG_NOT_FOUND)
dtes%: FC = $(AFLANG) -std=f$(FSTD) -Wall -Wextra -Minform=warn -Mstandard -Mbounds -Mchkptr -Kieee -ffp-exception-behavior=strict
# LLVM Flang
ftes%: FC = flang -std=f$(FSTD) -Wall -Wextra -Minform=warn -Mstandard -Mbounds -Mchkptr -Kieee
# GNU gfortran
gtes%: FC = gfortran -Wall -Wextra -pedantic -Wampersand -Wconversion -Wuninitialized \
-Wmaybe-uninitialized -Wsurprising -Waliasing -Wimplicit-interface -Wimplicit-procedure \
-Wintrinsics-std -Wunderflow -Wuse-without-only -Wdo-subscript \
-Wunused-parameter -fPIC -fimplicit-none -fbacktrace -fcheck=all \
-finit-real=nan -finit-integer=-9999999
#-Wrealloc-lhs -Wrealloc-lhs-all
# Intel ifort
ites%: FC = ifort -stand f$(FS) -warn all -check all -debug extended -fimplicit-none \
-ftrapuv -init=snan,array -fpe0 -fpe-all=0 -assume ieee_fpe_flags \
-fp-trap=divzero,invalid,overflow,underflow,denormal
# Lahey lf95
ltes%: FC = lf95 --f95 -v95s -v95o -AU --ap --chkglobal --lst --sav --xref --in --info --nswm --trace \
-w --warn --wo --chk a,e,f,o,s,u,x
# NAG nagfor
ntes%: FC = nagfor -colour=error:red,warn:magenta,info:cyan \
-I $(TESTSUITE) \
-f$(FSTD) -info -gline -u -C -C=alias -C=dangling -C=intovf -C=undefined -kind=unique \
-Warn=constant_coindexing -Warn=subnormal #-Warn=allocation
# NVIDIA nvfortran (aka, pgfortran)
vtes%: FC = nvfortran -C -Wall -Wextra -Minform=warn -Mstandard -Mbounds -Mchkstk -Mchkptr -Kieee -Ktrap=divz,ovf,inv
# Oracle sunf95
stes%: FC = sunf95 -w3 -u -U -ansi -xcheck=%all -C -fnonstd -ftrap=overflow,division,invalid
# Intel ifx
xtes%: FC = ifx -ftrapuv -init=snan,array -fpe0 -fpe-all=0 -assume ieee_fpe_flags \
-ftrapuv -init=snan,array -fpe0 -fpe-all=0 -assume ieee_fpe_flags \
-fp-trap=divzero,invalid,overflow,underflow,denorma -no-ftz -fp-model strict
####################################################################################################
# Making a specific test
test_flang_nan: test_flang_nan.f90
flang -Ofast test_flang_nan.f90 && ./a.out
test_sum: test_sum.f90
flang test_sum.f90 && ./a.out
test_mult_nan: test_mult_nan.f90
nagfor -ieee=full test_mult_nan.f90 && ./a.out
test_abs: test_abs.f90
nagfor -ieee=full test_abs.f90 && ./a.out
test_mult: test_mult.f90
nagfor -O1 test_mult.f90 && ./a.out
test_isorth: test_isorth.f90
nagfor test_isorth.f90 && ./a.out
test_trans: test_trans.f90
nagfor test_trans.f90 && ./a.out
test_value: test_value.f90
flang -c test_value.f90 && ./a.out
test_eqv: test_eqv.f90
gfortran -Ofast test_eqv.f90 && ./a.out
test_indices: test_indices.f90
nagfor test_indices.f90 && ./a.out
test_char: test_char.f90
#gfortran-12 -g -Wmaybe-uninitialized -Werror -std=f2018 test_char.f90
gfortran -g -Wmaybe-uninitialized -Werror -std=f2018 test_char.f90 # gfortran-11 raises a false positive
ifort -g -warn all -check all -debug extended test_char.f90
ifx -g -O0 -warn all -check all -debug extended test_char.f90
nagfor -g -C test_char.f90
flang -g -Wall -Wextra test_char.f90
nvfortran -g -Wall -Wextra test_char.f90
aflang -g -Wall -Wextra test_char.f90
sunf95 -g -w3 -ansi -xcheck=%all -C test_char.f90
test_nagfor_ice: test_nagfor_ice.f90 # NAG Fortran Compiler Release 7.1(Hanzomon) Build 7114 encountered an ICE
nagfor -C -kind=unique -c test_nagfor_ice.f90
test_nan_fpe: test_nan_fpe.f90
ifort -standard-semantics -fp-stack-check -fpe-all=0 -traceback test_nan_fpe.f90 && ./a.out
gfortran -g -ffpe-trap=invalid test_nan_fpe.f90 && ./a.out
test_nan_flang: test_nan_flang.f90
flang test_nan_flang.f90 && ./a.out
flang -O test_nan_flang.f90 && ./a.out
flang -O1 test_nan_flang.f90 && ./a.out
flang -O2 test_nan_flang.f90 && ./a.out
flang -O3 test_nan_flang.f90 && ./a.out
test_div_strong: test_div_strong.f90
ifort test_div_strong.f90 && ./a.out
ifort -O2 test_div_strong.f90 && ./a.out
test_div: test_div.f90
ifort test_div.f90 && ./a.out
ifort -O2 test_div.f90 && ./a.out
test_intel_sym_strong: test_intel_sym_strong.f90
ifx test_intel_sym_strong.f90 && ./a.out
ifort test_intel_sym_strong.f90 && ./a.out
test_intel_sym: test_intel_sym.f90
ifort -O0 test_intel_sym.f90 && ./a.out
ifort -O1 test_intel_sym.f90 && ./a.out
ifort -Ofast test_intel_sym.f90 && ./a.out
ifort test_intel_sym.f90 && ./a.out
ifort -O test_intel_sym.f90 && ./a.out
ifort -O2 test_intel_sym.f90 && ./a.out
ifort -O3 test_intel_sym.f90 && ./a.out
ifort -O4 test_intel_sym.f90 && ./a.out
ifort -O5 test_intel_sym.f90 && ./a.out
test_index: test_index.f90
af95 -g -m1 -en -et -Rb -Rc -Rs -Rp test_index.f90 && ./a.out
af95 test_index.f90 && ./a.out
test_def: test_def.f90
nagfor -C=undefined test_def.f90 && ./a.out
test_trace: test_trace.f90
af95 -g -et -TENV:simd_zmask=off test_trace.f90 && ./a.out
test_shape: test_shape.f90
ifx test_shape.f90 && ./a.out
ifx -warn shape test_shape.f90 && ./a.out
ifx -check shape test_shape.f90 && ./a.out
ifort test_shape.f90 && ./a.out
ifort -warn shape test_shape.f90 &&./a.out
ifort -check shape test_shape.f90 &&./a.out
test_rank: test_rank.f90
nagfor -C test_rank.f90 && ./a.out
test_loc: test_loc.f90
nagfor test_loc.f90 && ./a.out
test_vec: test_vec.f90
nagfor test_vec.f90 && ./a.out
sunf95 test_vec.f90 && ./a.out
test_infnan: test_infnan.f90
af95 test_infnan.f90 && ./a.out
test_nan: test_nan.f90
af95 test_nan.f90 && ./a.out
test_sym: test_sym.f90
nagfor test_sym.f90 && ./a.out
af95 test_sym.f90 && ./a.out
test_solve: test_solve.f90
# AOCC 3.2.0 fails the following
$(AFLANG) -Mbounds test_solve.f90 && ./a.out
#flang -O3 test_solve.f90 && ./a.out # OK, -C means "Include comments in preprocessed output"
#$(AFLANG) -O3 test_solve.f90 && ./a.out # OK, -C means "Include comments in preprocessed output"
# Flang 15.0.3 fails the following
flang -Mbounds test_solve.f90 && ./a.out
test_empty: test_empty.f90
flang -Mbounds test_empty.f90 && ./a.out # OK
flang -O3 test_empty.f90 && ./a.out # OK, -C means "Include comments in preprocessed output"
$(AFLANG) -Mbounds test_empty.f90 && ./a.out # OK
$(AFLANG) -O3 test_empty.f90 && ./a.out # OK, -C means "Include comments in preprocessed output"
nvfortran -Mbounds test_empty.f90 && ./a.out # OK
nvfortran -C test_empty.f90 && ./a.out # OK
nvfortran -C -O3 test_empty.f90 && ./a.out # -C means "Generate code to check array bounds"
test_ieee: test_ieee.f90
ifx --version && ifx -warn all -c test_ieee.f90 # Crash: ifx (IFORT) 2022.0.0 20211123
ifort --version && ifort -warn all -c test_ieee.f90 # Crash: ifort (IFORT) 2021.5.0 20211109
test_flang: test_flang.f90
flang --version && flang test_flang.f90
nvfortran --version && nvfortran test_flang.f90
$(AFLANG) --version && $(AFLANG) test_flang.f90
test_intel: test_intel.f90
ifort --version && ifort -warn all test_intel.f90 && ./a.out
ifx --version && ifx -warn all test_intel.f90 && ./a.out
%test: test.f90 \
consts.o infos.o debug.o memory.o inf.o infnan.o string.o linalg.o rand.o \
ratio.o resolution.o history.o selectx.o circle.o checkexit.o output.o preproc.o pintrf.o evaluate.o \
solver_unc.o solver_con.o \
uob.o solver_uoa.o \
param.o noise.o prob.o test_solver.o \
test_implied_do.o test_count.o test_alloc.o test_filt.o \
test_array12.o test_array3.o \
coa.o test_coa.o \
cob.o test_cob.o \
test_circle.o
@printf '\n$@ starts!\n\n'
$(FC) $(FFLAGS) -o $@ test.f90 *.o 2>&1
@printf '\n===> $@: Compilation completes successfully! <===\n\n'
./$@
$(MAKE) clean
@printf '\n===> $@: Test completes successfully! <===\n\n'
# Compile the Fortran code providing generic modules
%.o: $(COMMON)/%.*90 $(HEADERS)
$(FC) $(FFLAGS) -c -o $@ $<
# Compile the Fortran code providing solver-specific modules
%.o: $(SOLVERS)/%.f90
$(FC) $(FFLAGS) -c -o $@ $<
# Compile the Fortran code of the test suite
%.o: $(TESTSUITE)/%.f90
$(FC) $(FFLAGS) -c -o $@ $<
####################################################################################################
# Cleaning up.
clean:
rm -f *.o *.mod *.dbg core.*
rm -f testsuite/*.o testsuite/*.mod testsuite/*.dbg
rm -f atest* dtest* ftest* gtest* itest* ltest* ntest* stest* vtest* xtest* a.out