- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI All!
I'm compiling the code below in gfortan, ifort 11.1 and ifort 14.0.3.
PROGRAM TEST REAL :: x, x2(5), z COMPLEX :: y, y2(5) z = -1. z=sqrt(z) x=5./z x2=5./z y = (1.,1.)*x y2= (1.,1.)*x2 WRITE(*,*) x WRITE(*,*) x2 WRITE(*,*) y WRITE(*,*) y2 WRITE(*,*) x /= x WRITE(*,*) ANY(x2 /= x2) WRITE(*,*) y /= y WRITE(*,*) ANY(y2 /= y2) END PROGRAM TEST
The problem is when ifort 11.1 compares an array of NaNs with another array of NaNs, it returns false instead of true. Is it a compiler bug? Is there a way to set ifort 11.1 in a way it outputs the same results as in ifort 14.3?
$ gfortran -V gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) $ ./teste_gfortran NaN NaN NaN NaN NaN NaN ( NaN, NaN) ( NaN, NaN) ( NaN, NaN) ( NaN, NaN) ( NaN, NaN) ( NaN, NaN) T T T T
$ ifort -V Intel(R) Fortran Intel(R) 64 Compiler Professional for applications running on Intel(R) 64, Version 11.1 Build 20090827 Package ID: l_cprof_p_11.1.056 Copyright (C) 1985-2009 Intel Corporation. All rights reserved. $ ./teste_ifort_11_1 NaN NaN NaN NaN NaN NaN (NaN,NaN) (NaN,NaN) (NaN,NaN) (NaN,NaN) (NaN,NaN) (NaN,NaN) T T F F
$ ifort -V Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.3.174 Build 20140422 Copyright (C) 1985-2014 Intel Corporation. All rights reserved. t$ ./teste_ifort_14_03 NaN NaN NaN NaN NaN NaN (NaN,NaN) (NaN,NaN) (NaN,NaN) (NaN,NaN) (NaN,NaN) (NaN,NaN) T T T T
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your program is actually asking if any of the array elements is not equal to the others, and for NaN, a NaN isn't equal to anything else, even another NaN. However, we don't guarantee such comparisons unless you compile with "-fp strict", so try that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve!
I got the same thing, no change...
$ ifort -fp-model strict teste.f90 -O -o teste_ifort3 $ ./teste_ifort3 NaN NaN NaN NaN NaN NaN (NaN,NaN) (NaN,NaN) (NaN,NaN) (NaN,NaN) (NaN,NaN) (NaN,NaN) T T F F
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, I don't know then. That's an old, unsupported version. You should be using IEEE_ISNAN from intrinsic module IEEE_ARITHMETIC instead of comparing.

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