-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeson.build
More file actions
204 lines (179 loc) · 5.04 KB
/
meson.build
File metadata and controls
204 lines (179 loc) · 5.04 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
198
199
200
201
202
203
204
# SPDX-FileCopyrightText: 2023 Sunip K. Mukherjee
#
# SPDX-License-Identifier: Apache-2.0
project('glowpython2', 'c',
version : '0.0.2',
license: 'BSD-3',
meson_version: '>=0.64.0',
default_options : ['warning_level=2'],
)
add_languages('fortran')
# Find Python interpreter and dependency
py_mod = import('python')
py = py_mod.find_installation(pure: false)
py_dep = py.dependency()
# Define installation directory
install_dir = join_paths(py.get_install_dir(), 'glowpython2')
# Get numpy include directories
incdir_numpy = run_command(py,
[
'-c',
'import numpy; print(numpy.get_include())'
],
check: true
).stdout().strip()
# Get numpy.f2py include directory
incdir_f2py = run_command(py,
['-c', 'import numpy.f2py; print(numpy.f2py.get_include())'],
check : true
).stdout().strip()
# Combine include directories
inc_np = include_directories(incdir_numpy, incdir_f2py)
# Install Python source files
py.install_sources(
'src/glowpython2/__init__.py',
'src/glowpython2/atmo_iri90.py',
'src/glowpython2/atmo_msis00.py',
'src/glowpython2/igrf.py',
'src/glowpython2/pogo68.py',
'src/glowpython2/coeffs.py',
'src/glowpython2/base.py',
'src/glowpython2/utils.py',
'src/glowpython2/version.py',
'src/glowpython2/plots.py',
'src/glowpython2/examples.py',
subdir: 'glowpython2',
pure: false,
)
# Install data directories
install_subdir(
'src/GLOW/data',
install_dir: install_dir,
strip_directory: false,
)
install_subdir(
'src/ATMO/data',
install_dir: install_dir,
strip_directory: false,
)
install_subdir(
'src/IGRF/data',
install_dir: install_dir,
strip_directory: false,
)
# GLOW Fortran sources
glow_fort_srcs = [
'src/GLOW/cglow.f90',
'src/GLOW/glow.f90',
'src/GLOW/bands.f90',
'src/GLOW/conduct.f90',
'src/GLOW/pyconduct.f90',
'src/GLOW/egrid.f90',
'src/GLOW/ephoto_init.f90',
'src/GLOW/ephoto.f90',
'src/GLOW/etrans.f90',
'src/GLOW/exsect.f90',
'src/GLOW/gchem.f90',
'src/GLOW/gchem_modglow.f90',
'src/GLOW/maxt.f90',
'src/GLOW/qback.f90',
'src/GLOW/rcolum.f90',
'src/GLOW/solzen.f90',
'src/GLOW/ssflux_init.f90',
'src/GLOW/ssflux.f90',
'src/GLOW/vquart.f90',
]
# GLOW Fortran F2PY wrapper
glowpython_source = custom_target('glowfortmodule.c',
input : glow_fort_srcs,
output : ['glowfortmodule.c', 'glowfort-f2pywrappers.f', 'glowfort-f2pywrappers2.f90'],
command : [py, '-m', 'numpy.f2py', '@INPUT@', '-m', 'glowfort', '--lower']
)
# MSIS-00 and IRI-90 Fortran sources
atmo_fort_srcs = [
'src/ATMO/iri90.f',
'src/ATMO/nrlmsise00.f',
'src/ATMO/dfp.f90',
'src/ATMO/geomag.f90',
'src/ATMO/snoem.f90',
]
# ATMO static library
atmo_static = static_library('atmo',
atmo_fort_srcs,
fortran_args : ['-cpp', '-march=native', '-ffast-math', '-std=legacy'],
install : false,
)
# ATMO F2PY wrapper
atmoshim_tgt = custom_target('glowatmomodule.c',
input : ['src/ATMO/atmo.f90'],
output : ['glowatmomodule.c', 'glowatmo-f2pywrappers.f'],
command : [py, '-m', 'numpy.f2py', '@INPUT@', '-m', 'glowatmo', '--lower']
)
# FIELDM Fortran sources
fieldm_fort_srcs = [
'src/FIELDM/fieldm.f',
'src/FIELDM/geomag.f90',
]
# FIELDM static library
fieldm_static = static_library('fieldm',
fieldm_fort_srcs,
fortran_args : ['-cpp', '-march=native', '-ffast-math', '-std=legacy'],
install : false,
)
# FIELDM F2PY wrapper
fieldm_tgt = custom_target('glowfieldmmodule.c',
input : ['src/FIELDM/magfield.f90'],
output : ['glowfieldmmodule.c', 'glowfieldm-f2pywrappers.f'],
command : [py, '-m', 'numpy.f2py', '@INPUT@', '-m', 'glowfieldm', '--lower']
)
# IGRF Fortran static library
igrf_static = static_library('igrf',
['src/IGRF/igrf.f', 'src/IGRF/dfp.f90'],
fortran_args : ['-cpp', '-march=native', '-ffast-math', '-std=legacy'],
install : false,
)
# IGRF F2PY wrapper
igrf_tgt = custom_target('glowigrfmodule.c',
input : ['src/IGRF/igrf14_shim.f90'],
output : ['glowigrfmodule.c', 'glowigrf-f2pywrappers2.f90'],
command : [py, '-m', 'numpy.f2py', '@INPUT@', '-m', 'glowigrf', '--lower']
)
# GLOW Python extension module
py.extension_module('glowfort',
glow_fort_srcs + [glowpython_source],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
install : true,
install_dir: install_dir
)
# FIELDM Python extension module
py.extension_module('glowfieldm',
['src/FIELDM/magfield.f90', fieldm_tgt],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
link_with: [fieldm_static],
install : true,
install_dir: install_dir
)
# ATMO Python extension module
py.extension_module('glowatmo',
['src/ATMO/atmo.f90', atmoshim_tgt],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
link_with: [atmo_static],
install : true,
install_dir: install_dir
)
# IGRF Python extension module
py.extension_module('glowigrf',
['src/IGRF/igrf14_shim.f90', igrf_tgt],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
link_with: [igrf_static],
install : true,
install_dir: install_dir
)