<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic The assignment of cNaN gets in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039772#M112756</link>
    <description>&lt;P&gt;The assignment of cNaN gets trapped in default 32 bit debug configuration (windows) but the 64 bit version traps nothing !&lt;/P&gt;

&lt;P&gt;Using compiler &amp;nbsp; &amp;nbsp;&amp;nbsp; Intel(R) Visual Fortran Compiler XE 15.0.3.208&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jun 2015 13:58:34 GMT</pubDate>
    <dc:creator>Andrew_Smith</dc:creator>
    <dc:date>2015-06-15T13:58:34Z</dc:date>
    <item>
      <title>Use of signaling nan</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039771#M112755</link>
      <description>&lt;P&gt;I have been liberally using non-signalling nans as a debug aid. I can use these anywhere an initialization expression is allowed. But having no signalling limits the usefulness of this method.&lt;/P&gt;

&lt;P&gt;I tried to make use of the new option Qinit:snan but that is only applicable to local scalars which are a small subset of the cases I need.&lt;/P&gt;

&lt;P&gt;I create a parameter for my initialization like this:&lt;/P&gt;

&lt;P&gt;real(DP), parameter :: aNaN = 0.0D0 / 0.0D0.&lt;/P&gt;

&lt;P&gt;and declare arrays within derived types like this:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;type Bar
   real(DP) :: vec(3) = [aNaN, aNaN, aNaN]
end type&lt;/PRE&gt;

&lt;P&gt;So why not change the declaration of aNaN to a signalling version I thought. But having done so it still does not trap.&lt;/P&gt;

&lt;P&gt;This code demonstrates that even if my aNaN parameter has the same bit pattern as Qinit:snan it fails to trap assignment. I also tried the portable IEEE_VALUE function to get a signalling nan it it did not trap either.&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program TestSignalingNaN
   implicit none
   
   integer, parameter :: DP = 8
   real(DP), parameter :: aNaN = z'7FFFBADDADBADDAD' !Value from Qinit:snan
   real(DP), parameter :: bNaN = z'7FFC000000000000' !IEEE_VALUE(1.0_DP, IEEE_SIGNALING_NAN)
   real(DP), save :: cNaN
   
   real(DP) :: a
   a = aNaN
   a = bNaN
   a = cNaN !Only this assignment gets trapped
end program
&lt;/PRE&gt;

&lt;P&gt;The setting for fpe: flag does not appear to make any difference.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2015 13:49:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039771#M112755</guid>
      <dc:creator>Andrew_Smith</dc:creator>
      <dc:date>2015-06-15T13:49:45Z</dc:date>
    </item>
    <item>
      <title>The assignment of cNaN gets</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039772#M112756</link>
      <description>&lt;P&gt;The assignment of cNaN gets trapped in default 32 bit debug configuration (windows) but the 64 bit version traps nothing !&lt;/P&gt;

&lt;P&gt;Using compiler &amp;nbsp; &amp;nbsp;&amp;nbsp; Intel(R) Visual Fortran Compiler XE 15.0.3.208&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2015 13:58:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039772#M112756</guid>
      <dc:creator>Andrew_Smith</dc:creator>
      <dc:date>2015-06-15T13:58:34Z</dc:date>
    </item>
    <item>
      <title>My observation is that you</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039773#M112757</link>
      <description>&lt;P&gt;My observation is that you get the trap when the value is used, not on assignment. But I can't completely explain the behavior and will talk to the developers about it.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2015 15:36:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039773#M112757</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-06-15T15:36:05Z</dc:date>
    </item>
    <item>
      <title>Slightly confused, was there</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039774#M112758</link>
      <description>&lt;P&gt;Slightly confused, was there something missing in the code snipped? In&amp;nbsp;&lt;SPAN style="color: rgb(0, 0, 0); font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 13.0080003738403px; line-height: 14.3088006973267px; background-color: rgb(248, 248, 248);"&gt;a = cNaN, cNan is uninitialised or is it initialised to nan by compiler option....?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:29:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039774#M112758</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2015-06-15T16:29:41Z</dc:date>
    </item>
    <item>
      <title>cNaN would have been set to a</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039775#M112759</link>
      <description>&lt;P&gt;cNaN would have been set to a SNaN by the compiler when /Qinit:snan was used.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:35:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039775#M112759</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-06-15T16:35:11Z</dc:date>
    </item>
    <item>
      <title>How about this?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039776#M112760</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program p

   use, intrinsic :: iso_fortran_env, only : r8 =&amp;gt; real64
   use, intrinsic :: ieee_arithmetic, only : ieee_value, ieee_signaling_nan, ieee_quiet_nan
   use, intrinsic :: ieee_exceptions , only : ieee_invalid, ieee_set_halting_mode

   implicit none

   real(r8) :: a
   real(r8) :: b

   call ieee_set_halting_mode(ieee_invalid, .true.)

   a = ieee_value(real(0.0, kind(r8)), ieee_quiet_nan)
   print *, " a = ", a

   b = ieee_value(real(0.0, kind(r8)), ieee_signaling_nan)
   print *, " b = ", b

   stop

end program p
&lt;/PRE&gt;

&lt;PRE class="brush:plain;"&gt;  a =  NaN
forrtl: error (65): floating invalid
Image              PC                Routine            Line        Source

p64.exe            000000013FA21932  MAIN__                     17  p.f90
p64.exe            000000013FAC6B7E  Unknown               Unknown  Unknown
p64.exe            000000013FAC764C  Unknown               Unknown  Unknown
p64.exe            000000013FAC778E  Unknown               Unknown  Unknown
kernel32.dll       0000000076BA59BD  Unknown               Unknown  Unknown
ntdll.dll          00000000772BA551  Unknown               Unknown  Unknown
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2015 20:31:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039776#M112760</guid>
      <dc:creator>FortranFan</dc:creator>
      <dc:date>2015-06-15T20:31:56Z</dc:date>
    </item>
    <item>
      <title>FortranFan , although your</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039777#M112761</link>
      <description>&lt;P&gt;FortranFan , although your excellent code has the advantage of standard conformance it is not code that could be used to provide default initialization. For that we need a constant parameter.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 06:37:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039777#M112761</guid>
      <dc:creator>Andrew_Smith</dc:creator>
      <dc:date>2015-06-16T06:37:35Z</dc:date>
    </item>
    <item>
      <title>Copy operations may be</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039778#M112762</link>
      <description>&lt;P&gt;Copy operations may be difficult to trap. This is because, the copy could use general purpose registers, or it could use integer SIMD instructions.&lt;/P&gt;

&lt;P&gt;If you want to assure a trap in debug mode, force an expression on the variable.&lt;/P&gt;

&lt;P&gt;#define test_snan(x) (x + 0.0_D)&lt;/P&gt;

&lt;P&gt;If the compiler optimizes that out, then make the test a call to an external function that does not get inlined, and is not optimized.&lt;/P&gt;

&lt;P&gt;I agree with your desire to have /Qinit:snan, at least in Debug build, use instructions that will cause a trap on simple assignments. This could be done with the add literal 0.0. as part of the assignment.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 18:32:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Use-of-signaling-nan/m-p/1039778#M112762</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2015-06-16T18:32:00Z</dc:date>
    </item>
  </channel>
</rss>

