Skip to content
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

Duplicated interfaces for Fortran generic interfaces, if there are two interface blocks and interface also from used module #149

Open
haraldkl opened this issue Apr 12, 2019 · 0 comments

Comments

@haraldkl
Copy link

Trying to generate code for the following example:

module other_module
  implicit none

  interface sub
    module procedure sub_real
  end interface sub

contains
  subroutine sub_real(me)
    real :: me
  end subroutine sub_real
end module other_module

module tem_matrix_module
  use other_module, only: sub
  implicit none

  interface sub
    module procedure sub_int
  end interface sub

  interface sub
    module procedure sub_logical
  end interface sub


contains
    subroutine sub_int(me)
      integer :: me
    end subroutine sub_int

    subroutine sub_logical(me)
      logical:: me
    end subroutine sub_logical
end module tem_matrix_module

results in duplicated interface blocks after transforming to xml and back again:

$ F_Front mwe.f90 -o mwe.xml -I.
$ F_Back -l mwe.xml -o mwe_back.f90

Resulting mwe_back.f90:

MODULE other_module
 INTERFACE sub
  MODULE PROCEDURE sub_real
 END INTERFACE

CONTAINS
 SUBROUTINE sub_real ( me )

  REAL :: me

 END SUBROUTINE sub_real

END MODULE other_module

MODULE tem_matrix_module
 USE other_module , ONLY: sub
 INTERFACE sub
  MODULE PROCEDURE sub_int
  MODULE PROCEDURE sub_logical
 END INTERFACE
 INTERFACE sub
  MODULE PROCEDURE sub_int
  MODULE PROCEDURE sub_logical
 END INTERFACE

CONTAINS
 SUBROUTINE sub_int ( me )

  INTEGER :: me

 END SUBROUTINE sub_int

 SUBROUTINE sub_logical ( me )

  LOGICAL :: me

 END SUBROUTINE sub_logical

END MODULE tem_matrix_module

Which is illegal code, while the original was legal.

It may appear strange to have two separate generic interface blocks for the same generic name in the original code, but this arises because we generate the code for different data-types in a pre-processing step.

If the other_module is not used, the transformation works as expected resulting in two interface blocks with only a single module procedure, as in the original code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants