<?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 Quote:Steve Lionel (Intel) in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039315#M112654</link>
    <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Steve Lionel (Intel) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Or do this instead:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt; recursive subroutine test_recursive(i)
    implicit none
    integer::i
    if(i&amp;lt;=10)call test_recursive(i+1)
    print *,i
    end subroutine&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Dear Steve,&lt;/P&gt;

&lt;P&gt;Thank you very much for your kindly reply. The output is just what I needed.&lt;/P&gt;

&lt;P&gt;However, I need the increase of i be happened in the subroutine instead of during calling. I require this because every time the increase could be different. Is it possible to do so?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jun 2014 01:29:26 GMT</pubDate>
    <dc:creator>Zhanghong_T_</dc:creator>
    <dc:date>2014-06-13T01:29:26Z</dc:date>
    <item>
      <title>Question about local variable of recursive subroutine</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039309#M112648</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;For the following code, the compiler will show error #8000 if I use /warn:interfaces option. Could anyone tell me the problem of the code?&lt;/P&gt;

&lt;P&gt;After disabled this option, the running result is not what I expected. I wish the results are every subroutine's local value i, but now every display is 11. Could anyone help me to take a look at the problem?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Zhanghong Tang&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; subroutine test_recursive(i)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; implicit none&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; integer::i&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; i=i+1&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; if(i&amp;lt;=10)call test_recursive(i)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; print *,i&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; end subroutine&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; program testrecursive&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; implicit none&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ! Variables&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; integer::i=0&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; ! Body of testrecursive&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; call test_recursive(i)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; end program testrecursive&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 00:51:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039309#M112648</guid>
      <dc:creator>Zhanghong_T_</dc:creator>
      <dc:date>2014-06-13T00:51:59Z</dc:date>
    </item>
    <item>
      <title>Oh sorry, the first problem</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039310#M112649</link>
      <description>&lt;P&gt;Oh sorry, the first problem is solved. I forgot to add keyword&amp;nbsp; '&lt;CODE class="keyword"&gt;RECURSIVE'. &lt;/CODE&gt; How to solve my second problem?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 01:07:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039310#M112649</guid>
      <dc:creator>Zhanghong_T_</dc:creator>
      <dc:date>2014-06-13T01:07:43Z</dc:date>
    </item>
    <item>
      <title>Since i is passed by</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039311#M112650</link>
      <description>&lt;P&gt;Since i is passed by reference, there is only one value of i, not one per instance.&amp;nbsp; If you wish to create per-instance values for i, declare it as being passed by value and makes its interface explicit to program testrecursive.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 01:10:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039311#M112650</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2014-06-13T01:10:21Z</dc:date>
    </item>
    <item>
      <title>The print statement needs to</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039312#M112651</link>
      <description>&lt;P&gt;The print statement needs to be before the recursive call to the subroutine.&amp;nbsp; You only ever get to the print statement after the last call.&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 01:13:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039312#M112651</guid>
      <dc:creator>DavidWhite</dc:creator>
      <dc:date>2014-06-13T01:13:34Z</dc:date>
    </item>
    <item>
      <title>Or do this instead:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039313#M112652</link>
      <description>&lt;P&gt;Or do this instead:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt; recursive subroutine test_recursive(i)
    implicit none
    integer::i
    if(i&amp;lt;=10)call test_recursive(i+1)
    print *,i
    end subroutine&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 01:14:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039313#M112652</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-06-13T01:14:00Z</dc:date>
    </item>
    <item>
      <title>Quote:David White wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039314#M112653</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;David White wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The print statement needs to be before the recursive call to the subroutine.&amp;nbsp; You only ever get to the print statement after the last call.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;David&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Hi David,&lt;/P&gt;

&lt;P&gt;Thanks for your kindly reply. The code I put here is the simplest. The real code need the print statement be after the last call. I wish the first print is the last calling's i value, the second print is the previous calling's i value, and so on. Just like the push and pop of stack. How to modify the code?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 01:23:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039314#M112653</guid>
      <dc:creator>Zhanghong_T_</dc:creator>
      <dc:date>2014-06-13T01:23:34Z</dc:date>
    </item>
    <item>
      <title>Quote:Steve Lionel (Intel)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039315#M112654</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Steve Lionel (Intel) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Or do this instead:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt; recursive subroutine test_recursive(i)
    implicit none
    integer::i
    if(i&amp;lt;=10)call test_recursive(i+1)
    print *,i
    end subroutine&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Dear Steve,&lt;/P&gt;

&lt;P&gt;Thank you very much for your kindly reply. The output is just what I needed.&lt;/P&gt;

&lt;P&gt;However, I need the increase of i be happened in the subroutine instead of during calling. I require this because every time the increase could be different. Is it possible to do so?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 01:29:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039315#M112654</guid>
      <dc:creator>Zhanghong_T_</dc:creator>
      <dc:date>2014-06-13T01:29:26Z</dc:date>
    </item>
    <item>
      <title>Won't some of these code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039316#M112655</link>
      <description>&lt;P&gt;Won't some of these code samples result in recursive IO?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 02:45:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039316#M112655</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2014-06-13T02:45:06Z</dc:date>
    </item>
    <item>
      <title>Ian, recursive I/O? No - none</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039317#M112656</link>
      <description>&lt;P&gt;Ian, recursive I/O? No - none of the I/O statements invoke the function.&lt;/P&gt;

&lt;P&gt;If you need the updated copy of i locally do it this way:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;recursive subroutine test_recursive(i)
   implicit none
   integer::i, local_i
   local_i = i + 1
   if(i&amp;lt;=10)call test_recursive(local_i)
   print *,local_i
   end subroutine&lt;/PRE&gt;

&lt;P&gt;Note that this doesn't allow the call to test_recursive to modify i, but you said you didn't want that.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2014 15:22:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039317#M112656</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-06-13T15:22:22Z</dc:date>
    </item>
    <item>
      <title>Quote:Steve Lionel (Intel)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039318#M112657</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Steve Lionel (Intel) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Ian, recursive I/O? No - none of the I/O statements invoke the function.&lt;/P&gt;

&lt;P&gt;If you need the updated copy of i locally do it this way:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;recursive subroutine test_recursive(i)
   implicit none
   integer::i, local_i
   local_i = i + 1
   if(i&amp;lt;=10)call test_recursive(local_i)
   print *,local_i
   end subroutine&lt;/PRE&gt;

&lt;P&gt;Note that this doesn't allow the call to test_recursive to modify i, but you said you didn't want that.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Dear Steve,&lt;/P&gt;

&lt;P&gt;Thank you very much for your kindly reply. I was confused the local parameters and passed parameters. I think the parameters should be recovered to original value when the function is back from the recursive calling, but I don't know the change of passed parameters can't be recovered.&lt;/P&gt;

&lt;P&gt;I have modified my code to let it work on this rule.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jun 2014 04:37:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039318#M112657</guid>
      <dc:creator>Zhanghong_T_</dc:creator>
      <dc:date>2014-06-14T04:37:26Z</dc:date>
    </item>
    <item>
      <title>There are two ways to prevent</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039319#M112658</link>
      <description>&lt;P&gt;There are two ways to prevent the called procedure from changing the variable you pass to it. One is to add the VALUE attribute in the interface to the procedure, as suggested earlier, but this requires an explicit interface. Another is to pass the variable enclosed in parentheses, making it an expression. Both have the same effect.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jun 2014 12:54:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039319#M112658</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2014-06-15T12:54:20Z</dc:date>
    </item>
    <item>
      <title>Quote:Steve Lionel (Intel)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039320#M112659</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Steve Lionel (Intel) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;There are two ways to prevent the called procedure from changing the variable you pass to it. One is to add the VALUE attribute in the interface to the procedure, as suggested earlier, but this requires an explicit interface. Another is to pass the variable enclosed in parentheses, making it an expression. Both have the same effect.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Dear Steve,&lt;/P&gt;

&lt;P&gt;Thank you very much for your kindly reply. I got it now.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Zhanghong Tang&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2014 05:48:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Question-about-local-variable-of-recursive-subroutine/m-p/1039320#M112659</guid>
      <dc:creator>Zhanghong_T_</dc:creator>
      <dc:date>2014-06-18T05:48:56Z</dc:date>
    </item>
  </channel>
</rss>

