<?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 Unallocated array in rhs of assignment in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785700#M29923</link>
    <description>Beyond the scope of your question, if what you wanted to do was to build up the array in pieces, code such as this may be considered:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]program talloc

   integer, allocatable :: array(:)
 
  if(.not.allocated(array))allocate(array(0))

  array = [array, 1, 2]
  array = [array, 3]

  print *, array

end program talloc
[/fortran]&lt;/PRE&gt;</description>
    <pubDate>Mon, 05 Jul 2010 15:52:57 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2010-07-05T15:52:57Z</dc:date>
    <item>
      <title>Unallocated array in rhs of assignment</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785698#M29921</link>
      <description>&lt;P&gt;Hi, is the following code standard conforming?&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;[fortran]integer, allocatable :: array(:)
array = [array, 1, 2]
array = [array, 3]
print *, array
end[/fortran]&lt;/PRE&gt; I mean, does the standard allow an unallocated array to be part of an array expression? Compiling with /stand and /assume:realoc_lhs doesn't issue any warning, and there's no runtime error either.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2010 05:19:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785698#M29921</guid>
      <dc:creator>John4</dc:creator>
      <dc:date>2010-07-05T05:19:41Z</dc:date>
    </item>
    <item>
      <title>Unallocated array in rhs of assignment</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785699#M29922</link>
      <description>With /check:all and 11.1.065 I see an appropriate runtime error. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Jul 2010 06:07:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785699#M29922</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2010-07-05T06:07:40Z</dc:date>
    </item>
    <item>
      <title>Unallocated array in rhs of assignment</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785700#M29923</link>
      <description>Beyond the scope of your question, if what you wanted to do was to build up the array in pieces, code such as this may be considered:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]program talloc

   integer, allocatable :: array(:)
 
  if(.not.allocated(array))allocate(array(0))

  array = [array, 1, 2]
  array = [array, 3]

  print *, array

end program talloc
[/fortran]&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jul 2010 15:52:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785700#M29923</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2010-07-05T15:52:57Z</dc:date>
    </item>
    <item>
      <title>Unallocated array in rhs of assignment</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785701#M29924</link>
      <description>&lt;P&gt;I'm actually trying to avoid having to check the allocation status every time one entry needs to be added. I already have a subroutine that does just that:&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;[fortran]subroutine expand(array, idx, istat)
    integer, allocatable, intent(INOUT) :: array(:)
    integer, intent(OUT) :: idx, istat
    integer, allocatable :: aux(:)
    integer :: sz

continue
    idx = -1

    if (ALLOCATED(array)) then
        sz = SIZE(array)
        call MOVE_ALLOC(array, aux)

        allocate (array(1:sz + 1), STAT = istat)
        if (istat /= 0) then
            call MOVE_ALLOC(aux, array)
            return
        endif

        array(:sz) = aux

        sz = sz + 1
        deallocate (aux, STAT = istat)
    else
        sz = 1
        allocate (array(1), STAT = istat)
        if (istat /= 0) return
    endif

    idx = sz
end subroutine[/fortran]&lt;/PRE&gt; &lt;/P&gt;&lt;P&gt;That's why I &lt;SPAN style="text-decoration: underline;"&gt;only&lt;/SPAN&gt; asked if it was standard conforming. IanH's answer seems to confirm that the code is illegal.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2010 23:17:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785701#M29924</guid>
      <dc:creator>John4</dc:creator>
      <dc:date>2010-07-05T23:17:58Z</dc:date>
    </item>
    <item>
      <title>Unallocated array in rhs of assignment</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785702#M29925</link>
      <description>if (allocated(array)) then&lt;BR /&gt; sz = size(array) +1 ! new size&lt;BR /&gt;allocate(aux(sz), stat=istat)! allocate bigger array&lt;BR /&gt; if (istat == 0) then ! ok ?&lt;BR /&gt; aux(1:sz-1) = array ! then copy old values tobigger array&lt;BR /&gt; aux(sz) = 0 ! initialise new elements&lt;BR /&gt; call move_alloc(aux, array)!"rename" aux as array&lt;BR /&gt; endif&lt;BR /&gt;else&lt;BR /&gt; ...&lt;BR /&gt;endif&lt;BR /&gt;&lt;BR /&gt;only need one move_alloc and don't need a deallocate&lt;BR /&gt;&lt;BR /&gt;Les</description>
      <pubDate>Tue, 06 Jul 2010 08:27:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785702#M29925</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2010-07-06T08:27:40Z</dc:date>
    </item>
    <item>
      <title>Unallocated array in rhs of assignment</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785703#M29926</link>
      <description>&lt;P&gt;If you look carefully, you'll notice that the second MOVE_ALLOC is applied only in case of error (which is highly unlikely). The explicit deallocation of aux is just a precaution (since some compiler flags might affect automatic deallocation).&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2010 11:52:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785703#M29926</guid>
      <dc:creator>John4</dc:creator>
      <dc:date>2010-07-06T11:52:49Z</dc:date>
    </item>
    <item>
      <title>Unallocated array in rhs of assignment</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785704#M29927</link>
      <description>Ah. OK&lt;BR /&gt;&lt;BR /&gt;Les</description>
      <pubDate>Tue, 06 Jul 2010 14:53:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Unallocated-array-in-rhs-of-assignment/m-p/785704#M29927</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2010-07-06T14:53:19Z</dc:date>
    </item>
  </channel>
</rss>

