replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Compilation error - but why?
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 

Compilation error - but why?

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



Joined: 02 Aug 2005
Posts: 318

PostPosted: Wed Apr 10, 2013 5:20 pm    Post subject: Compilation error - but why? Reply with quote

Hi, the following generates an error at compile time...

Code:
!ftn95$free
    program test
   
    real*4  :: array(10)
   
    do i=1,10
      array(i)=float(i)
    end do
     
    call test1(array, 10)
   
    end
   
    subroutine test1 (array, anum)
   
    real*4  :: array(anum)
    integer anum
   
    aval=minval(array)
    write(*,*) aval
   
    end
   
   

I can code around it manually by swapping the two declarations in the subroutine, but my source is automatically generated from a list of function declarations supplied by a 3rd-party and in that list, the number of elements in the array are declared after the array itself and not with "fortran integers" in mind, thus:

!void test1(ref System.Float[]& array, ref int anum)

so editing all the places where this occurs manually is a bit of a faff! is it fixable in the compiler?

K
Back to top
View user's profile Send private message Visit poster's website
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Wed Apr 10, 2013 5:26 pm    Post subject: Reply with quote

There should be a compile error here!

When ARRAY is declared, the variable ANUM hasn't been given a type, and so the compiler thinks its real (since it begins A). The compiler is not allowed to look ahead to see that ANUM is Integer. This is part of the Fortran Standard.

You can make it work by swapping the declaration, or by changing the name to NUM (anything starting I-N) ( or by changing ARRAY(ANUM) to ARRAY(*) if the size of the array isn't used implicitly in the subroutine, i.e. you don't use MAX(ARRAY) or anything similar).

Maybe you can ask the 3rd party to change how they generate the code to comply with the Fortran Standard? The error isn't in the C void declaration thats OK, its in the actual Fortran code, so maybe change how this is generated?

David.
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
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