Closed
Description
External functions (e.g. #14919 or https://stackoverflow.com/questions/44073679/errors-when-using-a-fortran-call-back-function-in-f2py) do not generate correct headers in f2py if declared in F90 style.
Reproducing code example:
Version A: two lines for external
subroutine a(fcn)
implicit none
external fcn
real(8) :: fcn
real(8) :: x, y
x = 0d0
y = fcn(x)
end
Version B: one line for external
subroutine a(fcn)
implicit none
real(8), external :: fcn
real(8) :: x, y
x = 0d0
y = fcn(x)
end
Output:
Running f2py source.f90 -h header.pyf
produces the following results.
Version a correctly outputs a pyf header
! -*- f90 -*-
! Note: the context of this file is case sensitive.
python module a__user__routines
interface a_user_interface
function fcn(x) result (y) ! in external1.f90:a:unknown_interface
real(kind=8) :: x
real(kind=8) :: y
end function fcn
end interface a_user_interface
end python module a__user__routines
subroutine a(fcn) ! in external1.f90
use a__user__routines
external fcn
end subroutine a
! This file was auto-generated with f2py (version:2).
! See http://cens.ioc.ee/projects/f2py2e/
Version B incorrectly produces a header without external function
! -*- f90 -*-
! Note: the context of this file is case sensitive.
subroutine b(fcn) ! in external2.f90
real(kind=8) :: fcn
end subroutine b
! This file was auto-generated with f2py (version:2).
! See http://cens.ioc.ee/projects/f2py2e/
NumPy/Python version information:
1.19.4 3.9.0 (default, Oct 27 2020, 14:15:17)
[Clang 12.0.0 (clang-1200.0.32.21)]