mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Fri Feb 09, 2018 6:33 pm Post subject: FTN95 gets scope of interface definition wrong |
|
|
This is a bug report about FTN95 8.10, 32- and 64-bit.
Given the interface definition (file fnint.f90)
Code: | module fn_int
interface
subroutine f(x, v)
real, dimension (:), intent (in) :: x
real, dimension (:), intent (out) :: v
end subroutine f
end interface
end module fn_int |
and a subroutine that uses that interface (file stpqf.f90):
Code: | subroutine stpqf(n, y, a, f0)
use fn_int
implicit none
integer :: n
real :: a(n), f0(n+1), y(n)
!
call f(y(2:n+1), f0(1:n))
f0(1:n) = y(1)*f0(1:n) + (1.0-y(1))*(y(2:n+1)-a(1:n))
return
!
end subroutine stpqf |
the compiler has no problems. Likewise, it handles the following (file stpds.f90):
Code: | subroutine stpds(f, neqn, y, x, yp)
implicit none
real :: x
integer :: neqn
!
real :: y(neqn), yp(neqn)
!
interface
subroutine f(s, y, yp, n)
integer :: n
real :: s, y(n+1), yp(n+1)
end subroutine f
end interface
call f(x, y, yp, neqn-1)
return
end subroutine stpds |
However, if the subroutines occur in the same source file, with the code for STPDS preceding that for STPQF, the compiler gives an incorrect error message. For the source file stp.f90, with contents:
Code: | include 'stpds.f90'
include 'stpqf.f90' |
the compiler says:
Code: | 1/0007) call f(y(2:n+1), f0(1:n))
*** The third argument (YP) to F is missing (In include file s:\Homp\splt\stpqf.f90)
*** The fourth argument (N) to F is missing | The F with 4 arguments is a dummy argument to STPDS, and its actual name/address is not known at compile time. The subroutine with the actual name F takes 2 arguments and is called from STPQF. Within STPQF, the interface to the 4 argument subroutine F is not in scope.
NOTE: The actual code that caused me to notice this bug is HOMPACK90.F at http://people.cs.vt.edu/~ltw/hompack/hompack90/ . The code above resulted from ruthless deletion of lines from that source file. |
|