Array Expression to Do Loop[MESSAGE NOT SCANNED]
Arjen Markus
arjen.markus@wldelft.nl
Fri Dec 5 12:59:00 GMT 2008
> Sorry, I do mean automatic translation. I was considering the effect of
> intrinsics, multiple dimensions and dependencies on more complicated
> array expressions; and (ultimately) hoping to see how it translates into
> something like C.
>
> I think Vast once converted F90 to F77, but alas now it's done the other
> way :)
>
Yes, I used to use Vast ... An intriguing feature it had was
that it combined consecutive loops.
Well, my use of "you" was merely a figure of speech. As array
expressions in Fortran can actually be something like:
a(1:50) = a(2:100:2) ! Note: elements of a are used both sides!
an implementation will very probably have to use a temporary array.
Something along these lines:
do i = 1,50
tmp(i) = a(2*i)
enddo
do i = 1,50
a(i) = tmp(i)
enddo
But if the expression is as simple as:
a = b
it could very well be a call to memcpy() or similar.
Most intrinsic functions are actually elemental. That is:
a = sin(b)
would get translated into:
do i = 1,100
a(i) = sin(b(i))
enddo
Regards,
Arjen
More information about the Fortran
mailing list