Compiler problem: Generic procedures

Hi,
as previously mentioned we are evaluating PGI Visual Fortran for porting our FEM application to CUDA. However we have some issues not related to CUDA that we need to solve:

It seems that there is a compiler error in the treatment of generic procedures, below is an example that fails with PGI fortran (11.1) but compiles with e.g. intel fortran.

Here is the code:
!
module A
private
public :: A_new

interface A_new
module procedure new
end interface A_New
contains
subroutine new( r )
real :: r

r = 5.0
end subroutine new
end module A

module AA
use A

private
public :: A_new

interface A_new
module procedure new
end interface A_New

contains
subroutine new( r, i )
integer :: i
real :: r

r = 5.0
i =6
end subroutine new
end module AA

module AAA

!use A
use AA
contains

subroutine new( r, i )
integer :: i
real :: r

call A_new( r )
call A_new( r,i )
end subroutine new
end module AAA

The error message is:
: error S0155 : Could not resolve generic procedure a_new

However, changing the general “private” statement in module A and AA to the specific “private new”, the compilation returns with no error. As each module contains only one subroutine, these 2 version of the code should be identical but the compiler “believes” different.

In our code we have as a general principle that we use the “private” statement to change the default from public to private in our modules, and we think that there must be an error in the compiler or are there some compiler flags that may correct this?

Einar

Hi,

A workaround for now would be in module AA

use A, only:A_new

It seems to fix the problem. We will need to investigate more on this and will let you know on this thread.

I have filed a TPR#17633.


Thank you,
Hongyon

Well, this fixed our simple example, but for our full code it just moved the error.
The rest of the post refers to our production code where we have a similar module structure to A,AA and AAA.

Introducing the ONLY statement in what corresponds to AA with the module procedures of A produces now a compilation error compiling AA.

It seems as though the compiler is not able to find the reference to procedures in A from AA. Removing the ONLY statement, AA will compile fine but now we have the original problem of AAA.

For now we are stuck, but hopefully this issue will be solved.