Reputation: 330
I need help to understand why I cannot compile this code
program test
integer,dimension(1:10) :: isquares
isquares(:) = (j**2,j=1,10)
print*,isquares
end
However, this version is ok:
program test
print*,(j**2,j=1,10)
end
Upvotes: 2
Views: 93
Reputation: 18098
(j**2,j=1,10)
is a implicit loop. For an assignment, you need to convert this into an array first:
isquares(:) = [(j**2,j=1,10)]
Upvotes: 2