Fortran ieee_arithmetic NaN

The Fortran 2003 standard ieee_arithmetic intrinsic module gives a robust standard way to use NaN and other functions. However, on certain CPU arches such as PPC, GCC does not yet support ieee_arithmetic.

An example of robust NaN is given in nans.f90. A Fortran standard way to make NaN constant is:

use, intrinsic :: ieee_arithmetic, only: ieee_value, ieee_quiet_nan
implicit none

real:: nan

nan = ieee_value(0., ieee_quiet_nan)

Example NaN memory hex value–can be distinct on older/other compilers:

GCC 12.2.0; Intel oneAPI 2021, 2023
      IEEE   value   isnan                         hex
    real 32    NaN      T                          7FC00000
    real 64    NaN      T                  7FF8000000000000
    real128    NaN      T  7FFF8000000000000000000000000000
 complex 64    NaN      T                          7FC00000
 complex128    NaN      T                  7FF8000000000000
 complex256    NaN      T  7FFF8000000000000000000000000000

nvfortran 22.11 is same for real32/64