f90wrap
f90wrap copied to clipboard
Wrong f90wrap_module.f90 code if local variable contains function name
Dear James,
ingenious wrapper, I have to say.
There is an issue if a local variable contains the function name. The test example is: ` module itestit
implicit none
private
public :: testit
contains
function testit(x)
implicit none
! arguments
real, dimension(:), intent(in) :: x
real, dimension(size(x,1)) :: testit
! loca variables
integer :: i
! problematic variable
real :: testit1
do i=1, size(x,1)
testit1 = x(i)
testit(i) = testit1
end do
end function testit
end module itestit ` There is a a variable testit1 in the function testit.
f90wrap writes the following wrapper: ` subroutine f90wrap_testit(ret_testit1, x, n0) use itestit, only: testit implicit none
real, intent(out) :: ret_testit1
real, intent(in), dimension(n0) :: x
integer :: n0
!f2py intent(hide), depend(x) :: n0 = shape(x,0)
ret_testit1 = testit(x=x)
end subroutine f90wrap_testit
You see that it uses testit1 as its return argument. Compilation logically fails with
11 | ret_testit1 = testit(x=x)
| 1
Error: Incompatible ranks 0 and 1 in assignment at (1)
`
Sorry that I cannot offer a patch. That's out of my league.
Kind regards Matthias