Silverfrost Forums

Welcome to our forums

Compiler bug processing interface

5 Apr 2017 7:09 #19346

FTN95 8.10, 32-bit and 64-bit, incorrectly states that the following code is in error and needs a type declaration for FFUNC:

    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.

6 Apr 2017 6:56 #19349

Thank you for the bug report. I have logged it as needing attention.

13 Jun 2017 12:47 #19746

This has been fixed for the next release of FTN95.

The problem arises because real(kind(0.0d0)) comes before 'function'. A work-around is to move the type declaration of psi from where it is to within the body of the function....

function psi(.... real(kind(0.0d0)) psi

Please login to reply.