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 rejects valid code

 
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: 1024

PostPosted: Thu Nov 22, 2018 7:40 pm    Post subject: Compiler rejects valid code Reply with quote

According to the Fortran 95 standard,
Quote:
14.1.3 Statement and construct entities
The name of a variable that appears as the DO variable of an implied-DO in a DATA statement or an array constructor has a scope of the implied-DO list. It is a scalar variable that has the type and type parameters that it would have if it were the name of a variable in the scoping unit that includes the DATA statement or array constructor, and this type shall be integer type; it has no other attributes.

Therefore, the following code is correct:
Code:
module amod
integer :: ia(2) = (/ (i+2, i=2,3) /)
end module

subroutine suba
use amod
integer :: i
print *,'In suba, i,ia = ',(i,ia(i),'  ',i=1,2)
end subroutine

program tst
call suba
end program

The use of 'I' as the implied DO index on Line-2 does not create a variable 'I' in module AMOD. However, FTN95 8.30 says:
Code:
[FTN95/Win32 Ver. 8.30.279 Copyright (c) Silverfrost Ltd 1993-2018]
    PROCESSING MODULE  [<AMOD> FTN95/Win32 v8.30.279]
    NO ERRORS  [<AMOD> FTN95 v8.30.279]
0007) integer :: i
*** I has already been declared in MODULE AMOD
    1 ERROR  [<SUBA> FTN95 v8.30.279]
    NO ERRORS  [<TST> FTN95 v8.30.279]
*** Compilation failed


I wish to acknowledge the help of Steve Lionel (retd. from Intel). He pointed out the corresponding section of the F2008 standard on Usenet comp.lang.fortran.


Last edited by mecej4 on Fri Nov 23, 2018 10:15 am; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Nov 23, 2018 9:27 am    Post subject: Reply with quote

Thank you for the feedback. I have logged this for investigation.
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