<?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 Reallocation vs. Compiler Version Question in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762854#M18337</link>
    <description>We currently are running Intel Fortran V7.1 and are evidently not able to perform a reallocation operation to expand an existing array within a subroutine in which the array is being passed as an arguement.&lt;BR /&gt;&lt;BR /&gt;I tried the following gotten from this discussion group:&lt;BR /&gt;&lt;BR /&gt;        real, allocatable :: c(:)&lt;BR /&gt;        kmax=5&lt;BR /&gt;        allocate(c(kmax))&lt;BR /&gt;        nmax=10&lt;BR /&gt;        call realloc(c,nmax)&lt;BR /&gt;        stop&lt;BR /&gt;        end&lt;BR /&gt;        SUBROUTINE ReAlloc(A, n)&lt;BR /&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;BR /&gt;&lt;BR /&gt;and I get:&lt;BR /&gt;--------------------------------------&lt;BR /&gt;D:sigfit-devv2006&amp;gt;ifl realloc-code.f&lt;BR /&gt;Intel Fortran Compiler for 32-bit applications, Version 7.1   Build 20030307Z&lt;BR /&gt;&lt;BR /&gt;Copyright (C) 1985-2003 Intel Corporation.  All rights reserved.&lt;BR /&gt;&lt;BR /&gt;EPC Fortran-95 Version F95 Intel:200200:131124&lt;BR /&gt;Copyright (c) 1993-2000 EPCL. All Rights Reserved.&lt;BR /&gt;realloc-code.f&lt;BR /&gt;   main program&lt;BR /&gt;   external subroutine REALLOC&lt;BR /&gt;        DEALLOCATE(A)&lt;BR /&gt;                   ^&lt;BR /&gt;realloc-code.f(16): Error 230 : This entity is not a pointer to an array nor an allocatable array&lt;BR /&gt;        ALLOCATE(A(n))&lt;BR /&gt;                 ^&lt;BR /&gt;realloc-code.f(17): Error 230 : This entity is not a pointer to an array nor an allocatable array&lt;BR /&gt;realloc-code.f: Error 374 : Dummy argument A of procedure REALLOC must not be ALLOCATABLE&lt;BR /&gt;&lt;BR /&gt;3 Errors&lt;BR /&gt;compilation aborted for realloc-code.f (code 1)&lt;BR /&gt;--------------------------------------&lt;BR /&gt;&lt;BR /&gt;We are interpreting this to mean that since A is in the argument list, it may not be allocatable in the subroutine.&lt;BR /&gt;&lt;BR /&gt;The questions are:&lt;BR /&gt;&lt;BR /&gt;1. Are we interpreting the problem correctly and an upgrade will allow us to reallocate data structures in a subroutines after being passed through the argument list?&lt;BR /&gt;&lt;BR /&gt;2. With the latest version will we be able to perform reallocation on structures in COMMON?&lt;BR /&gt;&lt;BR /&gt;3. With the latest version is the above method the best way to reallocate data structures?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Greg</description>
    <pubDate>Tue, 31 Jan 2006 23:30:12 GMT</pubDate>
    <dc:creator>gjm</dc:creator>
    <dc:date>2006-01-31T23:30:12Z</dc:date>
    <item>
      <title>Reallocation vs. Compiler Version Question</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762854#M18337</link>
      <description>We currently are running Intel Fortran V7.1 and are evidently not able to perform a reallocation operation to expand an existing array within a subroutine in which the array is being passed as an arguement.&lt;BR /&gt;&lt;BR /&gt;I tried the following gotten from this discussion group:&lt;BR /&gt;&lt;BR /&gt;        real, allocatable :: c(:)&lt;BR /&gt;        kmax=5&lt;BR /&gt;        allocate(c(kmax))&lt;BR /&gt;        nmax=10&lt;BR /&gt;        call realloc(c,nmax)&lt;BR /&gt;        stop&lt;BR /&gt;        end&lt;BR /&gt;        SUBROUTINE ReAlloc(A, n)&lt;BR /&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;BR /&gt;&lt;BR /&gt;and I get:&lt;BR /&gt;--------------------------------------&lt;BR /&gt;D:sigfit-devv2006&amp;gt;ifl realloc-code.f&lt;BR /&gt;Intel Fortran Compiler for 32-bit applications, Version 7.1   Build 20030307Z&lt;BR /&gt;&lt;BR /&gt;Copyright (C) 1985-2003 Intel Corporation.  All rights reserved.&lt;BR /&gt;&lt;BR /&gt;EPC Fortran-95 Version F95 Intel:200200:131124&lt;BR /&gt;Copyright (c) 1993-2000 EPCL. All Rights Reserved.&lt;BR /&gt;realloc-code.f&lt;BR /&gt;   main program&lt;BR /&gt;   external subroutine REALLOC&lt;BR /&gt;        DEALLOCATE(A)&lt;BR /&gt;                   ^&lt;BR /&gt;realloc-code.f(16): Error 230 : This entity is not a pointer to an array nor an allocatable array&lt;BR /&gt;        ALLOCATE(A(n))&lt;BR /&gt;                 ^&lt;BR /&gt;realloc-code.f(17): Error 230 : This entity is not a pointer to an array nor an allocatable array&lt;BR /&gt;realloc-code.f: Error 374 : Dummy argument A of procedure REALLOC must not be ALLOCATABLE&lt;BR /&gt;&lt;BR /&gt;3 Errors&lt;BR /&gt;compilation aborted for realloc-code.f (code 1)&lt;BR /&gt;--------------------------------------&lt;BR /&gt;&lt;BR /&gt;We are interpreting this to mean that since A is in the argument list, it may not be allocatable in the subroutine.&lt;BR /&gt;&lt;BR /&gt;The questions are:&lt;BR /&gt;&lt;BR /&gt;1. Are we interpreting the problem correctly and an upgrade will allow us to reallocate data structures in a subroutines after being passed through the argument list?&lt;BR /&gt;&lt;BR /&gt;2. With the latest version will we be able to perform reallocation on structures in COMMON?&lt;BR /&gt;&lt;BR /&gt;3. With the latest version is the above method the best way to reallocate data structures?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Greg</description>
      <pubDate>Tue, 31 Jan 2006 23:30:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762854#M18337</guid>
      <dc:creator>gjm</dc:creator>
      <dc:date>2006-01-31T23:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reallocation vs. Compiler Version Question</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762855#M18338</link>
      <description>&lt;P&gt;Message Edited by tim18 on &lt;SPAN class="date_text"&gt;01-31-2006&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;09:52 AM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2006 00:34:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762855#M18338</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2006-02-01T00:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reallocation vs. Compiler Version Question</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762856#M18339</link>
      <description>&lt;I&gt;1. Are we interpreting the problem correctly and an upgrade will allow us to reallocate data structures in a subroutines after being passed through the argument list?&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;Yes. This is an extension to F95, called TR15581 (aka "allocatable TR"), and incorporated in the new Fortran 2003 standard. It is supported since IVF8 and CVF6.6 (I think), but not in IFC 7.&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;2. With the latest version will we be able to perform reallocation on structures in COMMON?&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;Hmm? As far as I know, COMMON and ALLOCATABLE attributes have always been (and will be) incompatible. COMMON implies static storage, and ALLOCATABLE is dynamic by definition. A POINTER variable may be in COMMON, but not with the "obvious" semantics -- it "equivalences" the pointer(s) rather than their targets.&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;3. With the latest version is the above method the best way to reallocate data structures?&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;Yes, more or less. In F2003, there is new, more efficient, MOVE_ALLOC intrinsic, but not yet implemented in VF. I once "cooked my own" and posted it in this Forum, but a) it's a low-level non-portable tweak b) I'm not sure if I got the syntax and semantics right. I can dig out the reference if you want.</description>
      <pubDate>Wed, 01 Feb 2006 00:40:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762856#M18339</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2006-02-01T00:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Reallocation vs. Compiler Version Question</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762857#M18340</link>
      <description>Ah, sorry, I overlooked the lack of explicit interface. Was TR15581 incorporated in IFC 7.1, then?</description>
      <pubDate>Wed, 01 Feb 2006 00:41:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762857#M18340</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2006-02-01T00:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reallocation vs. Compiler Version Question</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762858#M18341</link>
      <description>No.</description>
      <pubDate>Wed, 01 Feb 2006 01:57:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762858#M18341</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2006-02-01T01:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reallocation vs. Compiler Version Question</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762859#M18342</link>
      <description>&lt;P&gt;The following code is an approach taken from Numerical Recipies - maybe it will work with IVF Version 7 - Edmund&lt;/P&gt;
&lt;P&gt;! NRTYPE.F90&lt;BR /&gt;MODULE nrtype&lt;BR /&gt; INTEGER, PARAMETER :: I4B = SELECTED_INT_KIND(9)&lt;BR /&gt; INTEGER, PARAMETER :: I2B = SELECTED_INT_KIND(4)&lt;BR /&gt; INTEGER, PARAMETER :: I1B = SELECTED_INT_KIND(2)&lt;BR /&gt; INTEGER, PARAMETER :: SP = KIND(1.0)&lt;BR /&gt; INTEGER, PARAMETER :: DP = KIND(1.0D0)&lt;BR /&gt; INTEGER, PARAMETER :: SPC = KIND((1.0,1.0))&lt;BR /&gt; INTEGER, PARAMETER :: DPC = KIND((1.0D0,1.0D0))&lt;BR /&gt; INTEGER, PARAMETER :: LGT = KIND(.true.)&lt;BR /&gt; REAL(SP), PARAMETER :: PI=3.141592653589793238462643383279502884197_sp&lt;BR /&gt; REAL(SP), PARAMETER :: PIO2=1.57079632679489661923132169163975144209858_sp&lt;BR /&gt; REAL(SP), PARAMETER :: TWOPI=6.283185307179586476925286766559005768394_sp&lt;BR /&gt; REAL(SP), PARAMETER :: SQRT2=1.41421356237309504880168872420969807856967_sp&lt;BR /&gt; REAL(SP), PARAMETER :: EULER=0.5772156649015328606065120900824024310422_sp&lt;BR /&gt; REAL(DP), PARAMETER :: PI_D=3.141592653589793238462643383279502884197_dp&lt;BR /&gt; REAL(DP), PARAMETER :: PIO2_D=1.57079632679489661923132169163975144209858_dp&lt;BR /&gt; REAL(DP), PARAMETER :: TWOPI_D=6.283185307179586476925286766559005768394_dp&lt;BR /&gt; TYPE sprs2_sp&lt;BR /&gt; INTEGER(I4B) :: n,len&lt;BR /&gt; REAL(SP), DIMENSION(:), POINTER :: val&lt;BR /&gt; INTEGER(I4B), DIMENSION(:), POINTER :: irow&lt;BR /&gt; INTEGER(I4B), DIMENSION(:), POINTER :: jcol&lt;BR /&gt; END TYPE sprs2_sp&lt;/P&gt;
&lt;P&gt; TYPE sprs2_dp&lt;BR /&gt; INTEGER(I4B) :: n,len&lt;BR /&gt; REAL(DP), DIMENSION(:), POINTER :: val&lt;BR /&gt; INTEGER(I4B), DIMENSION(:), POINTER :: irow&lt;BR /&gt; INTEGER(I4B), DIMENSION(:), POINTER :: jcol&lt;BR /&gt; END TYPE sprs2_dp&lt;BR /&gt;END MODULE nrtype&lt;BR /&gt;! NRUTIL.F90&lt;BR /&gt;MODULE nrutil&lt;BR /&gt; USE nrtype&lt;BR /&gt; IMPLICIT NONE&lt;BR /&gt; INTERFACE reallocate&lt;/P&gt;
&lt;P&gt; MODULE PROCEDURE reallocate_rv,reallocate_rm,&amp;amp;&lt;BR /&gt; reallocate_iv,reallocate_im,reallocate_hv&lt;BR /&gt; END INTERFACE&lt;BR /&gt;CONTAINS&lt;BR /&gt;!BL&lt;BR /&gt; SUBROUTINE nrerror(string)&lt;/P&gt;
&lt;P&gt; CHARACTER(LEN=*), INTENT(IN) :: string&lt;BR /&gt; write (*,*) 'nrerror: ',string&lt;BR /&gt; STOP 'program terminated by nrerror'&lt;BR /&gt; END SUBROUTINE nrerror&lt;BR /&gt;!BL&lt;BR /&gt; FUNCTION reallocate_rv(p,n)&lt;BR /&gt; REAL(SP), DIMENSION(:), POINTER :: p, reallocate_rv&lt;BR /&gt; INTEGER(I4B), INTENT(IN) :: n&lt;BR /&gt; INTEGER(I4B) :: nold,ierr&lt;BR /&gt; allocate(reallocate_rv(n),stat=ierr)&lt;BR /&gt; if (ierr /= 0) call &amp;amp;&lt;BR /&gt; nrerror('reallocate_rv: problem in attempt to allocate memory')&lt;BR /&gt; if (.not. associated(p)) RETURN&lt;BR /&gt; nold=size(p)&lt;BR /&gt; reallocate_rv(1:min(nold,n))=p(1:min(nold,n))&lt;BR /&gt; deallocate(p)&lt;BR /&gt; END FUNCTION reallocate_rv&lt;BR /&gt;!BL&lt;BR /&gt; FUNCTION reallocate_iv(p,n)&lt;BR /&gt; INTEGER(I4B), DIMENSION(:), POINTER :: p, reallocate_iv&lt;BR /&gt; INTEGER(I4B), INTENT(IN) :: n&lt;BR /&gt; INTEGER(I4B) :: nold,ierr&lt;BR /&gt; allocate(reallocate_iv(n),stat=ierr)&lt;BR /&gt; if (ierr /= 0) call &amp;amp;&lt;BR /&gt; nrerror('reallocate_iv: problem in attempt to allocate memory')&lt;/P&gt;
&lt;P&gt; if (.not. associated(p)) RETURN&lt;BR /&gt; nold=size(p)&lt;BR /&gt; reallocate_iv(1:min(nold,n))=p(1:min(nold,n))&lt;BR /&gt; deallocate(p)&lt;BR /&gt; END FUNCTION reallocate_iv&lt;BR /&gt;!BL&lt;BR /&gt; FUNCTION realloca
te_hv(p,n)&lt;BR /&gt; CHARACTER(1), DIMENSION(:), POINTER :: p, reallocate_hv&lt;BR /&gt; INTEGER(I4B), INTENT(IN) :: n&lt;BR /&gt; INTEGER(I4B) :: nold,ierr&lt;BR /&gt; allocate(reallocate_hv(n),stat=ierr)&lt;BR /&gt; if (ierr /= 0) call &amp;amp;&lt;BR /&gt; nrerror('reallocate_hv: problem in attempt to allocate memory')&lt;BR /&gt; if (.not. associated(p)) RETURN&lt;BR /&gt; nold=size(p)&lt;BR /&gt; reallocate_hv(1:min(nold,n))=p(1:min(nold,n))&lt;BR /&gt; deallocate(p)&lt;BR /&gt; END FUNCTION reallocate_hv&lt;BR /&gt;!BL&lt;BR /&gt; FUNCTION reallocate_rm(p,n,m)&lt;BR /&gt; REAL(SP), DIMENSION(:,:), POINTER :: p, reallocate_rm&lt;BR /&gt; INTEGER(I4B), INTENT(IN) :: n,m&lt;BR /&gt; INTEGER(I4B) :: nold,mold,ierr&lt;BR /&gt; allocate(reallocate_rm(n,m),stat=ierr)&lt;BR /&gt; if (ierr /= 0) call &amp;amp;&lt;BR /&gt; nrerror('reallocate_rm: problem in attempt to allocate memory')&lt;BR /&gt; if (.not. associated(p)) RETURN&lt;BR /&gt; nold=size(p,1)&lt;BR /&gt; mold=size(p,2)&lt;BR /&gt; reallocate_rm(1:min(nold,n),1:min(mold,m))=&amp;amp;&lt;BR /&gt; p(1:min(nold,n),1:min(mold,m))&lt;BR /&gt; deallocate(p)&lt;/P&gt;
&lt;P&gt; END FUNCTION reallocate_rm&lt;BR /&gt;!BL&lt;BR /&gt; FUNCTION reallocate_im(p,n,m)&lt;BR /&gt; INTEGER(I4B), DIMENSION(:,:), POINTER :: p, reallocate_im&lt;BR /&gt; INTEGER(I4B), INTENT(IN) :: n,m&lt;BR /&gt; INTEGER(I4B) :: nold,mold,ierr&lt;BR /&gt; allocate(reallocate_im(n,m),stat=ierr)&lt;BR /&gt; if (ierr /= 0) call &amp;amp;&lt;BR /&gt; nrerror('reallocate_im: problem in attempt to allocate memory')&lt;BR /&gt; if (.not. associated(p)) RETURN&lt;BR /&gt; nold=size(p,1)&lt;BR /&gt; mold=size(p,2)&lt;BR /&gt; reallocate_im(1:min(nold,n),1:min(mold,m))=&amp;amp;&lt;BR /&gt; p(1:min(nold,n),1:min(mold,m))&lt;BR /&gt; deallocate(p)&lt;BR /&gt; END FUNCTION reallocate_im&lt;BR /&gt;!BL&lt;BR /&gt;END MODULE nrutil&lt;BR /&gt;!BL&lt;BR /&gt; program Realloc&lt;BR /&gt; USE nrtype; USE nrutil&lt;BR /&gt; IMPLICIT NONE&lt;BR /&gt; REAL(SP), DIMENSION(:), POINTER :: x&lt;BR /&gt; INTEGER(I4B) :: i&lt;BR /&gt; allocate(x(10))&lt;BR /&gt; forall(i=1:ubound(x,1)) x(i)=i&lt;BR /&gt; write(*,"(10F6.2)") x&lt;BR /&gt; x =&amp;gt; reallocate(x,20)&lt;BR /&gt; forall(i=1:ubound(x,1)) x(i)=2*i&lt;BR /&gt; write(*,"(20F6.2)") x&lt;BR /&gt; end program Realloc&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2006 03:12:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Reallocation-vs-Compiler-Version-Question/m-p/762859#M18342</guid>
      <dc:creator>edmund-dunlop</dc:creator>
      <dc:date>2006-02-01T03:12:33Z</dc:date>
    </item>
  </channel>
</rss>

