forked from MODFLOW-ORG/mt3d-usgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeson.build
More file actions
197 lines (175 loc) · 6.4 KB
/
Copy pathmeson.build
File metadata and controls
197 lines (175 loc) · 6.4 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
project(
'mt3dusgs',
'fortran',
version: '1.1.1',
license: 'CC0-1.0',
license_files : ['LICENSE'],
meson_version: '>= 1.3.1',
default_options : [
'b_vscrt=static_from_buildtype',
'buildtype=release',
'debug=false',
'fortran_std=legacy',
])
install_data('LICENSE', install_dir : 'bin')
if get_option('buildtype') == 'release'
profile = 'release'
else
profile = 'develop'
endif
message('Profile:', profile)
is_double = get_option('double')
message('Double precision:', is_double)
# ---------------------------------------------------------------
# Option OpenMP (--Dopenmp=true pour activer)
# ---------------------------------------------------------------
is_openmp = get_option('openmp')
message('OpenMP:', is_openmp)
# ---------------------------------------------------------------
# Option profiling Instruments (--Dprofiling=true pour activer)
# ---------------------------------------------------------------
is_profiling = get_option('profiling')
message('Profiling (Instruments):', is_profiling)
# parse compiler options
fc = meson.get_compiler('fortran')
fc_id = fc.get_id()
message('Compiler ID:', fc_id)
compile_args = []
link_args = []
extra_deps = []
# ---------------------------------------------------------------
# Command line options for gfortran
# ---------------------------------------------------------------
if fc_id == 'gcc'
# General options
compile_args += [
'-fall-intrinsics',
'-pedantic',
'-cpp',
'-ffixed-line-length-none',
'-fdec', # Enable DEC extensions (SHARE, BUFFERED in OPEN statements)
'-Wcharacter-truncation',
'-Wno-unused-dummy-argument', # This makes problems with OOP
'-Wno-intrinsic-shadow', # We shadow intrinsics with methods, which should be fine
'-Wno-maybe-uninitialized', # "Uninitialized" flags produce false positives with allocatables
'-Wno-uninitialized',
]
if is_double
compile_args += [
'-fdefault-real-8',
'-fdefault-double-8',
]
endif
# ---------------------------------------------------------------
# Flags profiling pour Instruments (macOS)
# Active avec : meson setup builddir -Dprofiling=true
# ---------------------------------------------------------------
if is_profiling
compile_args += [
'-g', # Symboles de debug (necessaires pour Instruments)
'-fno-omit-frame-pointer', # Conserver les frame pointers pour call stack
'-O1', # Optimisation legere pour garder la lisibilite
]
message('Profiling flags enabled: -g -fno-omit-frame-pointer -O1')
endif
# Define OS with gfortran for OS specific code
# These are identical to pre-defined macros available with ifort
system = build_machine.system()
if system == 'linux'
compile_args += '-D__linux__'
elif system == 'darwin'
compile_args += '-D__APPLE__'
elif system == 'windows'
compile_args += '-D_WIN32'
endif
endif
# ---------------------------------------------------------------
# Command line options for ifort
# ---------------------------------------------------------------
if fc_id == 'intel-cl'
# windows
compile_args += ['/fpe:0', # Activate all floating point exceptions
'/heap-arrays:0',
'/traceback',
'/fpp', # Activate preprocessing
'/extend-source',
'/Qdiag-disable:7416', # f2008 warning
'/Qdiag-disable:7025', # f2008 warning
'/Qdiag-disable:5268', # Line too long
'/Qdiag-disable:10448',# ifort deprecation warning
]
link_args += ['/ignore:4217', # access through ddlimport might be inefficient
'/ignore:4286' # same as 4217, but more general
]
if is_double
compile_args += [
'/real-size:64',
'/double-size:64',
]
endif
elif fc_id == 'intel' or fc_id == 'intel-llvm'
# linux and macOS
compile_args += ['-fpe0', # Activate all floating point exceptions
'-no-heap-arrays',
'-traceback',
'-extend-source',
'-diag-disable:7416', # f2008 warning
'-diag-disable:7025', # f2008 warning
'-diag-disable:5268', # Line too long
]
link_args += '-static-intel'
if is_double
compile_args += [
'-r8',
'-autodouble',
]
endif
# Command line options for ifx
elif fc_id == 'intel-llvm-cl'
# windows
compile_args += ['/fpe:0', # Activate all floating point exceptions
'/heap-arrays:0',
'/traceback',
'/extend-source',
'/fpp', # Activate preprocessing
'/Qdiag-disable:7416', # f2008 warning
'/Qdiag-disable:7025', # f2008 warning
'/Qdiag-disable:5268', # Line too long
]
if is_double
compile_args += [
'/4R8',
'/Qautodouble',
]
endif
endif
add_project_arguments(fc.get_supported_arguments(compile_args), language: 'fortran')
add_project_link_arguments(fc.get_supported_arguments(link_args), language: 'fortran')
# ---------------------------------------------------------------
# OpenMP
# Active avec : meson setup builddir -Dopenmp=true
# Sur macOS : brew install libomp requis
# ---------------------------------------------------------------
if is_openmp
omp = dependency('openmp', required: true)
if omp.found()
message('OpenMP found and enabled')
extra_deps += omp
else
error('OpenMP requested but not found. On macOS: brew install libomp')
endif
endif
# ---------------------------------------------------------------
# build
# ---------------------------------------------------------------
if is_double
buildname = 'mt3dusgsdbl'
else
buildname = 'mt3dusgs'
endif
message('Executable name: ' + buildname)
subdir('src')
test('version',
exe,
should_fail: true,
workdir: meson.current_source_dir())