-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Description
Describe the issue:
In #24555 the implementation of f2cmap was supplemented by definitions from iso_c_binding, however, due to an oversight there are no corresponding c2capi_map entries which results in KeyError during an f2py run.
Reproduce the code example:
subroutine add(A, B, C, N)
use iso_c_binding, only: c_int64_t
implicit none
integer(c_int64_t), intent(in) :: A(*)
integer(c_int64_t), intent(in) :: B(*)
integer(c_int64_t), intent(out) :: C(*)
integer, intent(in) :: N
integer :: j
do j = 1, N
C(j) = A(j)+B(j)
end do
end subroutineError message:
$ python3 -m numpy.f2py -m add add.f90
Reading fortran codes...
Reading file 'add.f90' (format:free)
Post-processing...
Block: add
Block: add
In: :add:add.f90:add
get_useparameters: no module iso_c_binding info used by add
Applying post-processing hooks...
character_backward_compatibility_hook
Post-processing (stage 2)...
Building modules...
Building module "add"...
Generating possibly empty wrappers"
Maybe empty "add-f2pywrappers.f"
Constructing wrapper function "add"...
getarrdims:warning: assumed shape array, using 0 instead of '*'
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/local/lib64/python3.12/site-packages/numpy/f2py/__main__.py", line 5, in <module>
main()
File "/usr/local/lib64/python3.12/site-packages/numpy/f2py/f2py2e.py", line 734, in main
run_main(sys.argv[1:])
File "/usr/local/lib64/python3.12/site-packages/numpy/f2py/f2py2e.py", line 496, in run_main
ret = buildmodules(postlist)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib64/python3.12/site-packages/numpy/f2py/f2py2e.py", line 418, in buildmodules
dict_append(ret[name], rules.buildmodule(module, um))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib64/python3.12/site-packages/numpy/f2py/rules.py", line 1298, in buildmodule
api, wrap = buildapi(nb)
^^^^^^^^^^^^
File "/usr/local/lib64/python3.12/site-packages/numpy/f2py/rules.py", line 1476, in buildapi
vrd = capi_maps.sign2map(a, var[a])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib64/python3.12/site-packages/numpy/f2py/capi_maps.py", line 602, in sign2map
ret['pydocsign'], ret['pydocsignout'] = getpydocsign(a, var)
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib64/python3.12/site-packages/numpy/f2py/capi_maps.py", line 410, in getpydocsign
c2pycode_map[
KeyError: 'int64_t'Runtime information:
>>> import sys, numpy; print(numpy.__version__); print(sys.version)
1.26.2
3.12.0 (main, Oct 2 2023, 00:00:00) [GCC 13.2.1 20230918 (Red Hat 13.2.1-3)]
>>> print(numpy.show_runtime())
WARNING: `threadpoolctl` not found in system! Install it by `pip install threadpoolctl`. Once installed, try `np.show_runtime` again for more detailed build information
[{'num
6A6E
py_version': '1.26.2',
'python': '3.12.0 (main, Oct 2 2023, 00:00:00) [GCC 13.2.1 20230918 (Red '
'Hat 13.2.1-3)]',
'uname': uname_result(system='Linux', node='0794a3b936a4', release='5.15.0-78-generic', version='#85~20.04.1-Ubuntu SMP Mon Jul 17 09:42:39 UTC 2023', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_SKX',
'AVX512_CLX'],
'not_found': ['AVX512_KNL',
'AVX512_KNM',
'AVX512_CNL',
'AVX512_ICL']}}]
NoneContext for the issue:
Workaround: Create a .f2py_f2cmap with the contents
{'integer':{'c_int64_t':'long_long'}}
HaoZeke