<?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 Allocatable array already allocated runtime error on calling ty in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocatable-array-already-allocated-runtime-error-on-calling/m-p/774789#M24459</link>
    <description>Do you have a small reproducer for this? That would help a lot.&lt;BR /&gt;(off the top of my head) If there is an assignment in the subroutine, then try -assume realloc_lhs . That will deallocate and reallocate (to correct size) an allocatable.</description>
    <pubDate>Wed, 18 Jul 2012 12:18:11 GMT</pubDate>
    <dc:creator>Udit_P_Intel</dc:creator>
    <dc:date>2012-07-18T12:18:11Z</dc:date>
    <item>
      <title>Allocatable array already allocated runtime error on calling type bound procedure</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocatable-array-already-allocated-runtime-error-on-calling/m-p/774788#M24458</link>
      <description>I have a pointer to a user defined type within another user defined type. When I call a subroutine belonging to the pointer , I get an allocatable array already allocated error. Any clue? This is completely non-intuitive, the pointer is associated and all the fields have been properly initialized. &lt;BR /&gt;&lt;BR /&gt;This is roughly the structure of the code. &lt;BR /&gt;&lt;PRE&gt;&lt;CODE&gt;ype B
   type(A),pointer :: obj
 contains
    procedure :: do_something
 end type B
type A 
    integer,allocatable:: long_array(:) 
  contains
    procedure :: do_something_to_long_array
end type A

 program main
  type(B) :: obj1
  type(A) ,target :: obj2

  allocate(obj2%long_array(10))
  obj1%obj=&amp;gt;obj2
  call obj1%obj%do_something_to_long_array()
 end program main&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;The runtime error happens at the final subroutine call. There is no allocation within the subroutine. it just reads a fixed number of values into a smaller array for use. &lt;BR /&gt;&lt;BR /&gt; 

&lt;PRE&gt;&lt;CODE&gt; 

 module test
      type A
      type(B),pointer :: bpoint=&amp;gt;null()
      contains
      procedure :: test_point
      end type A

      type B
      integer,allocatable :: long_array(:)
      contains
      procedure :: read_section_of_long_array
      end type B
      contains
      subroutine test_point(this)

      class(A) :: this
      integer :: a(3)
      call this%bpoint%read_section_of_long_array(a,3)
      write(*,*) a
      end subroutine test_point

      subroutine read_section_of_long_array(this,a)
      class(B) :: this
      integer:: a(:)
      integer ::l,i
      l = shape(a)
      write(*,*) shape(a),shape(this%long_array)
      do i=1,l
         write(*,*) i
         write(*,*)  this%long_array(i)
         a(i) = this%long_array(i)
      end do

     end subroutine read_section_of_long_array
     end module test
 
     program main
     use test

     type(A) :: aobj
     type(B),target :: bobj
     integer :: i


     allocate(bobj%long_array(10))

     do i=1,10
        bobj%long_array(i) = i+1
        write(*,*) bobj%long_array(i)
     end do
     write(*,*) "here"

     nullify(aobj%bpoint)
     aobj%bpoint=&amp;gt; bobj

     write(*,*) "here"
     call aobj%test_point() 
     end program main
&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;


This approximates what I am trying to do. but this gives me a segmentation fault. I can't see why as no unallocated memory is being accessed.</description>
      <pubDate>Wed, 18 Jul 2012 09:11:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocatable-array-already-allocated-runtime-error-on-calling/m-p/774788#M24458</guid>
      <dc:creator>potaman</dc:creator>
      <dc:date>2012-07-18T09:11:02Z</dc:date>
    </item>
    <item>
      <title>Allocatable array already allocated runtime error on calling ty</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocatable-array-already-allocated-runtime-error-on-calling/m-p/774789#M24459</link>
      <description>Do you have a small reproducer for this? That would help a lot.&lt;BR /&gt;(off the top of my head) If there is an assignment in the subroutine, then try -assume realloc_lhs . That will deallocate and reallocate (to correct size) an allocatable.</description>
      <pubDate>Wed, 18 Jul 2012 12:18:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Allocatable-array-already-allocated-runtime-error-on-calling/m-p/774789#M24459</guid>
      <dc:creator>Udit_P_Intel</dc:creator>
      <dc:date>2012-07-18T12:18:11Z</dc:date>
    </item>
  </channel>
</rss>

