Re: Scope of implied-do index
- From: Brooks Moses <bmoses-nospam@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 30 Aug 2006 21:50:18 -0700
Brooks Moses wrote:
"The name of a variable that appears as the DO variable of an implied-DO in a DATA statement or an array constructor has the 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."[...]
From this I conclude that not only is your code legal, but the following (where i is an array in the outer scope, but a scalar within the construct) is also legal:
integer i(2,0:3,5)
real x(10)
x = (/ (i, i=1, 10) /)
While I'm on the subject (and with the thought in mind that these probably ought go into the gfortran test suite), I believe that the following as well are legal:
integer, parameter :: i
real x(10)
x = (/ (i, i=1, 10) /)
integer, external :: i
real x(10)
x = (/ (i, i=1, 10) /)
integer, intrinsic :: ubound
real x(10)
x = (/ (ubound, ubound=1, 10) /)
function foo(i) result(x)
integer, intent(in) :: i
real x(10)
x = (/ (i, i=1, 10) /)
end function
And, similarly, substituting a write statement with an implied-do for the array statement in any of those should produce an error.
- Brooks
--
The "bmoses-nospam" address is valid; no unmunging needed.
.
- References:
- Scope of implied-do index
- From: Steven G. Kargl
- Re: Scope of implied-do index
- From: Brooks Moses
- Scope of implied-do index
- Prev by Date: Re: Scope of implied-do index
- Next by Date: Re: best way to use the USE statement
- Previous by thread: Re: Scope of implied-do index
- Next by thread: Re: Scope of implied-do index
- Index(es):
Relevant Pages
|