- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
h(1:3) = TriShell%h(1:3)
em = TriShell%em
h and em are both arrays, which method of assignment is Fortran preferred now?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Simpler is better. The first version makes the compiler work harder to optimize the assignment. It is also much clearer to the human reading the code. I touched on this in Doctor, it hurts when I do this! - Doctor Fortran (stevelionel.com)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The newer Fortran standards default to realloc_lhs = .true.
When the destination array is allocatable, for example your em on lhs,
this may result in em being deallocated (if allocated) then allocated to the size of TriShell%em
This may (used to) occur even though em is the same size as TriShell%em.
Intel may have fixed this (tested for same size and bounds then avoid reallocation) with the newer ifort and/or ifx.
You can use:
em(:) = TriShell%em
or
em(:) = TriShell%em(:)
or
use the explicit bounds for each array
This will assure no reallocation of lhs (should em be allocatable).
But expect error should em not be allocated .OR. size not the same.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve:
https://www-cs-faculty.stanford.edu/~knuth/address.html
was more fun to read, you should definitely rewrite BIM or SIM or whatever.
If you know any of these people let them know.
Jim:
It is English right? LOL
use the explicit bounds for each array === I will.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@JohnNichols wrote:
Steve:
https://www-cs-faculty.stanford.edu/~knuth/address.html
was more fun to read, you should definitely rewrite BIM or SIM or whatever.
I wrote an extended MIX interpreter (I called it XIM, in IBM 360 assembler) in college (mid-70s), supporting floating point and all of the extensions he had proposed. Wrote a letter to Knuth about it, he wrote back with encouragement. I had also asked when volume 4 of TAOCP was coming out, he basically said "don't hold your breath". I do now have the set that includes "volume 4A". Brings back memories, it does.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Steve_Lionel Wasn't MIX replaced by MMIX (a RISC machine)?
Also, in a letter I received in February 1990 from Knuth regarding volume 4 being published, he said "soon".
Doc (not an Intel employee or contractor)
[Maybe Windows 12 will be better]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes.
Doc (not an Intel employee or contractor)
[Maybe Windows 12 will be better]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No - that was 45 years ago!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page