gfortran has some strange behaviour for implied DO loops:
used in a print, the final value of the loop variable is retained
used in an assignment, the loop variable is left untouched
program main
integer i
integer is(5)
print *, i ! 0
print *, ( i, i = -1, 2 )
print *, i ! 3
is = [ (i, i = 2, 6) ]
print *, is
print *, i ! 3
end
Putting aside the print behaviour, they feel like syntactic sugar. gfortran even tells you if it's the wrong shape for the assigning array, implying it evaluates them to arrays during compilation. Based on this, I feel the assignment inside implied DOs isn't a real assignment, just syntax reuse.
gfortran has some strange behaviour for implied DO loops:
print
, the final value of the loop variable is retainedPutting aside the
print
behaviour, they feel like syntactic sugar. gfortran even tells you if it's the wrong shape for the assigning array, implying it evaluates them to arrays during compilation. Based on this, I feel the assignment inside implied DOs isn't a real assignment, just syntax reuse.