At the moment of building the implied loop, you have no array, you have an expression that just builds some sequence of things.
(i, i = 1, 3)
generates a sequence
1, 2, 3
You can print it
print *, (i, i = 1, 3)
An array only appears once you put the implied loop into an array constructor.
(/ (i, i = 1, 3) /)
or
[(i, i = 1, 3)]
generates an anonymous array 1:3
with three elements.
But even then you get an array expression, which is indexed from one, not your array a
that is on the left hand side of the assignment. The right hand side is always evaluated completely and only after that the compiler looks at the left hand side of =
.
So you cannot really index and reference any previous elements of the array in an implied loop, if those elements are created by the implied loop. Keep your normal do loop for what you are doing here.