- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
the following code shows some issues and surprising behavior with minloc:
program p
use ieee_arithmetic
implicit none
real :: inf, nan
inf = ieee_value (inf, ieee_positive_inf)
nan = ieee_value (nan, ieee_quiet_nan)
print *, "Testing minloc with zero-sized arrays"
print *, minloc ([real ::]), " <-- should be 0"
print *, minloc ([inf],mask=.false.), " <-- should be 0"
print *
print *, "Testing minval and minloc with ieee exceptional values"
print *, minval ([inf,-inf])
print *, minval ([nan, inf])
print *, minval ([nan, nan]), " <-- likely ok"
print *
print *, minloc ([inf, nan]), " <-- should be 1 (ok)"
print *, minloc ([inf, nan],back=.true.), " <-- should be 1 (ok)"
print *, minloc ([nan, inf]), " <-- should be 2"
print *, minloc ([nan, inf],back=.true.), " <-- should be 2 (ok)"
print *, minloc ([nan, nan]), " <-- likely ok"
print *, minloc ([nan, nan],back=.true.), " <-- likely ok"
end
ifx 2024.2.0 produces the following result:
Testing minloc with zero-sized arrays
1 <-- should be 0
1 <-- should be 0
Testing minval and minloc with ieee exceptional values
-Infinity
Infinity
Infinity <-- likely ok
1 <-- should be 1 (ok)
1 <-- should be 1 (ok)
1 <-- should be 2
2 <-- should be 2 (ok)
1 <-- likely ok
1 <-- likely ok
First, the result for zero-sized arrays is defined by the standard to be 0; ifx clearly has a bug here.
Some of the other results may be surprising. If there is no ieee finite array element, the result of minval could be expected to be Infinity or NaN in the third test (source line 15).
However, I don't understand why the result of minloc in source line 19 could be 1 instead of 2. Does ifx confuse NaN with Infinity? But then I do not understand why source line 21 and 22 give the same result.
Thanks for any insight.
Harald
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
using -standard-semantics I got
Testing minloc with zero-sized arrays
0 <-- should be 0
0 <-- should be 0
We are investigating the issue with the rest of the output.

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