Silverfrost Forums

Welcome to our forums

Compiler rejects valid code

22 Nov 2018 6:40 (Edited: 23 Nov 2018 9:15) #22845

According to the Fortran 95 standard,

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:

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:

[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.

23 Nov 2018 8:27 #22849

Thank you for the feedback. I have logged this for investigation.

4 Feb 2019 2:57 #23208

This bug has now been fixed for the next release of FTN95.

Please login to reply.