<?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 floating-point exception in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807229#M40804</link>
    <description>&lt;P&gt;Created a new project on the basis of an example on usage of procedure CLEARSTATUSFPQQ from Intel Fortran Compiler User and Reference Guides:&lt;/P&gt;&lt;P&gt;! Program to demonstrate CLEARSTATUSFPQQ.&lt;/P&gt;&lt;P&gt;! This program uses polling to detect that a&lt;/P&gt;&lt;P&gt;! floating-point exception has occurred.&lt;/P&gt;&lt;P&gt;! So, build this console application with the default&lt;/P&gt;&lt;P&gt;! floating-point exception behavior, fpe3.&lt;/P&gt;&lt;P&gt;! You need to specify compiler option /debug or /Od (Windows)&lt;/P&gt;&lt;P&gt;! or -O0 (Linux) to get the correct results&lt;/P&gt;&lt;P&gt;! PROGRAM CLEARFP&lt;/P&gt;&lt;P&gt;USE IFPORT&lt;/P&gt;&lt;P&gt;REAL*4 A,B,C&lt;/P&gt;&lt;P&gt;INTEGER*2 STS&lt;/P&gt;&lt;P&gt;A = 2.0E0&lt;/P&gt;&lt;P&gt;B = 0.0E0&lt;/P&gt;&lt;P&gt;! Poll and display initial floating point status&lt;/P&gt;&lt;P&gt;CALL GETSTATUSFPQQ(STS)&lt;/P&gt;&lt;P&gt;WRITE(*,'(1X,A,Z4.4)') 'Initial fp status = ',STS&lt;/P&gt;&lt;P&gt;! Cause a divide-by-zero exception&lt;/P&gt;&lt;P&gt;! Poll and display the new floating point status&lt;/P&gt;&lt;P&gt;C = A/B&lt;/P&gt;&lt;P&gt;CALL GETSTATUSFPQQ(STS)&lt;/P&gt;&lt;P&gt;WRITE(*,'(1X,A,Z4.4)') 'After div-by-zero fp status = ',STS&lt;/P&gt;&lt;P&gt;! If a divide by zero error occurred, clear the floating point&lt;/P&gt;&lt;P&gt;! status register so future exceptions can be detected.&lt;/P&gt;&lt;P&gt;IF ((STS .AND. FPSW$ZERODIVIDE) &amp;gt; 0) THEN&lt;/P&gt;&lt;P&gt;CALL CLEARSTATUSFPQQ()&lt;/P&gt;&lt;P&gt;CALL GETSTATUSFPQQ(STS)&lt;/P&gt;&lt;P&gt;WRITE(*,'(1X,A,Z4.4)') 'After CLEARSTATUSFPQQ fp status = ',STS&lt;/P&gt;&lt;P&gt;ENDIF&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;Installed compiler directive: /debug and /fpe:3&lt;/P&gt;&lt;P&gt;But as a result received on the screen following output:&lt;/P&gt;&lt;P&gt;Initial fp status = 0000&lt;/P&gt;&lt;P&gt;After div-by-zero fp status = 000&lt;/P&gt;&lt;P&gt;That is the program does not find out divide by zero?&lt;/P&gt;&lt;P&gt;In the Compaq Visual Fortran 6 program finds divide by zero!&lt;/P&gt;</description>
    <pubDate>Sun, 06 Feb 2011 12:35:19 GMT</pubDate>
    <dc:creator>beam2000</dc:creator>
    <dc:date>2011-02-06T12:35:19Z</dc:date>
    <item>
      <title>floating-point exception</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807229#M40804</link>
      <description>&lt;P&gt;Created a new project on the basis of an example on usage of procedure CLEARSTATUSFPQQ from Intel Fortran Compiler User and Reference Guides:&lt;/P&gt;&lt;P&gt;! Program to demonstrate CLEARSTATUSFPQQ.&lt;/P&gt;&lt;P&gt;! This program uses polling to detect that a&lt;/P&gt;&lt;P&gt;! floating-point exception has occurred.&lt;/P&gt;&lt;P&gt;! So, build this console application with the default&lt;/P&gt;&lt;P&gt;! floating-point exception behavior, fpe3.&lt;/P&gt;&lt;P&gt;! You need to specify compiler option /debug or /Od (Windows)&lt;/P&gt;&lt;P&gt;! or -O0 (Linux) to get the correct results&lt;/P&gt;&lt;P&gt;! PROGRAM CLEARFP&lt;/P&gt;&lt;P&gt;USE IFPORT&lt;/P&gt;&lt;P&gt;REAL*4 A,B,C&lt;/P&gt;&lt;P&gt;INTEGER*2 STS&lt;/P&gt;&lt;P&gt;A = 2.0E0&lt;/P&gt;&lt;P&gt;B = 0.0E0&lt;/P&gt;&lt;P&gt;! Poll and display initial floating point status&lt;/P&gt;&lt;P&gt;CALL GETSTATUSFPQQ(STS)&lt;/P&gt;&lt;P&gt;WRITE(*,'(1X,A,Z4.4)') 'Initial fp status = ',STS&lt;/P&gt;&lt;P&gt;! Cause a divide-by-zero exception&lt;/P&gt;&lt;P&gt;! Poll and display the new floating point status&lt;/P&gt;&lt;P&gt;C = A/B&lt;/P&gt;&lt;P&gt;CALL GETSTATUSFPQQ(STS)&lt;/P&gt;&lt;P&gt;WRITE(*,'(1X,A,Z4.4)') 'After div-by-zero fp status = ',STS&lt;/P&gt;&lt;P&gt;! If a divide by zero error occurred, clear the floating point&lt;/P&gt;&lt;P&gt;! status register so future exceptions can be detected.&lt;/P&gt;&lt;P&gt;IF ((STS .AND. FPSW$ZERODIVIDE) &amp;gt; 0) THEN&lt;/P&gt;&lt;P&gt;CALL CLEARSTATUSFPQQ()&lt;/P&gt;&lt;P&gt;CALL GETSTATUSFPQQ(STS)&lt;/P&gt;&lt;P&gt;WRITE(*,'(1X,A,Z4.4)') 'After CLEARSTATUSFPQQ fp status = ',STS&lt;/P&gt;&lt;P&gt;ENDIF&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;Installed compiler directive: /debug and /fpe:3&lt;/P&gt;&lt;P&gt;But as a result received on the screen following output:&lt;/P&gt;&lt;P&gt;Initial fp status = 0000&lt;/P&gt;&lt;P&gt;After div-by-zero fp status = 000&lt;/P&gt;&lt;P&gt;That is the program does not find out divide by zero?&lt;/P&gt;&lt;P&gt;In the Compaq Visual Fortran 6 program finds divide by zero!&lt;/P&gt;</description>
      <pubDate>Sun, 06 Feb 2011 12:35:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807229#M40804</guid>
      <dc:creator>beam2000</dc:creator>
      <dc:date>2011-02-06T12:35:19Z</dc:date>
    </item>
    <item>
      <title>floating-point exception</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807230#M40805</link>
      <description>Hello beam2000,&lt;BR /&gt;&lt;BR /&gt;I have tried your program and I have the same behaviour, but only when compiled under IA32. If I compile in x64, the "fp status" prints 4 (divided by zero). There is something wrong here, but I don't know what it could be... I'm using Composer XE update 2. What compiler are you using? &lt;BR /&gt;&lt;BR /&gt;Pedro</description>
      <pubDate>Sun, 06 Feb 2011 14:56:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807230#M40805</guid>
      <dc:creator>psantos</dc:creator>
      <dc:date>2011-02-06T14:56:20Z</dc:date>
    </item>
    <item>
      <title>floating-point exception</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807231#M40806</link>
      <description>Hello Pedro!&lt;BR /&gt;&lt;BR /&gt;I have Intel Visual Fortran 11.1.060 [IA-32].&lt;BR /&gt;&lt;BR /&gt;Sergey</description>
      <pubDate>Mon, 07 Feb 2011 07:19:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807231#M40806</guid>
      <dc:creator>beam2000</dc:creator>
      <dc:date>2011-02-07T07:19:41Z</dc:date>
    </item>
    <item>
      <title>floating-point exception</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807232#M40807</link>
      <description>There are a couple of different things that may cause this difference. You might want to try adding the /arch:ia32 option (in Visual Studio that is project property Fortran &amp;gt; Code Generation &amp;gt; Enable Enhanced Instruction Set &amp;gt; No enhanced instruction sets. The SSE instructions used by Intel Fortran behave differently regarding the FP flags compared to the "X87" instructions in earlier versions.&lt;BR /&gt;&lt;BR /&gt;A second possibility is a bug in the way the run-time library handles FP exceptions - use Intel Visual Fortran Composer XE 2011 to resolve that.&lt;BR /&gt;&lt;BR /&gt;However, I'd suggest instead that you use the Fortran 2003 "IEEE Floating point" intrinsic modules to accomplish what you want. Here's an example:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]    program zerodivide&lt;BR /&gt;    &lt;BR /&gt;    use, intrinsic :: IEEE_EXCEPTIONS&lt;BR /&gt;    use, intrinsic :: IEEE_ARITHMETIC&lt;BR /&gt;&lt;BR /&gt;    implicit none&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    real :: a, b, c&lt;BR /&gt;    logical :: zerodivide_flag&lt;BR /&gt;        &lt;BR /&gt;    ! Disable halting on a zerodivide&lt;BR /&gt;    &lt;BR /&gt;    call IEEE_SET_HALTING_MODE (IEEE_DIVIDE_BY_ZERO, .FALSE.)&lt;BR /&gt;    &lt;BR /&gt;    a = 2.0&lt;BR /&gt;    &lt;BR /&gt;    ! In a loop, read B from the console and divide it into A&lt;BR /&gt;     do&lt;BR /&gt;      read (*,*,END=99) b&lt;BR /&gt;      ! Clear the exception flags&lt;BR /&gt;      call IEEE_SET_FLAG (IEEE_USUAL, .FALSE.)&lt;BR /&gt;      c = a / b&lt;BR /&gt;      ! Did we get an exception?&lt;BR /&gt;      call IEEE_GET_FLAG (IEEE_DIVIDE_BY_ZERO, zerodivide_flag)&lt;BR /&gt;      if (zerodivide_flag) then&lt;BR /&gt;        write (*,*) "Divide by zero!"&lt;BR /&gt;      else&lt;BR /&gt;        write (*,*) "Result is ", c&lt;BR /&gt;      end if&lt;BR /&gt;    end do&lt;BR /&gt;    &lt;BR /&gt;99  continue&lt;BR /&gt;    &lt;BR /&gt;    end program zerodivide&lt;BR /&gt;[/fortran]&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Feb 2011 15:42:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807232#M40807</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-02-07T15:42:24Z</dc:date>
    </item>
    <item>
      <title>floating-point exception</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807233#M40808</link>
      <description>&lt;P&gt;Thank you very much, Steve!!!&lt;/P&gt;&lt;P&gt;Sergey&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2011 09:10:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807233#M40808</guid>
      <dc:creator>beam2000</dc:creator>
      <dc:date>2011-02-08T09:10:41Z</dc:date>
    </item>
    <item>
      <title>floating-point exception</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807234#M40809</link>
      <description>Hi Steve!&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;If to compile the program presented by you in configuration Win32 Release with Optimization directive: Speed the acceptable result turns out. If thus to change 29 line on&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;write (*, *) "Result is ok"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;the result will be unacceptable. Why?&lt;BR /&gt;&lt;BR /&gt;Sergey&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2011 17:59:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807234#M40809</guid>
      <dc:creator>beam2000</dc:creator>
      <dc:date>2011-02-09T17:59:34Z</dc:date>
    </item>
    <item>
      <title>floating-point exception</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807235#M40810</link>
      <description>Sergey, if I understand correctly, you're saying that if you change the WRITE to one that does not use the result of the division then you don't get an error. This is because the compiler sees that the division can be removed and therefore no zerodivide occurs.</description>
      <pubDate>Wed, 09 Feb 2011 18:21:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807235#M40810</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-02-09T18:21:16Z</dc:date>
    </item>
    <item>
      <title>floating-point exception</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807236#M40811</link>
      <description>Steve, but why in configuration Win32 Releasewith Optimization directive: Disable zerodivide occurs?</description>
      <pubDate>Wed, 09 Feb 2011 18:49:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807236#M40811</guid>
      <dc:creator>beam2000</dc:creator>
      <dc:date>2011-02-09T18:49:55Z</dc:date>
    </item>
    <item>
      <title>floating-point exception</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807237#M40812</link>
      <description>Because you disabled the optimizer so it didn't remove the unused calculation.</description>
      <pubDate>Wed, 09 Feb 2011 19:05:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/floating-point-exception/m-p/807237#M40812</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-02-09T19:05:28Z</dc:date>
    </item>
  </channel>
</rss>

