Bug: symbol not found for a function using module, etc.

First, the example, “test.f90”:

module blas
contains
function ddot(n,x,dx,y,dy)
  implicit none
  integer :: n,dx,dy
  real*8 :: x(*),y(*),ddot
  integer :: i
  ddot=0.0d0
  do i=0,n-1
    ddot=ddot+x(i*dx)*y(i*dy)
  end do
end function ddot
end module blas

module middle
use blas, b_ddot=>ddot
procedure(b_ddot), pointer :: my_ddot
end module middle

function ddot(n,x,dx,y,dy)
  use middle
  implicit none
  integer :: n,dx,dy
  real*8 :: x(*),y(*),ddot
  ddot=b_ddot(n,x,dx,y,dy)
end function ddot

program test
implicit none
integer, parameter :: n=100
integer :: i
real*8 :: x(n), y(n)
real*8, external :: ddot

do i=1,n
  x(i)=dble(i)
  y(i)=dble(n-i)
end do
write(6,*) ddot(n,x,1,y,1)

end program test

Compiling with “pgfortran test.f90” (PGI 15.3) gives:

PGF90-S-0038-Symbol, ddot, has not been explicitly declared (test.f90)
0 inform, 0 warnings, 1 severes, 0 fatal for ddot

while “gfortran” (4.8.2) works. The error disappears (and the program runs and gives the expecter result) if I comment out the procedure pointer declaration in the “middle” module, note that this pointer is never used! I had this problem with 14.7, and hoped it would be fixed with TPR 21166, but apparently it isn’t.[/code]

Hi Ignacio Fdez. Galvan,

TPR#21166 was reported in 14.10 and fixed in 15.1. I’m not sure what the difference between this code and that found in TPR#21166, but you are correct that they exhibit similar behavior. I created a new TPR, #21465, and sent to back to engineering for investigation.

The work around is to add “real(8)” before “function ddot(n,x,dx,y,dy)”.

 % cat test.f90
module blas
 contains
 function ddot(n,x,dx,y,dy)
   implicit none
   integer :: n,dx,dy
   real*8 :: x(*),y(*),ddot
   integer :: i
   ddot=0.0d0
   do i=0,n-1
     ddot=ddot+x(i*dx)*y(i*dy)
   end do
 end function ddot
 end module blas

 module middle
 use blas, b_ddot=>ddot
 procedure(b_ddot), pointer :: my_ddot
 end module middle

 real(8) function ddot(n,x,dx,y,dy)
! function ddot(n,x,dx,y,dy)
   use middle
   implicit none
   integer :: n,dx,dy
   real(8) :: x(*),y(*),ddot
   ddot=b_ddot(n,x,dx,y,dy)
 end function ddot

 program test
 implicit none
 integer, parameter :: n=100
 integer :: i
 real*8 :: x(n), y(n)
 real*8, external :: ddot

 do i=1,n
   x(i)=dble(i)
   y(i)=dble(n-i)
 end do
! write(6,*) ddot(n,x,1,y,1)

 end program test


% pgf90 test.f90
%

Thanks,
Mat

TPR 21465 - User code gets bogus “Symbol, ddot, has not been explicitly declare”
has been corrected in the current 15.5 release

thanks,
dave