mecej4
Joined: 31 Oct 2006 Posts: 1885
|
Posted: Wed Apr 05, 2017 8:09 pm Post subject: Compiler bug processing interface |
|
|
FTN95 8.10, 32-bit and 64-bit, incorrectly states that the following code is in error and needs a type declaration for FFUNC:
Code: |
real(kind(0.0d0)) function psi ( &
xold, xnew, &
fnew, ffunc, &
hnew, hfunc)
implicit none
integer, parameter :: double = kind(1d0)
interface
SUBROUTINE ffunc(x, f)
IMPLICIT NONE
INTEGER, PARAMETER :: dp = kind(0d0)
REAL (dp), INTENT(IN) :: x
REAL (dp), INTENT(OUT) :: f
END SUBROUTINE ffunc
end interface
interface
SUBROUTINE hfunc(x, h)
IMPLICIT NONE
INTEGER, PARAMETER :: dp = kind(0d0)
REAL (dp), INTENT(IN) :: x
REAL (dp), INTENT(OUT) :: h
END SUBROUTINE hfunc
end interface
! external ffunc
real(double) , intent(in) :: xold
real(double) :: xnew, fnew, hnew
!
xnew = xold
call ffunc (xnew, fnew)
psi= fnew
call hfunc (xnew, hnew)
psi = psi+hnew
return
end function psi
|
Curiously, HFUNC is not called out in the same way.
If REAL(dp) and REAL(double) are replaced by plain REAL, the bug goes away.
If the function is declared with a RESULT(res) clause, and 'psi' replaced by 'res' as appropriate in the body of the function, the bug goes away.
If the 'EXTERNAL FFUNC' statement is activated, the compiler is happy, but this should be unnecessary when an interface block has been provided. |
|