<?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 If you have numerical issues, in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963789#M95246</link>
    <description>&lt;P&gt;If you have numerical issues, including those affected by adding prints, you might consider including /assume:protect_parens /Qprec-div /Qprec-sqrt or even /fp:source if this doesn't slow it down. &amp;nbsp;As far as I'm concerned, protect_parens should be used always. &amp;nbsp;The option /Qftz is a default on account of the behavior of CPUs prior to corei7-3; there should be no need to use it for performance on the last 2 CPU generations.&lt;/P&gt;

&lt;P&gt;Such sensitivities may also indicate a need for algorithmic investigation, as you suggested, or promotion of critical single precision calculations to double.&lt;/P&gt;

&lt;P&gt;If you have source code bugs, sometimes they will be triggered in the absence of prints by optimizations such as /Qip. &amp;nbsp;I'm not advocating removal of that optimization except as a step toward diagnosing a possible bug.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Apr 2014 16:14:17 GMT</pubDate>
    <dc:creator>TimP</dc:creator>
    <dc:date>2014-04-01T16:14:17Z</dc:date>
    <item>
      <title>OpenMP + Optimization (/O2 or /O3) causes floating overflow</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963766#M95223</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I have a strange (to me) problem.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;In a big project, with OpenMP enabled by default.&lt;BR /&gt;
	In this project,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I have 2 modules: A and B, where m&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;odule A uses module B.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Module B do not have any OpenMP directive, nor Auto-parallelism is enabled.&lt;/SPAN&gt;&lt;BR /&gt;
	Inside Module A, t&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;he subroutines that calls Module B also do not have any OpenMP directive, nor do have any of the calling subroutines.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;When I compile the code, and disable OpenMP, OR disable Optimizations, OR disable both, only for the ModuleB, everything goes fine.&lt;BR /&gt;
	If I compile the ModuleB with both Optimization (/O2 or /O3) and OpenMP, the run craches after sometime with a floatpoint overflow.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Could you guide me to what kind of tests I should do in order to find the problem?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I'm using the latest Intel fortran.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Best regards,&lt;BR /&gt;
	Eduardo&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 14:04:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963766#M95223</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-27T14:04:25Z</dc:date>
    </item>
    <item>
      <title>Does the code in ModuleB</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963767#M95224</link>
      <description>&lt;P&gt;Does the code in ModuleB perform a convergence? Optimization may cause different instruction sequences that affect rounding.&lt;/P&gt;

&lt;P&gt;A second difference is compiling with OpenMP attributes the subroutines and functions as "recursive". This may move some variables to stack, as opposed to some of those variables implicitly being located as SAVE. If you omit variable initialization, or rely on implicit SAVE'dness, then you will have potential problems.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 15:06:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963767#M95224</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-03-27T15:06:23Z</dc:date>
    </item>
    <item>
      <title>Hello Jim,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963768#M95225</link>
      <description>&lt;P&gt;Hello Jim,&lt;/P&gt;

&lt;P&gt;Thanks for the fast reply.&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Nope. The module B is not performing convergence. It just uses values form other parts of the code to populate a 3D matrix.&lt;/P&gt;

&lt;P&gt;I think there is no recursive subroutines in the code, and the recursivity is disable in the properties.&lt;BR /&gt;
	And if there is some variables implicitly being SAVE, this would be a bug, in this project. We avoid the use of SAVE. I'll check this anyway.&lt;/P&gt;

&lt;P&gt;I think I'll not be able to scape the old "print" debug method... lol&lt;/P&gt;

&lt;P&gt;Eduardo&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 15:32:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963768#M95225</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-27T15:32:01Z</dc:date>
    </item>
    <item>
      <title>Hi Again,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963769#M95226</link>
      <description>&lt;P&gt;Hi Again,&lt;/P&gt;

&lt;P&gt;I made a series of tests and I think that my problem must be related with a compiler bug when using OpenMP and optimizing the code.&lt;/P&gt;

&lt;P&gt;The folowing code causes an error:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;
    subroutine Compute_Multiparameters

        !Local-----------------------------------------------------------------
        integer                                 :: i, j, k

        !Begin-----------------------------------------------------------------

if3D:   if (Me%Is3D) then

             if((Me%ExternalVar%PropertyID == MacroAlgae_) .OR. (Me%ExternalVar%PropertyID == SeagrassesLeaves_) ) then  

                do k = Me%WorkSize%KLB, Me%WorkSize%KUB
                do j = Me%WorkSize%JLB, Me%WorkSize%JUB
                do i = Me%WorkSize%ILB, Me%WorkSize%IUB

                    if (Me%ExternalVar%WaterPoints3D(i, j, k) == WaterPoint) then 

                        Me%ShortWave%ExtinctionCoefField3D(i,j,k) =                           &amp;amp;
                                            Me%ShortWave%ExtinctionCoefField3D(i,j,k)       + &amp;amp;
                                            Me%ExternalVar%ExtinctionParameter              * &amp;amp;
                                           (Me%ExternalVar%Concentration3D(i, j, k)         * &amp;amp;
                                            Me%ExternalVar%ProducerOccupation(i, j, k)    * Me%UnitsCoef)
                    end if

                enddo
                enddo
                enddo

            else 
                
                do k = Me%WorkSize%KLB, Me%WorkSize%KUB
                do j = Me%WorkSize%JLB, Me%WorkSize%JUB
                do i = Me%WorkSize%ILB, Me%WorkSize%IUB

                    if (Me%ExternalVar%WaterPoints3D(i, j, k) == WaterPoint) then 

                        Me%ShortWave%ExtinctionCoefField3D(i,j,k) =                     &amp;amp;
                                            Me%ShortWave%ExtinctionCoefField3D(i,j,k) + &amp;amp;
                                            Me%ExternalVar%ExtinctionParameter        * &amp;amp;
                                           (Me%ExternalVar%Concentration3D(i, j, k)   * Me%UnitsCoef)
                                      
                    end if

                enddo
                enddo
                enddo

            end if 

        else if3D

            do i = Me%Size1D%ILB, Me%Size1D%IUB

                if (Me%ExternalVar%RiverPoints1D(i) == WaterPoint) then 
                
                    Me%ShortWave%ExtinctionCoefField1D(i) =                         &amp;amp;
                                        Me%ShortWave%ExtinctionCoefField1D(i)     + &amp;amp;
                                        Me%ExternalVar%ExtinctionParameter        * &amp;amp;
                                        (Me%ExternalVar%Concentration1D(i)        * Me%UnitsCoef)
                end if

            enddo

        endif if3D

    end subroutine Compute_Multiparameters&lt;/PRE&gt;

&lt;P&gt;While the next code works:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;
    subroutine Compute_Multiparameters

        !Local-----------------------------------------------------------------
        integer                                 :: i, j, k
        real                                    :: a

        !Begin-----------------------------------------------------------------

if3D:   if (Me%Is3D) then

             if((Me%ExternalVar%PropertyID == MacroAlgae_) .OR. (Me%ExternalVar%PropertyID == SeagrassesLeaves_) ) then  

                do k = Me%WorkSize%KLB, Me%WorkSize%KUB
                do j = Me%WorkSize%JLB, Me%WorkSize%JUB
                do i = Me%WorkSize%ILB, Me%WorkSize%IUB

                    if (Me%ExternalVar%WaterPoints3D(i, j, k) == WaterPoint) then 

                        Me%ShortWave%ExtinctionCoefField3D(i,j,k) =                           &amp;amp;
                                            Me%ShortWave%ExtinctionCoefField3D(i,j,k)       + &amp;amp;
                                            Me%ExternalVar%ExtinctionParameter              * &amp;amp;
                                           (Me%ExternalVar%Concentration3D(i, j, k)         * &amp;amp;
                                            Me%ExternalVar%ProducerOccupation(i, j, k)    * Me%UnitsCoef)
                    end if

                enddo
                enddo
                enddo

            else 
                
                do k = Me%WorkSize%KLB, Me%WorkSize%KUB
                do j = Me%WorkSize%JLB, Me%WorkSize%JUB
                do i = Me%WorkSize%ILB, Me%WorkSize%IUB

                    if (Me%ExternalVar%WaterPoints3D(i, j, k) == WaterPoint) then 

                        Me%ShortWave%ExtinctionCoefField3D(i,j,k) =                     &amp;amp;
                                            Me%ShortWave%ExtinctionCoefField3D(i,j,k) + &amp;amp;
                                            Me%ExternalVar%ExtinctionParameter        * &amp;amp;
                                           (Me%ExternalVar%Concentration3D(i, j, k)   * Me%UnitsCoef)
                                      
                        a = Me%ShortWave%ExtinctionCoefField3D(i,j,k)     
                        if ((a &amp;gt; 1.0) .or. (a &amp;lt; 0.0)) then
                            print *, 'Error'
                            print *, Me%ShortWave%ExtinctionCoefField3D(i,j,k)
                            print *, Me%ExternalVar%ExtinctionParameter 
                            print *, Me%ExternalVar%Concentration3D(i, j, k)
                            print *, Me%UnitsCoef
                            stop
                        endif
                    end if

                enddo
                enddo
                enddo

            end if 

        else if3D

            do i = Me%Size1D%ILB, Me%Size1D%IUB

                if (Me%ExternalVar%RiverPoints1D(i) == WaterPoint) then 
                
                    Me%ShortWave%ExtinctionCoefField1D(i) =                         &amp;amp;
                                        Me%ShortWave%ExtinctionCoefField1D(i)     + &amp;amp;
                                        Me%ExternalVar%ExtinctionParameter        * &amp;amp;
                                        (Me%ExternalVar%Concentration1D(i)        * Me%UnitsCoef)
                end if

            enddo

        endif if3D

    end subroutine Compute_Multiparameters&lt;/PRE&gt;

&lt;P&gt;This shows to me that the optimizer is doing something wrong. When I include the variable a and use it inside this sibrotuine, the optimizer is unable to do what it was doing and the code works...&lt;/P&gt;

&lt;P&gt;This isn't the first time that adding a instruction solves an error...&lt;BR /&gt;
	I had othe case like this, sometime ago, where putting a "write" instruction would make the code work...&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Eduardo&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 17:57:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963769#M95226</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-27T17:57:43Z</dc:date>
    </item>
    <item>
      <title>Eduardo,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963770#M95227</link>
      <description>&lt;P&gt;Eduardo,&lt;/P&gt;

&lt;P&gt;A funny thing happened on the way to the forum....&lt;/P&gt;

&lt;P&gt;Fortran does not have an attribute REENTRANT. Multiple threads concurrently calling the same routine is a reentrancy situation. Due to the requirement of having the routines (possibly)&amp;nbsp;being called reentrantly in OpenMP compiled programs .AND. the lack of REENTRANT attribute the attribute RECURSIVE is implicitly applied (whether you want it or not). RECURSIVE and REENTRANT routines have a requirement that barring explicit attributes, the declared local variables are to be located on the stack. When compiled without OpenMP and without attribute RECURSIVE... the compiler is free to make the variables stack located .OR. in a private (static) global location. Usually (in past experience)scalars end up on stack but arrays (REAL :: VEC(3), MAT(3,3)) were made implicitly SAVE.&lt;/P&gt;

&lt;P&gt;Due to implicitly SAVE on non-OpenMP/non-RECURSIVE routines, and when alternate paths are traversed in the routine from call to call (IF... THEN... ELSE), it is quite possible that a first time path happens to initialize a variable that is bypassed for initialization on a subsequent pass.&lt;/P&gt;

&lt;P&gt;Compiling as OpenMP would relocate these arrays on the stack, and then depending on code between calls, the code may trash or not trash the memory locations to be used on subsequent call.&lt;/P&gt;

&lt;P&gt;The compiler has a runtime check option to test for uninitialized variable usage. Compile for OpenMP and enable this option to see what happens. (remove the option afterwards).&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 19:26:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963770#M95227</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-03-27T19:26:21Z</dc:date>
    </item>
    <item>
      <title>Hello Jim,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963771#M95228</link>
      <description>&lt;P&gt;Hello Jim,&lt;/P&gt;

&lt;P&gt;I aways wanted to know what happens when a routine is called multiple times in parallel.&lt;BR /&gt;
	So, even if a routine is never called inside a OpenMP parallel region, when compiling with OpenMP enabled, the compiler will make all routines RECURSIVE?&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Regarding the implicity SAVE, this would impact only the arrays declared inside the routine, no?&lt;/P&gt;

&lt;P&gt;The code of the routine that seems to be causing the error is this:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;
    subroutine Compute_Multiparameters

        !Local-----------------------------------------------------------------
        integer                                 :: i, j, k

        !Begin-----------------------------------------------------------------

if3D:   if (Me%Is3D) then

           !never enters here

            else 
                
                do k = Me%WorkSize%KLB, Me%WorkSize%KUB
                do j = Me%WorkSize%JLB, Me%WorkSize%JUB
                do i = Me%WorkSize%ILB, Me%WorkSize%IUB

                    if (Me%ExternalVar%WaterPoints3D(i, j, k) == WaterPoint) then 

                        Me%ShortWave%ExtinctionCoefField3D(i,j,k) =                     &amp;amp;
                                            Me%ShortWave%ExtinctionCoefField3D(i,j,k) + &amp;amp;
                                            Me%ExternalVar%ExtinctionParameter        * &amp;amp;
                                           (Me%ExternalVar%Concentration3D(i, j, k)   * Me%UnitsCoef)
                                      
                    end if

                enddo
                enddo
                enddo

            end if 

        else if3D

           !never enters here

        endif if3D

    end subroutine Compute_Multiparameters&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Me&lt;/STRONG&gt; is a module variable (a Type).&lt;BR /&gt;
	&lt;STRONG&gt;WaterPoint3D&lt;/STRONG&gt; is an integer matrix (WaterPoint is a parameter wi 1).&lt;BR /&gt;
	&lt;STRONG&gt;ExtinctionCoefField3D&lt;/STRONG&gt; ia a real matrix.&lt;BR /&gt;
	&lt;STRONG&gt;ExtinctionParameter&lt;/STRONG&gt; is a real.&lt;BR /&gt;
	&lt;STRONG&gt;Concentration3D&lt;/STRONG&gt; is a real matrix.&lt;BR /&gt;
	&lt;STRONG&gt;UnitsCoef&lt;/STRONG&gt; is a real.&lt;/P&gt;

&lt;P&gt;When this subroutine is called, all the arrays and scalars have theirs values defined.&lt;BR /&gt;
	The &lt;SPAN style="font-weight: bold;"&gt;ExtinctionCoefField3D&lt;/SPAN&gt;&amp;nbsp;is first initialized with 0, and is actualized in other routines also, all of them similar to this one, than the P = P + K form.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;if I change the code to something like below, the error disappears.&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;
    subroutine Compute_Multiparameters

        !Local-----------------------------------------------------------------
        integer                                 :: i, j, k
        real                                    :: a

        !Begin-----------------------------------------------------------------

if3D:   if (Me%Is3D) then

           !never enters here

            else 
                
                do k = Me%WorkSize%KLB, Me%WorkSize%KUB
                do j = Me%WorkSize%JLB, Me%WorkSize%JUB
                do i = Me%WorkSize%ILB, Me%WorkSize%IUB

                    if (Me%ExternalVar%WaterPoints3D(i, j, k) == WaterPoint) then 

                        Me%ShortWave%ExtinctionCoefField3D(i,j,k) =                     &amp;amp;
                                            Me%ShortWave%ExtinctionCoefField3D(i,j,k) + &amp;amp;
                                            Me%ExternalVar%ExtinctionParameter        * &amp;amp;
                                           (Me%ExternalVar%Concentration3D(i, j, k)   * Me%UnitsCoef)

                        a = Me%ShortWave%ExternalVar%ExtinctionCoefField3D(i, j, k)
&amp;nbsp;                       print *, a
                    end if

                enddo
                enddo
                enddo

            end if 

        else if3D

           !never enters here

        endif if3D

    end subroutine Compute_Multiparameters&lt;/PRE&gt;

&lt;P&gt;When I try to debug the first version, it tells me that all the variables inside the subroutine are register variables, so, for sure that is something related with optimization.&lt;/P&gt;

&lt;P&gt;One of the first things I did was to run with all the runtime checks enabled. Nothing appears.&amp;nbsp;&lt;BR /&gt;
	&lt;BR /&gt;
	Any idea?&lt;BR /&gt;
	I confess I didn't understand very well the last part about the code between calls trashing the memory locations where the arrays are allocated...&lt;/P&gt;

&lt;P&gt;Thanks,&amp;nbsp;&lt;BR /&gt;
	Eduardo&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 20:18:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963771#M95228</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-27T20:18:51Z</dc:date>
    </item>
    <item>
      <title>/Qopenmp sets among other</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963772#M95229</link>
      <description>&lt;P&gt;/Qopenmp sets among other things /Qauto, which is required for reentrancy, and RECURSIVE would do the same. &amp;nbsp;This puts local arrays on the stack; ifort's default is to set local arrays as if they were SAVE. &amp;nbsp;The /Qsave option (which is not on by default) would have a similar effect on local scalars. &amp;nbsp;Any local variable which gets SAVE one way or another would constitute a race condition if multiple threads try to modify it.&lt;/P&gt;

&lt;P&gt;You would also have a race condition if multiple threads are accessing shared module variables, with one or more of them changing their contents. &amp;nbsp;RECURSIVE declaration or compile options won't change that. &amp;nbsp;With a shared array under data parallelism, you want to have distinct sections of the array updated by the various threads.&lt;/P&gt;

&lt;P&gt;The Advisor application is meant to assist in parallelizing a working serial code, and Inspector in finding data races in parallel code. &amp;nbsp;Otherwise, it's pretty much accidental if serial run-time checks show up any parallelization problems.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2014 00:51:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963772#M95229</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2014-03-28T00:51:17Z</dc:date>
    </item>
    <item>
      <title>Eduardo,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963773#M95230</link>
      <description>&lt;P&gt;Eduardo,&lt;/P&gt;

&lt;P&gt;Is your program structure, effectively:&lt;/P&gt;

&lt;P&gt;!$omp parallel do&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; do i = 1,n&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call &lt;CODE class="fortran plain"&gt;Compute_Multiparameters&lt;/CODE&gt;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; end do&lt;BR /&gt;
	!$omp end parallel do&lt;/P&gt;

&lt;P&gt;or:&lt;/P&gt;

&lt;P&gt;!$omp parallel do&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do k = Me%WorkSize%KLB, Me%WorkSize%KUB&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j = Me%WorkSize%JLB, Me%WorkSize%JUB&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = Me%WorkSize%ILB, Me%WorkSize%IUB&lt;BR /&gt;
	&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Me%ExternalVar%WaterPoints3D(i, j, k) == WaterPoint) then&lt;BR /&gt;
	&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me%ShortWave%ExtinctionCoefField3D(i,j,k) =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me%ShortWave%ExtinctionCoefField3D(i,j,k) + &amp;amp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me%ExternalVar%ExtinctionParameter&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * &amp;amp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Me%ExternalVar%Concentration3D(i, j, k)&amp;nbsp;&amp;nbsp; * Me%UnitsCoef)&lt;BR /&gt;
	&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a = Me%ShortWave%ExternalVar%ExtinctionCoefField3D(i, j, k)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print *, a&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end if&lt;BR /&gt;
	&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; enddo&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; enddo&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; enddo&lt;BR /&gt;
	!$omp end parallel do&lt;/P&gt;

&lt;P&gt;If it is the former, then you can have multiple threads calculating the same values:&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; Me%ShortWave%ExtinctionCoefField3D(i,j,k) = Me%ShortWave%ExtinctionCoefField3D(i,j,k) + ...&lt;BR /&gt;
	This&amp;nbsp;will cause problems if multiple threads are updating the same memory values.&lt;/P&gt;

&lt;P&gt;If it is the latter, you might have more success by explicitly declaring shared and private variables&lt;/P&gt;

&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2014 01:08:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963773#M95230</guid>
      <dc:creator>John_Campbell</dc:creator>
      <dc:date>2014-03-28T01:08:12Z</dc:date>
    </item>
    <item>
      <title>Hello Tim,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963774#M95231</link>
      <description>&lt;P&gt;Hello Tim,&lt;/P&gt;

&lt;P&gt;Thanks for the explanation. I have yet to learn how to use the inspector.&lt;BR /&gt;
	&lt;BR /&gt;
	In our code, we avoid the use of the SAVE attribute, don't initialize the local variables at the same time we declare it (avoid implicity SAVE) nor the /QSave options is used, so all local scalars will not have its value stored between calls and they mus be initialized before used.&lt;/P&gt;

&lt;P&gt;Anything different of this would be a "bug".&lt;/P&gt;

&lt;P&gt;The OpenMP directives are implemented only for looping and all local variables are declared as private, including the looping indexes. A great care was taken when implementing the OpenMP looping so to avoid Data race conditions, and usually only arrays on the form (i,j,k) are changed, making each thread working on a separated array section.&lt;/P&gt;

&lt;P&gt;But in the code I showed, there isn't any OpenMP looping, nor the subroutine is called from inside openmp looping or recursively.&lt;/P&gt;

&lt;P&gt;With only Optimization or only OpenMP enabled, the code works. When both are active, the run fails, but the "wrong" results are always the same, so, I don't think this is a data race conditions, as it would cause different results to appear. I tested the code at least a hundred times as of now.&lt;/P&gt;

&lt;P&gt;So, to me, is something related to the way the optimization is being done, when using OpenMP, because while this array, &lt;STRONG&gt;ExtictionCoefField3D&lt;/STRONG&gt;, in this part of the code, is not used under OpenMP conditions, it is used later in the code. Also, adding the "print" instruction, for sure changes something in the way this routine is optimized, because the problem goes away.&lt;/P&gt;

&lt;P&gt;This matrix is declared inside a type, and at the start of the execution is allocated.&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;
    type       T_Wave
        real, pointer, dimension(:)                 :: ExtinctionCoefField1D
        real, pointer, dimension(:,:,:)             :: ExtinctionCoefField3D
        integer                                     :: ExtinctionType       = FillValueInt
        real                                        :: ExtinctionCoef       = FillValueReal
        real                                        :: ExtCoefWater         = FillValueReal
        real                                        :: Percentage           = FillValueReal               
    end type T_Wave&lt;/PRE&gt;

&lt;P&gt;Also, in the module where it is computed, no OpenMP directives exist. Yet, removing the OpenMP from this module also solves the problem, so, Is something related not only with Optimization, but also with the way subroutines under OpenMP, as was said, that becomes implicitly recursive to allow the possibility of reentrance, are optimized.&lt;BR /&gt;
	&lt;BR /&gt;
	How is possible that a simple "print" put inside the looping can solve the problem?&lt;/P&gt;

&lt;P&gt;Maybe the problem is not here, but somewhere else?&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
	Eduardo&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2014 11:12:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963774#M95231</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-28T11:12:27Z</dc:date>
    </item>
    <item>
      <title>Eduardo,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963775#M95232</link>
      <description>&lt;P&gt;Eduardo,&lt;/P&gt;

&lt;P&gt;From the sketch code, in particular inserting a print removes bug, I would agree that this looks like a bug.&lt;/P&gt;

&lt;P&gt;Does compiling this routine (only) with /Qauto, without OpenMP, with optimizations run properly?&lt;BR /&gt;
	If, yes, then this could be a work around ** provided you have no intentions of making the k,j,i loop parallel in the future.&lt;/P&gt;

&lt;P&gt;Placing the print inside the loop will inhibit vectorization of that loop.&lt;/P&gt;

&lt;P&gt;Try removing the print and compiling that routine only&amp;nbsp;with /Qsimd-, with OpenMP, with Optimizations.&lt;BR /&gt;
	Note the "-" on /Qsimd-&lt;/P&gt;

&lt;P&gt;This suggestion is a probe to help determine the problem. If it works, it can also be used as a work around while Intel investigates this further (assuming you can send them a reproducer).&lt;/P&gt;

&lt;P&gt;Your kji loop can be (could be) vectorized. At some point you would like to have it vectorized. If this suggestion works, I also suggest you add a reoccurring reminder to your task list to remind you to revisit this on compiler updates.&lt;/P&gt;

&lt;P&gt;Another thought comes to mind. I cannot attest that this is true or not, Tim or Steve would be a better source.&lt;/P&gt;

&lt;P&gt;Should you want the kji loop parallelized, recall that the compiler optimizations can collapse loops. I do not know if COLLAPSE is auto-determinable by the compiler. I know COLLAPSE is an !$OMP directive, but this does not mean loop collapsing is not used in non-OpenMP sections of code. Compiling with OpenMP enabled is likely to change the rules used by the compiler to decide if/how to collapse nested loops. What I suggest you do is:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;
!$OMP COLLAPSE(2)
do k = Me%WorkSize%KLB, Me%WorkSize%KUB
do j = Me%WorkSize%JLB, Me%WorkSize%JUB
do i = Me%WorkSize%ILB, Me%WorkSize%IUB&lt;/PRE&gt;

&lt;P&gt;Tim or Steve, is there a !DEC$ NOCOLLAPSE and/or !DEC$ COLLAPSE(n) directive for non-OpenMP do loops?&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2014 13:00:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963775#M95232</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-03-28T13:00:00Z</dc:date>
    </item>
    <item>
      <title>You can turn on optimization</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963776#M95233</link>
      <description>&lt;P&gt;You can turn on optimization reports to see what the compiler did with loops. If you think there is a bug, you'd need to provide a complete test case to us (either here or through Intel Premier Support.)&lt;/P&gt;

&lt;P&gt;Offhand I don't think we have any control over loop collapsing other than the OMP directive.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2014 16:03:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963776#M95233</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-03-28T16:03:26Z</dc:date>
    </item>
    <item>
      <title>Hello Again, Jim</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963777#M95234</link>
      <description>&lt;P&gt;Hello Again, Jim&lt;/P&gt;

&lt;P&gt;"Does compiling this routine (only) with /Qauto, without OpenMP, with optimizations run properly?"&lt;/P&gt;

&lt;P&gt;Yes, it does. Compiling only the module with /O3+/Qauto without OpenMP works.&lt;/P&gt;

&lt;P&gt;"Try removing the print and compiling that routine only&amp;nbsp;with /Qsimd-, with OpenMP, with Optimizations."&lt;/P&gt;

&lt;P&gt;With this configuration (only for the module where the routine is), do not works.&lt;BR /&gt;
	But this is not surprise. The looping is not being vectorized anyway, probably due the fact of being in the form vec(i) = vec(i) + k. At least is what I understood from the message of why this looping is not being vectorized (when compiling without /Qsimd-)&lt;/P&gt;

&lt;P&gt;But searching a little deep, seems that the culprit is the &lt;STRONG&gt;Me%ExternalVar%Concentration3D &lt;/STRONG&gt;matrix.&lt;BR /&gt;
	No changes happen to it, during the execution of the suspect routine (the one that if I put a print, it solves the problem), The values in matrix, that is only used, not changed here, is always the same before and after the subroutine.&lt;/P&gt;

&lt;P&gt;BUT, when the error happens, it is this variable that changes it value, and this leads to utlimately the error on the suspected routine.&lt;/P&gt;

&lt;P&gt;Here is why I think it's probably a compiler problem. This matrix is used only for reading in this routine, the routine do not changes it's value, but even being so, without the "print", the optimization do something that causes a problem somewhere else in the code (I have to find where yet)&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2014 16:35:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963777#M95234</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-28T16:35:56Z</dc:date>
    </item>
    <item>
      <title>John,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963778#M95235</link>
      <description>&lt;P&gt;John,&lt;/P&gt;

&lt;P&gt;The program is not structured on either case.&lt;BR /&gt;
	The subroutine is not called inside aby OpenMP looping, and the loopings inside the subroutine are not OpenMP loopings.&lt;BR /&gt;
	&lt;BR /&gt;
	Cheers,&lt;BR /&gt;
	Eduardo&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2014 16:59:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963778#M95235</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-28T16:59:10Z</dc:date>
    </item>
    <item>
      <title>Steve,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963779#M95236</link>
      <description>&lt;P&gt;Steve,&lt;/P&gt;

&lt;P&gt;I'm looking to the results file and I think it will take some time until I can sort out what is being done.&lt;BR /&gt;
	I think I should make the comparison of the report with and without the print instruction, to see what is changing.&lt;BR /&gt;
	&lt;BR /&gt;
	I'll dig a little deeper in this before sending a case test.&lt;BR /&gt;
	I want to try/test everything before assuming that is effectively a compiler problem.&lt;BR /&gt;
	&lt;BR /&gt;
	Thanks&lt;BR /&gt;
	Eduardo&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2014 17:19:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963779#M95236</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-28T17:19:29Z</dc:date>
    </item>
    <item>
      <title>Try this:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963780#M95237</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;P&gt;Change "print *,a" to "if (doDebug) print *,a"&lt;/P&gt;

&lt;P&gt;Make doDebug a global logical variable initialize to .TRUE.&lt;/P&gt;

&lt;P&gt;Run the program and verify it does not crash.&lt;BR /&gt;
	Re-run the program (do not recompile) with break at start, change doDebug to .FALSE., continue.&lt;BR /&gt;
	Does the program complete or crash?&lt;/P&gt;

&lt;P&gt;This test will run the exact same code with different code path.&lt;/P&gt;

&lt;P&gt;This is an indirect test to see if the call to print, which will modify&amp;nbsp;memory locations&amp;nbsp;deeper on the stack, which is memory supposedly not used by the routine Compute_Multiparameters, but possibly used by code called by Compute_Multiparameters. Note, if a subroutine/function called by Compute_Multiparameters has variables that are supposed to be persistent (or unintentionally require persistence) then the call to the print may accidentally provide the appearance of it fixes the problem. Using the doDebug to enable/disable the printing will test this hypothesis.&lt;/P&gt;

&lt;P&gt;&amp;gt;&amp;gt;BUT, when the error happens, it is this variable that changes it value, and this leads to utlimately the error on the suspected routine.&lt;/P&gt;

&lt;P&gt;Curious.&lt;/P&gt;

&lt;P&gt;Does the LOC(&lt;STRONG&gt;Me%ExternalVar%Concentration3D&lt;/STRONG&gt;) and/or SIZE(&lt;STRONG&gt;Me%ExternalVar%Concentration3D&lt;/STRONG&gt;) change as well (IOW your pointer got corrupted)?&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Sat, 29 Mar 2014 17:25:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963780#M95237</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-03-29T17:25:51Z</dc:date>
    </item>
    <item>
      <title>Hi Jim,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963781#M95238</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;

&lt;P&gt;I did the test of making the print based on "doDebug", on run letting the default value of .true. and one where I changed the value at the construction for .false.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Both simulations run to the end, with exact the same results. Removing this instruction from the routine (comment it) makes the error appear.&lt;BR /&gt;
	In the case it works (with the print) the results are identical to a run without OpenMP and one without Optimizations without the print.&lt;/P&gt;

&lt;P&gt;When the program crashes,&amp;nbsp;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;LOC(&lt;/SPAN&gt;&lt;SPAN style="font-weight: 700; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;Me%ExternalVar%Concentration3D&lt;/SPAN&gt;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;) and SIZE(&lt;/SPAN&gt;&lt;SPAN style="font-weight: 700; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;Me%ExternalVar%Concentration3D&lt;/SPAN&gt;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;) both remain the same from beginning to end. No changes at all.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;In fact, running a simulation that runs ok (with print or without optimizations or without OpenMP) and comparing the results with one that fails, I noticed a thing.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;The error rises in a routine called&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ModifySolarRadiation&lt;/STRONG&gt;, in this &amp;nbsp;equation:&amp;nbsp;&lt;EM&gt;exp(-ShortWaveExtinctionField(i,j,k+1) * Thickness)&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;ShortWaveExtinctionField&amp;nbsp;&lt;/EM&gt;is defined in the &lt;STRONG&gt;Compute_MultiParameters&lt;/STRONG&gt; routine, is a pointer to &lt;EM&gt;Me%ShortWaveExtinctionCoef3D&lt;/EM&gt; array. This by its time, depends on the value of the Concentration.&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;Because in the&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Compute_MultiParameters&lt;/STRONG&gt;&amp;nbsp;subroutine everything seems fine, the values are being correctly calculated (I checked), I look for the Concentration3D as the only possibility for the error. In fact, the error starts there.&lt;/P&gt;

&lt;P&gt;The Concentration3D array is calculated inside other routines, one of them named&amp;nbsp;&lt;STRONG&gt;AdvectionDiffusion&lt;/STRONG&gt;, that is in another module. Looking for the value before and after entering this routine, for both ok and bad runs, I noticed that for many iterations, everything goes well, with both runs having exactly the same value before and after.&lt;/P&gt;

&lt;P&gt;Suddenly, in the bad run, the result changes after entering this routine (after many iterations).&lt;/P&gt;

&lt;P&gt;What puzzles me is how a simple print in a routine in another module can make this strange behaviour disappear...&lt;BR /&gt;
	I first thought of an OpenMP problem, but the results are always the same for the bad simulation, and for a OpenMP problem I was expecting some kind of differences in the results, from run to run. I was expecting different results also if it was a stack corruption or something like that.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Mar 2014 21:06:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963781#M95238</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-29T21:06:00Z</dc:date>
    </item>
    <item>
      <title>I don't know whether you've</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963782#M95239</link>
      <description>&lt;P&gt;I don't know whether you've looked into it, but of course adding a print could prevent the compiler from vectorizing, possibly reducing the possibility of puzzling results from incorrect code, or could introduce sufficient delay to suppress potential race conditions. &amp;nbsp;It can equally happen that race conditions are suppressed by code optimization, in case you consider that puzzling.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Mar 2014 21:21:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963782#M95239</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2014-03-29T21:21:48Z</dc:date>
    </item>
    <item>
      <title>Hello Tim,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963783#M95240</link>
      <description>&lt;P&gt;Hello Tim,&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I looked into the report from the optimizer and it seems that he is unable to vectorize the loopings inside the Compute_Multiparameters routine, due some kind of dependence or non-standard looping.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Here is the part of the report (that I attached) regarding the loopings:&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;------ Build started: Project: MOHIDBase1, Configuration: Release Double OpenMP|x64 ------

Compiling with Intel(R) Visual Fortran Compiler XE 14.0.2.176 [Intel(R) 64]...
ModuleLightExtinction.F90

HLO REPORT LOG OPENED ON Sat Mar 29 21:42:07 2014

&amp;lt;D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90;-1:-1;hlo;MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS;0&amp;gt;
High Level Optimizer Report (MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS)
QLOOPS 9/9/0	ENODE LOOPS 9 unknown 0 multi_exit_do 2 do 7 linear_do 7 lite_throttled 0
LINEAR HLO EXPRESSIONS:  160 / 637 + LINEAR(innermost): 83 / 637
------------------------------------------------------------------------------
HPO VECTORIZER REPORT (MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS) LOG OPENED ON Sat Mar 29 21:42:07 2014

&amp;lt;D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90;-1:-1;hpo_vectorization;MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS;0&amp;gt;
HPO Vectorizer Report (MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS)
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1461:17-1461:17):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  loop was not vectorized: nonstandard loop is not a vectorization candidate
loop was not vectorized: existence of vector dependence
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1465:25-1465:25):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  potential FLOW dependence
potential ANTI dependence
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1460:17-1460:17):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  loop was not vectorized: not inner loop
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1459:17-1459:17):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  loop was not vectorized: not inner loop
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1442:17-1442:17):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  loop was not vectorized: nonstandard loop is not a vectorization candidate
loop was not vectorized: existence of vector dependence
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1446:25-1446:25):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  potential FLOW dependence on .2.93_2.
potential ANTI dependence on .2.93_2.
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1441:17-1441:17):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  loop was not vectorized: not inner loop
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1440:17-1440:17):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  loop was not vectorized: not inner loop
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1491:13-1491:13):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  loop was not vectorized: existence of vector dependence
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1493:53-1495:21):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  potential ANTI dependence between ME and (unknown).
D:\Projects\Software\mohid.codeplex.pristine.tests\Software\MOHIDBase1\ModuleLightExtinction.F90(1495:21-1493:53):VEC:MODULELIGHTEXTINCTION_mp_COMPUTE_MULTIPARAMETERS:  potential FLOW dependence between (unknown) and ME.

&lt;/PRE&gt;

&lt;P&gt;Could be something related to "inlining"?&lt;BR /&gt;
	I put also the report when the print is there. It seems that the "inline" thing changes are more important than the vectorization (that do not happens either way).&lt;/P&gt;</description>
      <pubDate>Sat, 29 Mar 2014 22:01:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963783#M95240</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-29T22:01:50Z</dc:date>
    </item>
    <item>
      <title>Hello Tim,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963784#M95241</link>
      <description>&lt;P&gt;Hello Tim,&lt;/P&gt;

&lt;P&gt;With or without the print statments, the loopings are not being vectorized according the optmization report.&lt;BR /&gt;
	I compiled just the module where Compute_Multiparameters is, selecting just the routine.&lt;/P&gt;

&lt;P&gt;The post with the reports attached (both with and without the print instruction) are waiting for approval.&lt;/P&gt;

&lt;P&gt;Maybe is something related with inlining...&lt;/P&gt;</description>
      <pubDate>Sat, 29 Mar 2014 22:05:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963784#M95241</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-29T22:05:30Z</dc:date>
    </item>
    <item>
      <title>I tested a change in the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963785#M95242</link>
      <description>&lt;P&gt;I tested a change in the subroutine, using arguments to pass the matrix:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;    subroutine Compute_Multiparameters (ExtinctionCoefField3D, ExtinctionCoefField1D)
    
        real, dimension(:,:,:), pointer, optional   :: ExtinctionCoefField3D
        real, dimension(:), pointer, optional       :: ExtinctionCoefField1D

        !Local-----------------------------------------------------------------
        integer                                 :: i, j, k

        !Begin-----------------------------------------------------------------        

if3D:   if (Me%Is3D) then

            if (.not. present(ExtinctionCoefField3D)) stop 'ModuleLightExtiction - Compute_Multiparameters - ERR001'

             if((Me%ExternalVar%PropertyID == MacroAlgae_) .OR. (Me%ExternalVar%PropertyID == SeagrassesLeaves_) ) then  

                do k = Me%WorkSize%KLB, Me%WorkSize%KUB
                do j = Me%WorkSize%JLB, Me%WorkSize%JUB
                do i = Me%WorkSize%ILB, Me%WorkSize%IUB

                    if (Me%ExternalVar%WaterPoints3D(i, j, k) == WaterPoint) then 

                        ExtinctionCoefField3D(i,j,k) =                           &amp;amp;
                                            ExtinctionCoefField3D(i,j,k)       + &amp;amp;
                                            Me%ExternalVar%ExtinctionParameter              * &amp;amp;
                                           (Me%ExternalVar%Concentration3D(i, j, k)         * &amp;amp;
                                            Me%ExternalVar%ProducerOccupation(i, j, k)    * Me%UnitsCoef)
                    end if

                enddo
                enddo
                enddo

            else 
                                
                do k = Me%WorkSize%KLB, Me%WorkSize%KUB
                do j = Me%WorkSize%JLB, Me%WorkSize%JUB
                do i = Me%WorkSize%ILB, Me%WorkSize%IUB

                    if (Me%ExternalVar%WaterPoints3D(i, j, k) == WaterPoint) then 

                        ExtinctionCoefField3D(i,j,k) =                                &amp;amp;
                                            ExtinctionCoefField3D(i,j,k)            + &amp;amp;
                                            Me%ExternalVar%ExtinctionParameter      * &amp;amp;
                                           (Me%ExternalVar%Concentration3D(i, j, k) * Me%UnitsCoef)
                                      
                    end if

                enddo
                enddo
                enddo

            end if 

        else if3D

            if (.not. present(ExtinctionCoefField1D)) stop 'ModuleLightExtiction - Compute_Multiparameters - ERR003'
            
            do i = Me%Size1D%ILB, Me%Size1D%IUB

                if (Me%ExternalVar%RiverPoints1D(i) == WaterPoint) then 
                
                    ExtinctionCoefField1D(i) =                                &amp;amp;
                                        ExtinctionCoefField1D(i)            + &amp;amp;
                                        Me%ExternalVar%ExtinctionParameter  * &amp;amp;
                                        (Me%ExternalVar%Concentration1D(i)  * Me%UnitsCoef)                                        
                end if

            enddo

        endif if3D

    end subroutine Compute_Multiparameters&lt;/PRE&gt;

&lt;P&gt;The use of arguments instead of the "global" variables also has the same effect in results than the "print" instruction, making the error disappear.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;What the optimization can do with a subroutine without arguments that it can't with one with arguments?&lt;BR /&gt;
	&lt;BR /&gt;
	Cheers,&lt;BR /&gt;
	Eduardo.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Mar 2014 11:31:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-Optimization-O2-or-O3-causes-floating-overflow/m-p/963785#M95242</guid>
      <dc:creator>Jauch</dc:creator>
      <dc:date>2014-03-30T11:31:17Z</dc:date>
    </item>
  </channel>
</rss>

