<?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 User-Defined Types and Strange Behavior in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/ALLOCATABLE-User-Defined-Types-and-Strange-Behavior/m-p/985484#M27034</link>
    <description>I have something similar to following code: &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
--- type.f90 --- 
MODULE MTYPE 
TYPE NEWTYPE 
  INTEGER, ALLOCATABLE :: N(:) 
END TYPE 
END MODULE 
 
--- subrt.f90 --- 
MODULE MSUBS 
CONTAINS 
SUBROUTINE SETUP(a) 
  TYPE(NEWTYPE), INTENT(OUT) :: a 
  ALLOCATE(a%n(1000)) 
  a%n = 0 
END SUBROUTINE 
END MODULE 
 
--- main.f90 --- 
PROGRAM TEST 
USE MTYPE 
TYPE(NEWTYPE) :: a 
CALL SETUP(a) 
END PROGRAM 
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;When I run this program, it works fine until I return from the subroutine. When that happens, the array I allocated in the subroutine contains random values. Does the ALLOCATE command have scope in this case? i.e. Do I have to allocate in the outermost program unit or can I allocate in a subroutine like this? &lt;BR /&gt; &lt;BR /&gt;Thank you, &lt;BR /&gt;Michael Carr</description>
    <pubDate>Tue, 05 Mar 2002 09:11:23 GMT</pubDate>
    <dc:creator>michael-a-carr</dc:creator>
    <dc:date>2002-03-05T09:11:23Z</dc:date>
    <item>
      <title>ALLOCATABLE User-Defined Types and Strange Behavior</title>
      <link>https://community.intel.com/t5/Software-Archive/ALLOCATABLE-User-Defined-Types-and-Strange-Behavior/m-p/985484#M27034</link>
      <description>I have something similar to following code: &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
--- type.f90 --- 
MODULE MTYPE 
TYPE NEWTYPE 
  INTEGER, ALLOCATABLE :: N(:) 
END TYPE 
END MODULE 
 
--- subrt.f90 --- 
MODULE MSUBS 
CONTAINS 
SUBROUTINE SETUP(a) 
  TYPE(NEWTYPE), INTENT(OUT) :: a 
  ALLOCATE(a%n(1000)) 
  a%n = 0 
END SUBROUTINE 
END MODULE 
 
--- main.f90 --- 
PROGRAM TEST 
USE MTYPE 
TYPE(NEWTYPE) :: a 
CALL SETUP(a) 
END PROGRAM 
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;When I run this program, it works fine until I return from the subroutine. When that happens, the array I allocated in the subroutine contains random values. Does the ALLOCATE command have scope in this case? i.e. Do I have to allocate in the outermost program unit or can I allocate in a subroutine like this? &lt;BR /&gt; &lt;BR /&gt;Thank you, &lt;BR /&gt;Michael Carr</description>
      <pubDate>Tue, 05 Mar 2002 09:11:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/ALLOCATABLE-User-Defined-Types-and-Strange-Behavior/m-p/985484#M27034</guid>
      <dc:creator>michael-a-carr</dc:creator>
      <dc:date>2002-03-05T09:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: ALLOCATABLE User-Defined Types and Strange Behavior</title>
      <link>https://community.intel.com/t5/Software-Archive/ALLOCATABLE-User-Defined-Types-and-Strange-Behavior/m-p/985485#M27035</link>
      <description>After inserting the line USE MTYPE in module MSUBS and USE MSUBS in program TEST so that the above compiles, it looks like the first few elements of a%n are incorrect.  Compaq just put this allocatable components stuff in their compiler and they don't have all the kinks worked out yet.  You should send them a bug report when you see misbehavior like this.  Probably the above would work if you used the F95-compatible method of a pointer component rather than an allocatable component.</description>
      <pubDate>Tue, 05 Mar 2002 10:51:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/ALLOCATABLE-User-Defined-Types-and-Strange-Behavior/m-p/985485#M27035</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2002-03-05T10:51:23Z</dc:date>
    </item>
  </channel>
</rss>

