- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just came across a curious capability of Fortran in a manual.
Is it true that in Fortran an array can be assigned to itself in reverse order as in:
INTEGER, PARAMETER :: max = ...
REAL ::A(max)
... initialzation of data in A ...
A(1 : max) = A(max : 1 : -1)
without any form of temporary being used?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, because the language semantics mean that the compiler creates a temporary for you. Then the compiler tries to figure out if the temporary can be eliminated, which in this case it probably isn't.
In essence, array assignment completely evaluates the right-hand-side of the assignment before assigning to the left-hand-side.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page