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 

FTN95 gets scope of interface definition wrong

 
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: Fri Feb 09, 2018 6:33 pm    Post subject: FTN95 gets scope of interface definition wrong Reply with quote

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


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

PostPosted: Sat Feb 10, 2018 10:46 am    Post subject: Reply with quote

mecej4

Many thanks for the feedback and for the effort you have made to reduce this to a short piece of coding.

FTN95 remembers some things between separate program units when they occur in the same file and this is not always appropriate.
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: Thu Jul 18, 2019 6:37 pm    Post subject: Reply with quote

This bug has now been fixed for the next release of FTN95.
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