GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — f2py parser fails on a Fortran function with C binding · Issue #9693 · numpy/numpy

f2py parser fails on a Fortran function with C binding #9693

New issue
Copy link
New issue
Copy link
Closed
#24555
Closed
f2py parser fails on a Fortran function with C binding#9693
#24555
Copy link
Assignees
HaoZeke
Labels
component: numpy.f2py

Description

@dhermes
dhermes
opened on Sep 15, 2017
Issue body actions

Related to #2275 (I opened a new issue per @charris request).

See this gist for a repro. Observed with numpy==1.13.1 in Python 3.6. The source causing a failure is:

function wat(x, y) result(z) bind(c, name='wat')
  integer, intent(in) :: x, y
  integer :: z

  z = x + y
end function wat

Activity

  1. dhermes
    changed the title [-]f2py parser fails when a Fortran function with C binding[/-] [+]f2py parser fails on a Fortran function with C binding[/+] on Sep 15, 2017
  2. kprussing commented on Dec 17, 2017

    @kprussing
    kprussing
    on Dec 17, 2017
    More actions

    This is in part due to the fact that the bind(c) attribute is part of the Fortran 2003 standard and the snippet is not valid Fortran 2003. The function must be in a module that uses the iso_c_binding module. A valid minimum failing example would be:

    module mfe
        use iso_c_binding
        implicit none
    contains
        function wat(x, y) result(z) bind(c, name='wat')
            integer(c_int), intent(in) :: x, y
            integer(c_int) :: z
        
            z = x + 7
        end function wat
    end module mfe
    

    This compiles happily with gfortran on macOS 10.12.6 However, this still throw an assertion error with NumPy 1.13.3

    AssertionError: (1, "x, y@)@ result@(@z@)@ bind@(@c, name='wat'", "x@,@ y@)@ result@(@z@)@ bind@(@c, name='wat'", ')')
    

    I get the same error in both Python 3.6 and 2.7 installed from MacPorts. I cloned the repo and managed to build tags v1.6.0 and v1.7.0 against the native Python (2.7), but I still get the error.

    So, is this a user error trying to parse the source using f2py.crackfortran.crackfortran or a parer error as referenced in the closed issue? Are there any other tags where this was to have been fixed?

    Update: Fixed the attributes to properly declare the types of the arguments.

  3. eric-wieser
    added
    component: numpy.f2py
    on Dec 18, 2017
  4. HaoZeke
    self-assigned this
    on Aug 25, 2021
  5. charris
    closed this as completedin #24555on Sep 2, 2023
  6. github-project-automation
    added this to f2py coreon Aug 26, 2024
  7. github-project-automation
    moved this to Done in f2py coreon Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @HaoZeke
    HaoZeke

Labels

component: numpy.f2py

Type

No type

Projects

  • f2py core
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.