<?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 Hi, in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058900#M117013</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;More updates on the leak: it leaks only at the first time it calls the function, subsequent calls do not increase the leak. If the function is in an executable, 1MB might not be the end of the world. Our problem is that this function is part of a dll which is loaded/unloaded many times, which adds up fast.&lt;/P&gt;

&lt;P&gt;I am using ProcessExplorer to follow the leak (Private Bytes column).&lt;/P&gt;

&lt;P&gt;It seems that the following similar code does not leak:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;     integer*4, parameter :: MATN_ = 10
     write(*,10)(line(j),j=1,MATN_)
  10 format(1x,&amp;lt;MATN_&amp;gt;a1)
&lt;/PRE&gt;

&lt;P&gt;Rak&lt;/P&gt;</description>
    <pubDate>Mon, 23 Mar 2015 14:37:56 GMT</pubDate>
    <dc:creator>rakkota</dc:creator>
    <dc:date>2015-03-23T14:37:56Z</dc:date>
    <item>
      <title>Memory leak in FORTRAN format with variable string length</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058894#M117007</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am experiencing a memory leak of ~1MB in a subroutine if I am using the following write like statement inside:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;    write(*,10)(line(j),j=1,var)
10  format(1x,&amp;lt;var&amp;gt;a1)&lt;/PRE&gt;

&lt;P&gt;where var is variable computed at runtime. Is this a known issue?&lt;/P&gt;

&lt;P&gt;I am using ifort 13.1.3.198 Build&amp;nbsp;20130607 under Windows.&lt;/P&gt;

&lt;P&gt;Rak&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2015 22:25:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058894#M117007</guid>
      <dc:creator>rakkota</dc:creator>
      <dc:date>2015-03-20T22:25:27Z</dc:date>
    </item>
    <item>
      <title>Would you please provide a</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058895#M117008</link>
      <description>&lt;P&gt;Would you please provide a small but complete example demonstrating this? Also, please try the current version 15.0.2 if you can.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2015 23:51:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058895#M117008</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-03-20T23:51:11Z</dc:date>
    </item>
    <item>
      <title>Quote:rakkota wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058896#M117009</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;rakkota wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;..&lt;/P&gt;

&lt;P&gt;I am using ifort 13.1.3.198 Build&amp;nbsp;20130607 under Windows.&lt;/P&gt;

&lt;P&gt;Rak&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Is it possible for you to upgrade to the latest version? &amp;nbsp;While it is possible the version you're using and some subsequent versions may have memory leaks with WRITE operations (I'm not sure, but I do recall running into such problems with internal files), I have not noticed issues with WRITE and memory leaks in the current compiler 2015, update 2 version.&lt;/P&gt;

&lt;P&gt;By the way, you may know the use of &amp;lt;var&amp;gt; in the FORMAT statement is a compiler extension and not standard-conforming. &amp;nbsp;See this thread, Quote #18 by Steve Lionel:&amp;nbsp;https://software.intel.com/en-us/forums/topic/542686.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2015 14:43:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058896#M117009</guid>
      <dc:creator>FortranFan</dc:creator>
      <dc:date>2015-03-21T14:43:28Z</dc:date>
    </item>
    <item>
      <title>Here is a reproducer. While</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058897#M117010</link>
      <description>&lt;P&gt;Here is a reproducer.&amp;nbsp;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I put the VFEs in a subroutine to localize the reported location of the memory leak. I used IFort 15.0.2 - 32 bit. Changing the upper limit of the DO loop to 540 did not change the reported size of the leak,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;No problem was reported when I used the 64-bit compiler.&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program vfex
call sub()        ! memory leak of 1056768 bytes reported by Inspector XE
end program

subroutine sub()
implicit none
integer :: i,j,nvar
character(1) :: lin(255)
character(255) :: olin
do i=1,255
   lin(i)=char(mod(i*257+13,255))
end do
do i=513,767
   nvar=i-512
100 format(&amp;lt;nvar&amp;gt;A1)
   write(olin,100)(lin(j),j=nvar,1,-1)
end do
end subroutine sub
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2015 16:11:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058897#M117010</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2015-03-21T16:11:00Z</dc:date>
    </item>
    <item>
      <title>Quote:mecej4 wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058898#M117011</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;mecej4 wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Here is a reproducer. ..&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Interesting, I wonder if it is a false positive by Intel Inspector.&lt;/P&gt;

&lt;P&gt;Anyways, one can retry with line 15 replaced with standard-conforming&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;100 format(*(A1))
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2015 16:57:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058898#M117011</guid>
      <dc:creator>FortranFan</dc:creator>
      <dc:date>2015-03-21T16:57:47Z</dc:date>
    </item>
    <item>
      <title>Thanks, we'll check this out.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058899#M117012</link>
      <description>&lt;P&gt;Thanks, we'll check this out.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2015 00:32:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058899#M117012</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-03-22T00:32:12Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058900#M117013</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;More updates on the leak: it leaks only at the first time it calls the function, subsequent calls do not increase the leak. If the function is in an executable, 1MB might not be the end of the world. Our problem is that this function is part of a dll which is loaded/unloaded many times, which adds up fast.&lt;/P&gt;

&lt;P&gt;I am using ProcessExplorer to follow the leak (Private Bytes column).&lt;/P&gt;

&lt;P&gt;It seems that the following similar code does not leak:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;     integer*4, parameter :: MATN_ = 10
     write(*,10)(line(j),j=1,MATN_)
  10 format(1x,&amp;lt;MATN_&amp;gt;a1)
&lt;/PRE&gt;

&lt;P&gt;Rak&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 14:37:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058900#M117013</guid>
      <dc:creator>rakkota</dc:creator>
      <dc:date>2015-03-23T14:37:56Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058901#M117014</link>
      <description>&lt;P style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;Hi,&lt;/P&gt;

&lt;P style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;More updates on the leak: it leaks only at the first time it calls the function, subsequent calls do not increase the leak. If the function is in an executable, 1MB might not be the end of the world. Our problem is that this function is part of a dll which is loaded/unloaded many times, which adds up fast.&lt;/P&gt;

&lt;P style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;I am using ProcessExplorer to follow the leak (Private Bytes column).&lt;/P&gt;

&lt;P style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;It seems that the following similar code does not leak:&lt;/P&gt;

&lt;PRE class="brush:fortran;" style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;     integer*4, parameter :: MATN_ = 10
     write(*,10)(line(j),j=1,MATN_)
  10 format(1x,&amp;lt;MATN_&amp;gt;a1)
&lt;/PRE&gt;

&lt;P style="font-size: 13.0080003738403px; line-height: 19.5120010375977px;"&gt;Rak&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 14:39:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058901#M117014</guid>
      <dc:creator>rakkota</dc:creator>
      <dc:date>2015-03-23T14:39:48Z</dc:date>
    </item>
    <item>
      <title>Thanks - I have escalated</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058902#M117015</link>
      <description>&lt;P&gt;Thanks - I have escalated this as issue&amp;nbsp;DPD200368141.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 15:03:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058902#M117015</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-03-23T15:03:52Z</dc:date>
    </item>
    <item>
      <title>Quote:FortranFan wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058903#M117016</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;FortranFan wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG class="quote-header"&gt;Quote:&lt;/STRONG&gt;&lt;/P&gt;

&lt;BLOCKQUOTE class="quote-msg quote-nest-1 odd"&gt;
	&lt;DIV class="quote-author"&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Anyways, one can retry with line 15 replaced with standard-conforming&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;

&lt;PRE class="brush:fortran;"&gt;100 format(*(A1))
&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Thanks Lionel.&lt;BR /&gt;
	Using the standard notation *(A1) works fine in isolation, as suggested, but produces undesired output if used in conjunction with other variables.&amp;nbsp;For example the following dummy code:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;     subroutine myfunc()
     implicit none
     integer*4, parameter :: MATN_ = 10
     integer line(10),j,var
     data line/'a','b','c','d','e','f','g','h','i','j'/
     var=MATN_
     write(*,10)(line(j),j=1,var-2),line(2),line(3)
  10 format(1x,*(a1),1x,a1,a1)
     end subroutine myfunc    &lt;/PRE&gt;

&lt;P&gt;produces at output&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt; abcdefghbc&lt;/PRE&gt;

&lt;P&gt;while expected&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt; abcdefgh bc&lt;/PRE&gt;

&lt;P&gt;On the other hand, the equivalent variable length construction&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;    write(*,10)(line(j),j=1,var-2),line(2),line(3)
10  format(1x,&amp;lt;var-2&amp;gt;(a1),1x,a1,a1)&lt;/PRE&gt;

&lt;P&gt;comes in handy and produces the expected result.&lt;/P&gt;

&lt;P&gt;Rak&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 14:40:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058903#M117016</guid>
      <dc:creator>rakkota</dc:creator>
      <dc:date>2015-03-25T14:40:52Z</dc:date>
    </item>
    <item>
      <title>Investigation so far shows</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058904#M117017</link>
      <description>&lt;P&gt;Investigation so far shows that this leak occurs for VFEs and if you pass a contained procedure as an argument - both create what is called a "bound procedure value" and the routine that is doing this is reserving a rather large chunk of memory for a pool and not releasing it on image exit or DLL unload. Only 12 bytes for the BPV is being allocated, but that larger pool is the leak. It's a one-time thing, but we understand the issue for DLLs.&lt;/P&gt;

&lt;P&gt;Still, for your case if you can avoid VFEs it would be better. It is true that the unlimited repeat count isn't useful if other variables follow that need different formats. The standard-conforming approach would be something like this:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;   subroutine myfunc()
   implicit none
   integer*4, parameter :: MATN_ = 10
   integer line(10),j,var
   data line/'a','b','c','d','e','f','g','h','i','j'/
   character(50) fmt
   var=MATN_
   write (fmt,'(A,I0,A)') '(1x,',var-2,'a1,1x,a1,a1)'
   write(*,fmt)(line(j),j=1,var-2),line(2),line(3)
   end subroutine myfunc    &lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 14:49:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Memory-leak-in-FORTRAN-format-with-variable-string-length/m-p/1058904#M117017</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-03-25T14:49:59Z</dc:date>
    </item>
  </channel>
</rss>

