<?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 It is usually the case that in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/O0-modifies-variable-value/m-p/946793#M91334</link>
    <description>&lt;P&gt;It is usually the case that when one can't reproduce the problem in a smaller case, the actual issue is somewhere different than you think. It is almost always the case that a "snippet" bears little or no bearing on the real problem.&lt;/P&gt;
&lt;P&gt;You can run the program under the debuggger and step through it, watching the variable to see when and where it changes.&amp;nbsp; This may give you a clue as to what is wrong. For problems such as this, it is almost always a coding error in the application.&lt;/P&gt;</description>
    <pubDate>Sun, 17 Feb 2013 23:52:00 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2013-02-17T23:52:00Z</dc:date>
    <item>
      <title>-O0 modifies variable value</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/O0-modifies-variable-value/m-p/946791#M91332</link>
      <description>&lt;P&gt;I came across a weird situation while trying to debug my code. I tried to reproduce it in a smaller program but unfortunately couldn't, so let me start by posting the relevant snippets:&lt;/P&gt;
&lt;P&gt;[fortran]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; subroutine sub(H)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; implicit none&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; type(derived), intent(inout) :: H&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer :: i, N&lt;BR /&gt;...&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; N = size(H%field1) ! yields 24&lt;BR /&gt;...&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1,N&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; print*,i,N&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; call module_sub(H%field2,H%field3)&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; print*,i,N&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end do&lt;BR /&gt;...&lt;BR /&gt;&amp;nbsp; end subroutine sub&lt;/P&gt;
&lt;P&gt;[/fortran]&lt;/P&gt;
&lt;P&gt;The full program, including the module containing sub (file ops.f90), compiles OK:&lt;/P&gt;
&lt;P&gt;[bash]&lt;/P&gt;
&lt;P&gt;$ make&lt;BR /&gt;...&lt;BR /&gt;ifort -O0 -c ops.f90&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;$ ifort -V&lt;BR /&gt;Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 13.0.1.117 Build 20121010&lt;BR /&gt;Copyright (C) 1985-2012 Intel Corporation.&amp;nbsp; All rights reserved.&lt;BR /&gt;FOR NON-COMMERCIAL USE ONLY&lt;/P&gt;
&lt;P&gt;[/bash]&lt;/P&gt;
&lt;P&gt;There are no warnings when compiled with any / all of -warn all -debug full -check all -check bounds. Here is the relevant output of the two print statements shown above:&lt;/P&gt;
&lt;P&gt;[bash]&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&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; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24&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; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;[/bash]&lt;/P&gt;
&lt;P&gt;Note that the variable N is defined in the beginning and never touched again and that it is not passed to module_sub. It is only used as an upper DO-loop bound after the second print.&amp;nbsp;There is no connection to global variables whatsoever. The weird behavior disappears for -O1 and above and the code always prints the same initial value of N (=24 in the example above).&lt;/P&gt;
&lt;P&gt;Is there any O0-related reason why ifort changes the value of this variable? If not, is this perhaps a known issue? If not and not, would it make sense to provide the full code (modified version that makes it easy to spot the relevant point, of course)?&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Feb 2013 14:04:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/O0-modifies-variable-value/m-p/946791#M91332</guid>
      <dc:creator>Stefanos_K_</dc:creator>
      <dc:date>2013-02-16T14:04:35Z</dc:date>
    </item>
    <item>
      <title>Hi Stefane,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/O0-modifies-variable-value/m-p/946792#M91333</link>
      <description>&lt;P&gt;Hi Stefane,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;I've just written a test program to simulate your case. If you don't describe mod_sub then its difficult to tell what's happening. Could you please write a toy module_sub &amp;nbsp;that replaces my module_sub and does what yours is doing (or at least as similar as possible) ?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;With the code I posted, I don't get the same behaviour (version 13.1.0.146), so in my opinion module_sub is essential.&lt;/P&gt;
&lt;P&gt;BR,&lt;/P&gt;
&lt;P&gt;Kostas&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Feb 2013 21:03:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/O0-modifies-variable-value/m-p/946792#M91333</guid>
      <dc:creator>kostas85</dc:creator>
      <dc:date>2013-02-16T21:03:00Z</dc:date>
    </item>
    <item>
      <title>It is usually the case that</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/O0-modifies-variable-value/m-p/946793#M91334</link>
      <description>&lt;P&gt;It is usually the case that when one can't reproduce the problem in a smaller case, the actual issue is somewhere different than you think. It is almost always the case that a "snippet" bears little or no bearing on the real problem.&lt;/P&gt;
&lt;P&gt;You can run the program under the debuggger and step through it, watching the variable to see when and where it changes.&amp;nbsp; This may give you a clue as to what is wrong. For problems such as this, it is almost always a coding error in the application.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Feb 2013 23:52:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/O0-modifies-variable-value/m-p/946793#M91334</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-02-17T23:52:00Z</dc:date>
    </item>
  </channel>
</rss>

