Re: Array Constructors
- From: "Arjen Markus" <arjen.markus@xxxxxxxxxx>
- Date: 28 Feb 2007 03:56:35 -0800
On 28 feb, 12:05, c...@xxxxxxxxx wrote:
Hello,
Can anyone confirm that when a variable is used in an implied do loop
in an array constructor, is its value always restored afterwards. For
example, if I do:
integer :: i
integer :: XYZ(8)
call date_and_time(values = XYZ)
i = 42
write (*,"(I5)") i
write (*,"(8I5)") (/(XYZ(i),i=1,8)/)
write (*,"(I5)") i
will the last line written always be 42. Intuitively, it felt like it
should be, as I would hope that the two i's are total separate.
However, IVF complained if the variable used in the array constructor
had not been declared (with implicit none set). It does works with
IVF, but I can't see anything in the documentation that states this
must always be the case.
Chris
I can confirm this works with g95 (on Linux) too, but
I am quite surprised: I always thought implied do-loops
were very much like ordinary do loops.
Apparently, they are not.
Still, the i within the implied do-loop is a variable and
it could have been a real too, so the compiler has every
right to complain :)
Regards,
Arjen
.
- References:
- Array Constructors
- From: cjk32
- Array Constructors
- Prev by Date: Re: Matlab -> Fortran
- Next by Date: Re: Array Constructors
- Previous by thread: Array Constructors
- Next by thread: Re: Array Constructors
- Index(es):
Relevant Pages
|
|