<?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 It should work the example in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/scope-of-allocatable-arrays-in-modules/m-p/1105953#M127932</link>
    <description>&lt;P&gt;It should work the example below runs fine.&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;module fred
    implicit none
    real, allocatable :: arry(:,:)
    contains
    subroutine bill()
        integer :: istat
        allocate(arry(3,3), stat = istat)
        arry = 0.0
    end subroutine bill
end module fred   

program Console3
    use fred
    implicit none
    integer :: istat
    
    if (allocated( arry ) ) then
        arry=1.0
        arry(1,2) = 2.0
    else
        allocate(arry(3,3), stat = istat)
        arry = 0.0
        arry(3,3) = 3.0
    end if
        
    print *, 'Hello World'
    print *, arry  

end program Console3&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Oct 2016 22:34:27 GMT</pubDate>
    <dc:creator>andrew_4619</dc:creator>
    <dc:date>2016-10-07T22:34:27Z</dc:date>
    <item>
      <title>scope of allocatable arrays in modules</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/scope-of-allocatable-arrays-in-modules/m-p/1105952#M127931</link>
      <description>&lt;P&gt;I have the following structure:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;PROGRAM myPro
USE mMod1
IMPLICIT NONE

REAL t
INTEGER i

CALL proc1

! do something...
! I can access here dt defined in mMod1
! but not myArr1
END PROGRAM myPro&lt;/PRE&gt;

&lt;PRE class="brush:fortran;"&gt;MODULE mMod1
IMPLICIT NONE
REAL dt
REAL, ALLOCATABLE :: myArr1(:,:)


CONTAINS

SUBROUTINE proc1
USE mMod2
CHARACTER(LEN=256) fn
CALL proc2(fn,myArr1)
! I can access here both dt and myArr1
END SUBROUTINE proc1

END MODULE mMod1&lt;/PRE&gt;

&lt;PRE class="brush:fortran;"&gt;MODULE mMod2
IMPLICIT NONE

CONTAINS

SUBROUTINE proc2(fn,myArr1)
CHARACTER(LEN=256), INTENT(IN) :: fn
REAL, ALLOCATABLE :: myArr1(:,:)
INTEGER n
INTEGER, PARAMETER :: dim = 3

! read some input file and determine n

ALLOCATE (myArr1(dim,n))

! fill in the array by reading the rest of the file
END SUBROUTINE proc2

END MODULE mMod2&lt;/PRE&gt;

&lt;P&gt;The question is, the definition of both dt and myArr is the same except that myArr is an allocatable array allocated in a separate module. But I cannot access myArr1 in the main program while I can access dt in the main program. Why? And how to make changes so that I can access it there.&lt;/P&gt;

&lt;P&gt;The whole purpose is: I want to read an input file in a separate subroutine into an array (myArr1) and have this array available globaly. This is why I declare it in mMod1. The dimensions of the array are written at the top of the file so I do not know them until I have started reading the file. So the allocation of the myArr1 has to happen inside the separate procedure, I would include it as a separate procedure but it does not work as probably INTERFACE is necessary, so I decided to wrap the procedure in a separate module.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 22:06:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/scope-of-allocatable-arrays-in-modules/m-p/1105952#M127931</guid>
      <dc:creator>lespo</dc:creator>
      <dc:date>2016-10-07T22:06:35Z</dc:date>
    </item>
    <item>
      <title>It should work the example</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/scope-of-allocatable-arrays-in-modules/m-p/1105953#M127932</link>
      <description>&lt;P&gt;It should work the example below runs fine.&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;module fred
    implicit none
    real, allocatable :: arry(:,:)
    contains
    subroutine bill()
        integer :: istat
        allocate(arry(3,3), stat = istat)
        arry = 0.0
    end subroutine bill
end module fred   

program Console3
    use fred
    implicit none
    integer :: istat
    
    if (allocated( arry ) ) then
        arry=1.0
        arry(1,2) = 2.0
    else
        allocate(arry(3,3), stat = istat)
        arry = 0.0
        arry(3,3) = 3.0
    end if
        
    print *, 'Hello World'
    print *, arry  

end program Console3&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 22:34:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/scope-of-allocatable-arrays-in-modules/m-p/1105953#M127932</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2016-10-07T22:34:27Z</dc:date>
    </item>
    <item>
      <title>Hmm  you may have a problem</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/scope-of-allocatable-arrays-in-modules/m-p/1105954#M127933</link>
      <description>&lt;P&gt;Hmm &amp;nbsp;you may have a problem with DIM =3 which is a parameter which is applied at compile time&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 22:41:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/scope-of-allocatable-arrays-in-modules/m-p/1105954#M127933</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2016-10-07T22:41:14Z</dc:date>
    </item>
  </channel>
</rss>

