f90wrap icon indicating copy to clipboard operation
f90wrap copied to clipboard

f90wrap gets confused if the argument of a module procedure has name of the interface

Open mcuntz opened this issue 4 years ago • 0 comments

Dear James,

this is an error probably due to bad programming and I do not see how it could be resolved. The Fortran program should probably be edited (that's what I did whence I found the error).

The individual module procedures had an argument with exactly the name of the interface. The test program is:

module itestit

  implicit none

  private
  
  public :: testit

  interface testit
     module procedure testit1, testit2
  end interface testit
  
contains

  subroutine testit1(n,testit)

    implicit none

    integer,            intent(in)    :: n
    real, dimension(n), intent(inout) :: testit

    real :: swap

    swap = testit(1)
    testit = swap

  end subroutine testit1

  subroutine testit2(testit)

    implicit none

    real, dimension(:), intent(inout) :: testit

    real, dimension(size(testit,1)) :: swap

    swap = testit
    testit = swap

  end subroutine testit2

end module itestit

You see that testit1 and testit2 have arguments with the name testit. So f90wrap writes the following:

subroutine f90wrap_testit1(n, testit, n0)
    use itestit, only: testit
    implicit none
    integer, intent(in) :: n
    real, intent(inout), dimension(n0) :: testit
    integer :: n0
    !f2py intent(hide), depend(testit) :: n0 = shape(testit,0)
    call testit(n=n, testit=testit)
end subroutine f90wrap_testit1

subroutine f90wrap_testit2(testit, n0)
    use itestit, only: testit
    implicit none
    real, intent(inout), dimension(n0) :: testit
    integer :: n0
    !f2py intent(hide), depend(testit) :: n0 = shape(testit,0)
    call testit(testit=testit)
end subroutine f90wrap_testit2

So it uses testit from the module itestit. But then the input arguments are also called testit. This obviously fails during compiling.

As said, I think this is bad programming and I do not see how f90wrap could deal with it. But I just wanted to report it anyway.

Kind regards Matthias

mcuntz avatar Mar 12 '20 23:03 mcuntz