forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compiler bug processing interface

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
mecej4



Joined: 31 Oct 2006
Posts: 1884

PostPosted: Wed Apr 05, 2017 8:09 pm    Post subject: Compiler bug processing interface Reply with quote

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.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7912
Location: Salford, UK

PostPosted: Thu Apr 06, 2017 7:56 am    Post subject: Reply with quote

Thank you for the bug report. I have logged it as needing attention.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7912
Location: Salford, UK

PostPosted: Tue Jun 13, 2017 1:47 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group