Description
Describe the issue:
I'm attempting to use f2py to compile some fortran code. I'm able to do this using the following numpy versions:
- 1.21.0
- 1.22.0
- 1.23.0
- 1.24.0
- 1.24.2
Starting on v1.24.3, the same compilation code no longer works using f2py. Strangely enough, if I precompile one of files (LAPACK.f), the compilation can work with v1.24.3.
Reproduce the code example:
# I don't see how I can produce runnable code using f2py, as it requires the fortran source code
# This code produces a .so file in my project's home directory on numpy <= 1.24.2 but doesn't work on numpy >= 1.24.3
from pathlib import Path
from numpy import f2py
project_path = Path(__file__).resolve().parent
disort_directory = project_path.joinpath('disort4.0.99')
module_name = 'disort'
fortran_source_filenames = ['BDREF.f', 'DISOBRDF.f', 'ERRPACK.f', 'LAPACK.f', 'LINPAK.f', 'RDI1MACH.f']
fortran_paths = [disort_directory.joinpath(f) for f in fortran_source_filenames]
with open(disort_directory.joinpath('DISORT.f')) as disort_module:
f2py.compile(disort_module.read(), modulename=module_name, extra_args=fortran_paths)
# If I precompile LAPACK.f using:
# /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -g -fno-second-underscore -fPIC -O3 -funroll-loops -c LAPACK.f
# then it works using numpy = 1.24.3. Note the only difference in the code is the LAPACK.f is now LAPACK.o
project_path = Path(__file__).resolve().parent
disort_directory = project_path.joinpath('disort4.0.99')
module_name = 'disort'
fortran_source_filenames = ['BDREF.f', 'DISOBRDF.f', 'ERRPACK.f', 'LAPACK.o', 'LINPAK.f', 'RDI1MACH.f']
fortran_paths = [disort_directory.joinpath(f) for f in fortran_source_filenames]
with open(disort_directory.joinpath('DISORT.f')) as disort_module:
f2py.compile(disort_module.read(), modulename=module_name, extra_args=fortran_paths)
Error message:
There is no error message. f2py simply stops right before where it prints this line:
INFO: compiling Fortran sources
Runtime information:
Line 1 output:
1.24.0
3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]
(note that I have no idea why it says 1.24.0 when Pycharm assures me I'm using 1.24.2)
Line 2 output:
Exception ignored on calling ctypes callback function: <function ThreadpoolController._find_libraries_with_dl_iterate_phdr..match_library_callback at 0x7f592f9c00d0>
Traceback (most recent call last):
File "/repos/pyRT_DISORT/venv/lib/python3.10/site-packages/threadpoolctl.py", line 584, in match_library_callback/repos/pyRT_DISORT/venv/lib/python3.10/site-packages/threadpoolctl.py", line 725, in _make_controller_from_path
self._make_controller_from_path(filepath)
File "
lib_controller = lib_controller_class(
File "/pyRT_DISORT/venv/lib/python3.10/site-packages/threadpoolctl.py", line 842, in init/repos/pyRT_DISORT/venv/lib/python3.10/site-packages/threadpoolctl.py", line 810, in init
super().init(**kwargs)
File "
self._dynlib = ctypes.CDLL(filepath, mode=_RTLD_NOLOAD)
File "/usr/lib/python3.10/ctypes/init.py", line 374, in init
self._handle = _dlopen(self._name, mode)
OSError: dlopen() error
[{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}}]
None
Context for the issue:
I believe that LAPACK.f is one of the more widely used fortran codes. If it cannot compile in conjunction with other code, that could potentially disrupt a good number of users.