<?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 Cubing positive real(8) leads to NaN in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824331#M49340</link>
    <description>Yes, declaring a real function result as implicit integer appears to be an outright bug in the example code, such that no meaningful result may be expected. On the other hand, there is no NaN representation in integer types. Nor would the common expectation from x87 code that a real function result of any type could be received as any other real type work, as in that case any real function return type would be ignored when receiving an integer.</description>
    <pubDate>Tue, 24 Jan 2012 22:28:48 GMT</pubDate>
    <dc:creator>TimP</dc:creator>
    <dc:date>2012-01-24T22:28:48Z</dc:date>
    <item>
      <title>Cubing positive real(8) leads to NaN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824322#M49331</link>
      <description>Imagine the following FORTRAN code Parallel Studio XE 2011 (with default real(8) but most other relevant compiler options unchanged from their default):&lt;BR /&gt;&lt;BR /&gt;__________________________________&lt;BR /&gt;&lt;BR /&gt;program example1&lt;BR /&gt;&lt;BR /&gt;real x,t,a,b,c&lt;BR /&gt;&lt;BR /&gt;a=1.; b=1.; c=1.&lt;BR /&gt;t=0.00635&lt;BR /&gt;x=kyle(t,a,b,c)&lt;BR /&gt;&lt;BR /&gt;end&lt;BR /&gt;&lt;BR /&gt;function kyle(t,a,b,c)&lt;BR /&gt;&lt;BR /&gt;real kyle,t,a,b,c&lt;BR /&gt;&lt;BR /&gt;kyle=t**3.0&lt;BR /&gt;&lt;BR /&gt;end&lt;BR /&gt;&lt;BR /&gt;___________________________________&lt;BR /&gt;&lt;BR /&gt;For some combinations of parameters a,b,c the function behaves correctly. For others, the function evaluates t to be NaN. Is there any clear explanation of why this might be?&lt;BR /&gt;&lt;BR /&gt;Obviously, there is more going on in my code but I've extracted what I think to be relative charateristics. If there is no answer to my question above, I will add more details.&lt;BR /&gt;&lt;BR /&gt;Thank you.</description>
      <pubDate>Tue, 24 Jan 2012 18:10:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824322#M49331</guid>
      <dc:creator>kschmitt_dom</dc:creator>
      <dc:date>2012-01-24T18:10:09Z</dc:date>
    </item>
    <item>
      <title>Cubing positive real(8) leads to NaN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824323#M49332</link>
      <description>I think you are going to have to determine which actual values create the problem and show us a program that demonstrates it.</description>
      <pubDate>Tue, 24 Jan 2012 18:18:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824323#M49332</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2012-01-24T18:18:51Z</dc:date>
    </item>
    <item>
      <title>Cubing positive real(8) leads to NaN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824324#M49333</link>
      <description>Note that you haven't declared the type of the function in the main program. Implicit typing rules would result in a mismatch, which could result in lots of interesting things happening. Consider using IMPLICIT NONE in all program units and putting the function in a module.</description>
      <pubDate>Tue, 24 Jan 2012 19:04:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824324#M49333</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2012-01-24T19:04:39Z</dc:date>
    </item>
    <item>
      <title>Cubing positive real(8) leads to NaN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824325#M49334</link>
      <description>zero or negative t is likely to produce NaN when raised to 3.0 power, where 3 (integer) power is OK.</description>
      <pubDate>Tue, 24 Jan 2012 19:04:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824325#M49334</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2012-01-24T19:04:54Z</dc:date>
    </item>
    <item>
      <title>Cubing positive real(8) leads to NaN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824326#M49335</link>
      <description>The program is far more complex and (as is so often the case I am sure) proprietary. I would make an attempt to recreate the error in a streamlined program, but it appears that it was in fact due to implicit typing as suggesting by IanH. &lt;BR /&gt;&lt;BR /&gt;Other details: My variable "t" in the actual program is an *intermediate* variable used inside the function "kyle", so it seems weird that there would be a implicit typing mismatch just because the function return "kyle" was not explicitly typed in the main program. Furthermore, if I debug stop immediately before returning from "kyle", my debugger shows "t" to be 3.65D-02 but shows "kyle" to be NaN. &lt;BR /&gt;&lt;BR /&gt;Nonetheless, expliciting assigning "kyle" to real in the main program appears to have fixed my problem.&lt;BR /&gt;&lt;BR /&gt;Thank you!</description>
      <pubDate>Tue, 24 Jan 2012 19:36:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824326#M49335</guid>
      <dc:creator>kschmitt_dom</dc:creator>
      <dc:date>2012-01-24T19:36:15Z</dc:date>
    </item>
    <item>
      <title>Cubing positive real(8) leads to NaN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824327#M49336</link>
      <description>If you are building in Visual Studio, make sure that Warnings &amp;gt; Generated Interface Checking is enabled. This is on by default for new projects and can catch errors of this nature. From the command line, specify /warn:interface</description>
      <pubDate>Tue, 24 Jan 2012 20:10:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824327#M49336</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2012-01-24T20:10:18Z</dc:date>
    </item>
    <item>
      <title>Cubing positive real(8) leads to NaN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824328#M49337</link>
      <description>&lt;I&gt;&amp;gt; so it seems weird that there would be a implicit typing mismatch just 
because the function return "kyle" was not explicitly typed in the main 
program&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;Unlike in, say, C, in Fortran all type declarations have program-unit-scope, not file-scope. &lt;BR /&gt;&lt;BR /&gt;Some compilers, egged on by a proper choice of diagnostic options, may warn you of the type mismatch at compile time or catch the mismatch at run-time. However, the source code needs to be rectified.&lt;BR /&gt;&lt;BR /&gt;The short example that you provided will not work to exhibit the problem since, in the main program, the result of the function call is not used and the compiler can optimize out the function call entirely.&lt;BR /&gt;&lt;BR /&gt;On X86 CPUs, the convention is that integer functions return the result in register EAX, whereas real/double-precision functions return the result in ST0. With the mismatch that you had, the function puts the result into ST0, but the caller takes the content of EAX as the result.</description>
      <pubDate>Tue, 24 Jan 2012 20:11:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824328#M49337</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2012-01-24T20:11:24Z</dc:date>
    </item>
    <item>
      <title>Cubing positive real(8) leads to NaN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824329#M49338</link>
      <description>I took the original description as implying that -real-size:64 (or equivalent) is in effect for the entire build. Needless to say, making the type explicit in the source code, and allowing compiler to check interfaces, may avoid mistakes.</description>
      <pubDate>Tue, 24 Jan 2012 20:29:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824329#M49338</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2012-01-24T20:29:56Z</dc:date>
    </item>
    <item>
      <title>Cubing positive real(8) leads to NaN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824330#M49339</link>
      <description>I don't see why choosing the &lt;B&gt;-real-size:64&lt;/B&gt; option would have any effect on the compiled code from a reference to a variable or function that is implicitly typed to be INTEGER.</description>
      <pubDate>Tue, 24 Jan 2012 20:35:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824330#M49339</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2012-01-24T20:35:25Z</dc:date>
    </item>
    <item>
      <title>Cubing positive real(8) leads to NaN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824331#M49340</link>
      <description>Yes, declaring a real function result as implicit integer appears to be an outright bug in the example code, such that no meaningful result may be expected. On the other hand, there is no NaN representation in integer types. Nor would the common expectation from x87 code that a real function result of any type could be received as any other real type work, as in that case any real function return type would be ignored when receiving an integer.</description>
      <pubDate>Tue, 24 Jan 2012 22:28:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cubing-positive-real-8-leads-to-NaN/m-p/824331#M49340</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2012-01-24T22:28:48Z</dc:date>
    </item>
  </channel>
</rss>

