<?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 Re: Problem with ReAlloc in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830364#M52154</link>
    <description>&lt;DIV&gt;Alas, only temporarily :-( -- they merged some holidays so I got an extended weekend off. I'll be definitely back only in mid-August.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Regards&lt;/DIV&gt;
&lt;DIV&gt;Jugoslav&lt;/DIV&gt;</description>
    <pubDate>Thu, 28 Apr 2005 20:40:42 GMT</pubDate>
    <dc:creator>Jugoslav_Dujic</dc:creator>
    <dc:date>2005-04-28T20:40:42Z</dc:date>
    <item>
      <title>Problem with ReAlloc</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830358#M52148</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I am trying to use the routine ReAllocbut I get the following error.&lt;/DIV&gt;
&lt;DIV&gt;What am I doing wrong?&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;subroutine TryReAlloc&lt;/DIV&gt;
&lt;DIV&gt;real,allocatable::B(:)&lt;BR /&gt;integer::j&lt;BR /&gt;real::c&lt;/DIV&gt;
&lt;DIV&gt;c=1.34&lt;/DIV&gt;
&lt;DIV&gt;do j=1,10&lt;BR /&gt;call ReAlloc (B,j)&lt;BR /&gt;B(j)=c*j&lt;BR /&gt;end do&lt;/DIV&gt;
&lt;DIV&gt;end subroutine TryReAlloc&lt;/DIV&gt;
&lt;DIV&gt;!--------------------------&lt;/DIV&gt;
&lt;DIV&gt;subroutine ReAlloc (A,n)&lt;BR /&gt;! A array&lt;BR /&gt;! n new size&lt;/DIV&gt;
&lt;DIV&gt;real,allocatable::A(:)&lt;BR /&gt;integer::n,nOld&lt;BR /&gt;real,allocatable::Temp(:)&lt;BR /&gt;nOld=size(A)&lt;BR /&gt;if (nOld &amp;gt; n) RETURN&lt;BR /&gt;allocate (Temp(nOld))&lt;BR /&gt;Temp=A&lt;BR /&gt;Deallocate (A)&lt;BR /&gt;Allocate (A(n))&lt;BR /&gt;A(1:nOld)=Temp&lt;BR /&gt;end subroutine ReAlloc&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Warning: In the call to REALLOC, actual argument #1 does not match the type and kind of the corresponding dummy argument.&lt;BR /&gt; call ReAlloc (B,j)&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Thanks,&lt;/DIV&gt;
&lt;DIV&gt;David&lt;/DIV&gt;</description>
      <pubDate>Tue, 26 Apr 2005 20:16:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830358#M52148</guid>
      <dc:creator>davidgraham</dc:creator>
      <dc:date>2005-04-26T20:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ReAlloc</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830359#M52149</link>
      <description>You need an explicit interface to call a routine which has a deferred-shape (:) argument.</description>
      <pubDate>Tue, 26 Apr 2005 20:41:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830359#M52149</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-04-26T20:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ReAlloc</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830360#M52150</link>
      <description>&lt;DIV&gt;Thanks, I have got it working now.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I am trying to repicate the Visual Basic redim preserve command.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I have found that the method of using the ReAlloc routine takes long time for a large array.&lt;/DIV&gt;
&lt;DIV&gt;Repeating the loop 100 time takes 0.000 secs, 1,000 times takes 0.08 secs, 10,000 times takes 8.4 secs, 100,000 times - I gave up waiting.&lt;/DIV&gt;
&lt;DIV&gt;Is there a more efficient way of doing this?&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;David&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 27 Apr 2005 15:18:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830360#M52150</guid>
      <dc:creator>davidgraham</dc:creator>
      <dc:date>2005-04-27T15:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ReAlloc</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830361#M52151</link>
      <description>Not at present.  Fortran 2003 offers a way of doing a "realloc" on allocatables.  You would have a bit better luck using POINTER as you could just move pointers around and just move the data once and not twice.</description>
      <pubDate>Wed, 27 Apr 2005 19:51:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830361#M52151</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-04-27T19:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ReAlloc</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830362#M52152</link>
      <description>&lt;P&gt;David,&lt;/P&gt;
&lt;P&gt;You can speed it up using C code (or even, an equivalent Fortran code), by directly manipulating Fortran array descriptor. Basically, the F2000 MOVE_ALLOC does only &lt;STRONG&gt;one &lt;/STRONG&gt;allocation instead of two, by means of having two pieces of allocated memory -- the old one and the new one -- simultaneously. Here's a sketch, which reusessome codefrom thread:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://softwareforums.intel.com/ids/board/message?board.id=5&amp;amp;message.id=10361&amp;amp;view=by_date_ascending&amp;amp;page=1" target="_blank"&gt;http://softwareforums.intel.com/ids/board/message?board.id=5&amp;amp;message.id=10361&amp;amp;view=by_date_ascending&amp;amp;page=1&lt;/A&gt;&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: black 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; BORDER-LEFT: black 1px solid; PADDING-TOP: 10px; BORDER-BOTTOM: black 1px solid"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;PRE&gt;void move_alloc(CVF_1D_DESCRIPTOR* A, int iSizeSingleElement,
  int iNewArraySize)
{
  void* lpOldAddress;
  lpOldAddress = A-&amp;gt;lpAddress;
  A-&amp;gt;lpAddress = malloc(iNewArraySize*iSizeSingleElement);

  // Copy the old contents into new location
  if (A-&amp;gt;iAllocated) 
  {
     memcpy(lpOldAddress, A-&amp;gt;lpAddress, A-&amp;gt;Dim1.iExtent * iSizeSingleElement);
     // kill the old allocation
     free(lpOldAddress);
  }
  A-&amp;gt;Dim1.iExtent = iNewArraySize;
  //Fill in the rest of A appropriately
}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV&gt;Instead of malloc/memcpy/free you can use native Windows APIs or whatever. Note, however, that you have to use same allocators as were used to allocate the original array, meaning that you cannot e.g. free() memory which was not allocated with malloc() but e.g. with ALLOCATE (unless you happen to know which API is used by ALLOCATE internally). Thus, you should probably write your own (de)allocation routines in C, using the same malloc/free as used in move_alloc above.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Hope this helps,&lt;/DIV&gt;
&lt;DIV&gt;Jugoslav&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 Apr 2005 18:36:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830362#M52152</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2005-04-28T18:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ReAlloc</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830363#M52153</link>
      <description>Hey, Jugoslav's back!</description>
      <pubDate>Thu, 28 Apr 2005 19:24:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830363#M52153</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-04-28T19:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ReAlloc</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830364#M52154</link>
      <description>&lt;DIV&gt;Alas, only temporarily :-( -- they merged some holidays so I got an extended weekend off. I'll be definitely back only in mid-August.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Regards&lt;/DIV&gt;
&lt;DIV&gt;Jugoslav&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 Apr 2005 20:40:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-ReAlloc/m-p/830364#M52154</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2005-04-28T20:40:42Z</dc:date>
    </item>
  </channel>
</rss>

