- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have been wasting time for hours trying to understand why my code does not work, the way it should as the Fortran standard says. and finally I realized Intel Fortran compiler does not provide automatic reallocation by default, as it was introduced in Fortran 2003 Standard. According to this page:
https://software.intel.com/en-us/articles/error-variable-not-allocated-assume-realloc_lhs
one has to use the compilation flag /assume:realloc_lhs to get the "default" behavior as one should in modern Fortran. Why is there so much drag to follow the new Fortran standards? It is now a decade and half since this feature was introduced and yet one has to explicitly request the compiler to recognize the new Fortran stanard. Thanks for any reasonable explanation, and permanent fix to this problem, if there is any.
I am using: Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.0.108 Build 20140726
Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have standards checking (/stand) to f03 or higher than you get /assume:realloc_lhs automatically I believe. Ifort does it this wway as otherwise old code that conformed to f95 would/could break.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you use a more recent compiler, such as the current 17.0.4, /assume:realloc_lhs is the default. Earlier versions did what you described, and I remember reading discussions of what the default should be.
Please see https://software.intel.com/en-us/node/678232 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your answers. I think this could also explain the random behaviors that I have seen on different devices with different Intel compiler versions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The flag you need to use is /standard-semantics. Use it, always.
The Fortran 2003 behaviour does not break conforming Fortran 95 programs, but it may have a slight performance impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Ian. Is the performance hit you mentioned specific to parts of the codes that use the new >2003 standard features, or is it broader? For example, if I compile a F90 code with F03 syntax enabled, would it perform worse than when F03 syntax is disabled? My own naive answer would be "no".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
/standard-semantics definitely does break some f95-conforming programs, but usually this is due to a change from one valid implementation choice to another. You have to get creative to compose a program that is guaranteed to behave differently between f95 and f2003.
- 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
andrew_4619 wrote:
If you have standards checking (/stand) to f03 or higher than you get /assume:realloc_lhs automatically I believe. Ifort does it this wway as otherwise old code that conformed to f95 would/could break.
/stand does not affect this. You are correct that defaulting to current standard behavior across the board would break many existing programs. All of these cases are where earlier standards did not specify behavior and left it up to implementations. Over the years, The DEC/Compaq/Intel compilers did change defaults where it could without breaking many programs or severely impacting performance.

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