vector expression question.
Steve Kargl
sgk@troutmask.apl.washington.edu
Thu Nov 17 19:45:00 GMT 2011
On Thu, Nov 17, 2011 at 11:30:52AM -0800, Mike Kumbera wrote:
> program test
>
> integer, parameter :: n = 10
> integer :: i(n) = (/ 1, 2, 3, 4, 5, 5, 4, 3, 2, 1/)
> integer x(5),xser(5)
>
> ! cumaddin
> xser = 0;
> do j = 1, n
> xser (i (j)) = xser (i (j)) + 1
> enddo
> write (*,*) xser
>
> x = 0;
> x(i) = x(i) + 1 ! same as the loop above
The RHS is evaulated before the LHS is assigned a value.
So, what you have is essentially x(i) = (/0,0,0,0,0,0,0,0,0,0,0/) + 1.
--
Steve
More information about the Fortran
mailing list