- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We are in the process of comparing test case outputs after porting a large amount of legacy code from Digital Visual Fortran 6 to IVF 10.
We have a case where we compute a value using a real*8 function and assign the result to a real*4 local variable. Later we use that variable in an expression, all the other values in which are real*8 (including the result). In the old compiler this particular code compiles to use the in-memory single-precision value but the new compiler, unless you disable optimization, keeps the computed real*8 value in a register and uses that instead.
We found the intrinsic SNGL() function, which claims to produce a default-precision output from any FP input and our default (legacy code, remember) is real*4. But injecting this into the code had no effect whatsoever.
In this particular case we'll probably change the leftover intermediate variable to a real*8 and update the baseline dataset. But it raises the question: If I want to force rounding to single precision at a particular point in a computation, how do I do it? Other than by putting a real*8 -> real*4 "identity" function in a C++ support library, I mean. In C++ I'd mark the intermediate as volatile, is there an equivalent in fortran?
I feel kinda dumb compaining about the optimizer being so good, but there it is. Sometimes you value reproducible results more than speed. And occasionally numerical analysis calls for explicit control of rounding.
Thank you,
-swn
Link Copied
- 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

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