8000 BUG: c2capi_map entries missing for iso_c_binding in f2py · Issue #25207 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: c2capi_map entries missing for iso_c_binding in f2py #25207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hmenke opened this issue Nov 20, 2023 · 0 comments · Fixed by #25226
Closed

BUG: c2capi_map entries missing for iso_c_binding in f2py #25207

hmenke opened this issue Nov 20, 2023 · 0 comments · Fixed by #25226

Comments

@hmenke
Copy link
hmenke commented Nov 20, 2023

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 subroutine

Error 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
[{'numpy_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']}}]
None

Context for the issue:

Workaround: Create a .f2py_f2cmap with the contents

{'integer':{'c_int64_t':'long_long'}}
HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 22, 2023
HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 22, 2023
HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 26, 2023
HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 26, 2023
HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 26, 2023
HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 26, 2023
HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 26, 2023
charris pushed a commit to charris/numpy that referenced this issue Dec 23, 2023
charris pushed a commit to charris/numpy that referenced this issue Dec 23, 2023
charris pushed a commit to charris/numpy that referenced this issue Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0