<?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 extended derived data type in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/allocatable-extended-derived-data-type/m-p/963574#M95192</link>
    <description>&lt;P&gt;I am coding a program with allocatable derived datatype like the following code.&lt;/P&gt;
&lt;P&gt;my problem is that after allocating test_array using type child, the data is not well allocated. It turns out that the allocated test_array only has integer A, without integer B.&lt;/P&gt;
&lt;P&gt;Are there any way to allocate such an array test_array with all data from parent and child data type?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;program&lt;/STRONG&gt; test&lt;BR /&gt;&lt;STRONG&gt;use&lt;/STRONG&gt; p_c&lt;BR /&gt;&lt;STRONG&gt;call&lt;/STRONG&gt; data_allocator&lt;BR /&gt;&lt;STRONG&gt;!write&lt;/STRONG&gt;(*,*) test_array(2)%B&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;module&lt;/STRONG&gt; p_c&lt;BR /&gt;&lt;STRONG&gt;type,abstract,public&lt;/STRONG&gt;::parent&lt;BR /&gt; &lt;STRONG&gt;integer&lt;/STRONG&gt;::A=1&lt;BR /&gt;&lt;STRONG&gt;end type&lt;/STRONG&gt; parent&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;type,extends&lt;/STRONG&gt;(parent)::child&lt;BR /&gt; &lt;STRONG&gt;integer&lt;/STRONG&gt;::B=2&lt;BR /&gt;&lt;STRONG&gt;end type&lt;/STRONG&gt; child&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;class&lt;/STRONG&gt;(parent),&lt;STRONG&gt;allocatable&lt;/STRONG&gt;,&lt;STRONG&gt;dimension&lt;/STRONG&gt;(:)::test_array&lt;BR /&gt;&lt;STRONG&gt;contains&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;subroutine&lt;/STRONG&gt; data_allocator&lt;BR /&gt;&lt;STRONG&gt;allocate&lt;/STRONG&gt;(child::test_array(5))&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;end subroutine&lt;/STRONG&gt; data_allocator&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;end module&lt;/STRONG&gt; p_c&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;end program&lt;/STRONG&gt; test&lt;/P&gt;</description>
    <pubDate>Wed, 23 Oct 2013 16:37:11 GMT</pubDate>
    <dc:creator>wang__shihao</dc:creator>
    <dc:date>2013-10-23T16:37:11Z</dc:date>
    <item>
      <title>allocatable extended derived data type</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/allocatable-extended-derived-data-type/m-p/963574#M95192</link>
      <description>&lt;P&gt;I am coding a program with allocatable derived datatype like the following code.&lt;/P&gt;
&lt;P&gt;my problem is that after allocating test_array using type child, the data is not well allocated. It turns out that the allocated test_array only has integer A, without integer B.&lt;/P&gt;
&lt;P&gt;Are there any way to allocate such an array test_array with all data from parent and child data type?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;program&lt;/STRONG&gt; test&lt;BR /&gt;&lt;STRONG&gt;use&lt;/STRONG&gt; p_c&lt;BR /&gt;&lt;STRONG&gt;call&lt;/STRONG&gt; data_allocator&lt;BR /&gt;&lt;STRONG&gt;!write&lt;/STRONG&gt;(*,*) test_array(2)%B&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;module&lt;/STRONG&gt; p_c&lt;BR /&gt;&lt;STRONG&gt;type,abstract,public&lt;/STRONG&gt;::parent&lt;BR /&gt; &lt;STRONG&gt;integer&lt;/STRONG&gt;::A=1&lt;BR /&gt;&lt;STRONG&gt;end type&lt;/STRONG&gt; parent&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;type,extends&lt;/STRONG&gt;(parent)::child&lt;BR /&gt; &lt;STRONG&gt;integer&lt;/STRONG&gt;::B=2&lt;BR /&gt;&lt;STRONG&gt;end type&lt;/STRONG&gt; child&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;class&lt;/STRONG&gt;(parent),&lt;STRONG&gt;allocatable&lt;/STRONG&gt;,&lt;STRONG&gt;dimension&lt;/STRONG&gt;(:)::test_array&lt;BR /&gt;&lt;STRONG&gt;contains&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;subroutine&lt;/STRONG&gt; data_allocator&lt;BR /&gt;&lt;STRONG&gt;allocate&lt;/STRONG&gt;(child::test_array(5))&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;end subroutine&lt;/STRONG&gt; data_allocator&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;end module&lt;/STRONG&gt; p_c&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;end program&lt;/STRONG&gt; test&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2013 16:37:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/allocatable-extended-derived-data-type/m-p/963574#M95192</guid>
      <dc:creator>wang__shihao</dc:creator>
      <dc:date>2013-10-23T16:37:11Z</dc:date>
    </item>
    <item>
      <title>It does work, but your</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/allocatable-extended-derived-data-type/m-p/963575#M95193</link>
      <description>&lt;P&gt;It does work, but your program isn't correct in how it sees it. In the commented out WRITE, the compiler uses the "declared type", which is parent, and that doesn't have a B component. You have to do it this way:&lt;/P&gt;
&lt;P&gt;[fortran]&lt;BR /&gt;module p_c&lt;BR /&gt;type,abstract,public::parent&lt;BR /&gt;integer::A=1&lt;BR /&gt;end type parent&lt;BR /&gt;&lt;BR /&gt;type,extends(parent)::child&lt;BR /&gt;integer::B=2&lt;BR /&gt;end type child&lt;BR /&gt;&lt;BR /&gt;class(parent),allocatable,dimension(:)::test_array&lt;BR /&gt;contains&lt;BR /&gt;&lt;BR /&gt;subroutine data_allocator&lt;BR /&gt;allocate(child::test_array(5))&lt;BR /&gt;&lt;BR /&gt;end subroutine data_allocator&lt;BR /&gt;&lt;BR /&gt;end module p_c&lt;BR /&gt;program test&lt;BR /&gt;use p_c&lt;BR /&gt;call data_allocator&lt;BR /&gt;select type(test_array)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; type is (child)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; write(*,*) test_array(2)%B&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; class default&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; write (*,*) "Oops!"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end select&lt;BR /&gt;&lt;BR /&gt;end program test&lt;BR /&gt;[/fortran]&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2013 18:34:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/allocatable-extended-derived-data-type/m-p/963575#M95193</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-10-23T18:34:24Z</dc:date>
    </item>
    <item>
      <title>thank you, Steve!
Shihao</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/allocatable-extended-derived-data-type/m-p/963576#M95194</link>
      <description>&lt;P&gt;thank you, Steve!&lt;/P&gt;
&lt;P&gt;Shihao&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2013 18:42:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/allocatable-extended-derived-data-type/m-p/963576#M95194</guid>
      <dc:creator>wang__shihao</dc:creator>
      <dc:date>2013-10-23T18:42:16Z</dc:date>
    </item>
  </channel>
</rss>

