<?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 Sure, A is already global, in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151026#M140085</link>
    <description>&lt;P&gt;Sure, A is already global, but does not initialized, I just want dummy argument array1 be global, and the subroutine test will be called by other language.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Mar 2018 16:42:24 GMT</pubDate>
    <dc:creator>Stephen_W_</dc:creator>
    <dc:date>2018-03-09T16:42:24Z</dc:date>
    <item>
      <title>Make intent in array be global</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151023#M140082</link>
      <description>&lt;P&gt;I wonder how to make the array `array1` be global (module) variable, consider following code&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;module data
    implicit none
    real(8), allocatable, dimension(:,:) :: A
end module data

subroutine test(array1, n, m)
    use data
    implicit none
    integer, intent(in) :: n, m
    real(8), intent(in), dimension(n,m) :: array1
    
    allocate(A, source=array1)
    
    do_something
    
end subroutine test&lt;/PRE&gt;

&lt;P&gt;`allocate(A, source=array1)` works but double store the same array, `save` is another method but not satisfied.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 10:53:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151023#M140082</guid>
      <dc:creator>Stephen_W_</dc:creator>
      <dc:date>2018-03-09T10:53:27Z</dc:date>
    </item>
    <item>
      <title>I am not entirely sure what</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151024#M140083</link>
      <description>&lt;P&gt;I am not entirely sure what you want to achieve, but you could define the array A to be a pointer:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;module ..
     real(8), dimension(:,:), pointer :: A
end module

subroutine ...
     real(8), dimension(:,:), target :: array1

     A =&amp;gt; array1

end subroutine&lt;/PRE&gt;

&lt;P&gt;You have only one copy of the array then, but make sure that the array1 remains "alive" as long as you want to use A, while pointing to array1.&lt;/P&gt;

&lt;P&gt;It might be better to move the allocation, via call move_alloc - array1 must be an allocatable array/pointer to an array. That way you transfer the memory to A and you only have to worry about the "aliveness" of A.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 11:01:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151024#M140083</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2018-03-09T11:01:30Z</dc:date>
    </item>
    <item>
      <title>A is already "global" - I too</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151025#M140084</link>
      <description>&lt;P&gt;A is already "global" - I too am not sure what you want to happen differently. As you have it, the allocate of the global array A occurs in the subroutine and the dummy argument array1 is copied into it - that's what source= does. There is no double store. What would you like to happen? Really, you don't need subroutine test at all - the ALLOCATE will do everything.&lt;/P&gt;

&lt;P&gt;Do not use pointers here.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 15:58:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151025#M140084</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2018-03-09T15:58:55Z</dc:date>
    </item>
    <item>
      <title>Sure, A is already global,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151026#M140085</link>
      <description>&lt;P&gt;Sure, A is already global, but does not initialized, I just want dummy argument array1 be global, and the subroutine test will be called by other language.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 16:42:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151026#M140085</guid>
      <dc:creator>Stephen_W_</dc:creator>
      <dc:date>2018-03-09T16:42:24Z</dc:date>
    </item>
    <item>
      <title>Quote:Arjen Markus wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151027#M140086</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Arjen Markus wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;I am not entirely sure what you want to achieve, but you could define the array A to be a pointer:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;module ..
     real(8), dimension(:,:), pointer :: A
end module

subroutine ...
     real(8), dimension(:,:), target :: array1

     A =&amp;gt; array1

end subroutine&lt;/PRE&gt;

&lt;P&gt;You have only one copy of the array then, but make sure that the array1 remains "alive" as long as you want to use A, while pointing to array1.&lt;/P&gt;

&lt;P&gt;It might be better to move the allocation, via call move_alloc - array1 must be an allocatable array/pointer to an array. That way you transfer the memory to A and you only have to worry about the "aliveness" of A.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Many thanks, I have tested the pointer solution, yes, only one copy of the array.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 16:48:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Make-intent-in-array-be-global/m-p/1151027#M140086</guid>
      <dc:creator>Stephen_W_</dc:creator>
      <dc:date>2018-03-09T16:48:00Z</dc:date>
    </item>
  </channel>
</rss>

