<?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 Since Fortran pointers in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936690#M89022</link>
    <description>&lt;P&gt;Since Fortran pointers/allocatables contain information about the upper and lower limits of indices, I mainly use them to obtain summation indices. Thus if I pass a pointer, it may look like this:&lt;/P&gt;
&lt;P&gt;SUBROUTINE (a)&lt;/P&gt;
&lt;P&gt;INTEGER, POINTER, DIMENSION(:) :: a&lt;/P&gt;
&lt;P&gt;INTEGER :: i&lt;/P&gt;
&lt;P&gt;DO i = LBOUND(a,1), UBOUND(a,1)&lt;/P&gt;
&lt;P&gt;a(i) = ...&lt;/P&gt;
&lt;P&gt;END DO&lt;/P&gt;
&lt;P&gt;END SUBROUTINE&lt;/P&gt;
&lt;P&gt;On the CONTIGUOUS-attribute: I didn't specify it anywhere, but all my arrays are actually contiguous. Does it make sense to explicitly specify it everywhere? Or will the Compiler know that a pointer array, pointing at an allocated array is contiguous if i specify a contiguous range of indices?&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jul 2013 08:56:03 GMT</pubDate>
    <dc:creator>Dino_R_</dc:creator>
    <dc:date>2013-07-01T08:56:03Z</dc:date>
    <item>
      <title>pointer boundaries</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936683#M89015</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;PROGRAM INDICES&lt;BR /&gt;&amp;nbsp;&amp;nbsp; INTEGER, POINTER, DIMENSION(:) :: a, b&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ALLOCATE(a(0:1))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; a(0) = 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp; a(1) = 2&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; b =&amp;gt; a&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; WRITE(*,*) LBOUND(b,1)&amp;nbsp;&amp;nbsp; !__&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp; WRITE(*,*) UBOUND(b,1)&amp;nbsp;&amp;nbsp; !__ &amp;nbsp; = 1 &lt;BR /&gt;&amp;nbsp;&amp;nbsp; WRITE(*,*)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; b =&amp;gt; a(:)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; WRITE(*,*) LBOUND(b,1)&amp;nbsp;&amp;nbsp;&amp;nbsp; !__&amp;nbsp; = 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp; WRITE(*,*) UBOUND(b,1)&amp;nbsp;&amp;nbsp;&amp;nbsp; !__&amp;nbsp; = 2 &lt;BR /&gt;END PROGRAM INDICES&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Apparently, the boundaries of indices are only kept if I do not specify (:). Though, this makes it impossible for me to work with parts of a large array (e.g. x =&amp;gt; y(:,:,:, j)) since all the indices get shifted to start from 1.&amp;nbsp; Is there any way to have a pointer to a subfield without shifting the boundaries of indices? Or do i have to allocate another array for that?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Dino&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2013 16:56:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936683#M89015</guid>
      <dc:creator>Dino_R_</dc:creator>
      <dc:date>2013-06-27T16:56:20Z</dc:date>
    </item>
    <item>
      <title>If you want b to point to a</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936684#M89016</link>
      <description>&lt;P&gt;If you want b to point to a(ilower:iupper) such that the bounds of b also run from ilower to iupper, the statement you want is&lt;/P&gt;
&lt;P&gt;b(ilower:)=&amp;gt;a(ilower:iupper)&lt;/P&gt;
&lt;P&gt;This form of pointer was not a part of Fortran 90 or Fortran 95; it was introduced in Fortran 2003.&amp;nbsp; I assume that by now it is implemented in ifort.&amp;nbsp; If you have to be compatible with a Fortran compiler that doesn't implement this form of pointer assignment, there is an ugly workaround:&lt;/P&gt;
&lt;P&gt;call my_section_assigner(b,a(jlower:jupper),jlower)&lt;BR /&gt;...&lt;BR /&gt;subroutine my_section_assigner(lhs,rhs,lower)&lt;BR /&gt;integer :: lower&lt;BR /&gt;integer,pointer :: lhs(:)&lt;BR /&gt;integer,target :: rhs(lower:)&lt;BR /&gt;lhs=&amp;gt;rhs&lt;BR /&gt;end subroutine&lt;/P&gt;
&lt;P&gt;The subroutine dummy argument rhs is associated with (i.e., points to) the section of interest, and the subroutine interface gives it our chosen lower bound.&amp;nbsp; Because the pointer assignment is now to a simple name rather than an expression, the lower bound of that name becomes the lower bound of the pointer.&lt;/P&gt;
&lt;P&gt;-Kurt&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2013 22:32:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936684#M89016</guid>
      <dc:creator>Hirchert__Kurt_W</dc:creator>
      <dc:date>2013-06-27T22:32:37Z</dc:date>
    </item>
    <item>
      <title>Dino,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936685#M89017</link>
      <description>&lt;P&gt;Dino,&lt;/P&gt;
&lt;P&gt;Here is an additional example:&lt;/P&gt;
&lt;P&gt;[fortran]&lt;BR /&gt;recursive subroutine CopyToYMM_1D(f, t, s)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; use MOD_ALL&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; real, pointer :: f(:)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; type(TypeYMM), pointer :: t(:)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer :: s&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer :: i&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; real, pointer :: slice(:)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=LBOUND(f, DIM=1),UBOUND(f, DIM=1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t(i).v(s) = f(i)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; slice(LBOUND(f, DIM=1):UBOUND(f, DIM=1)) =&amp;gt;&amp;nbsp; t(LBOUND(f, DIM=1))%v(s::4)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f =&amp;gt; slice&lt;BR /&gt;end subroutine CopyToYMM_1D&lt;BR /&gt;[/fortran]&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 00:06:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936685#M89017</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2013-06-28T00:06:00Z</dc:date>
    </item>
    <item>
      <title>Ah, thanks a lot. This is</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936686#M89018</link>
      <description>&lt;P&gt;Ah, thanks a lot. This is kind of obvious, but I'm still surprised that the default behavior is to start all indices from 1.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 09:23:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936686#M89018</guid>
      <dc:creator>Dino_R_</dc:creator>
      <dc:date>2013-06-28T09:23:19Z</dc:date>
    </item>
    <item>
      <title>It's because you can point to</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936687#M89019</link>
      <description>&lt;P&gt;It's because you can point to an array section, including a discontiguous section. What other choice could be made there? The same rule applies to passing an array to a deferred-shape array dummy argument.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 10:22:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936687#M89019</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-06-28T10:22:50Z</dc:date>
    </item>
    <item>
      <title>And Steve could have added</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936688#M89020</link>
      <description>&lt;P&gt;And Steve could have added that arrays can be declared:&lt;/P&gt;
&lt;P&gt;real :: foo(-123:456)&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 12:30:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936688#M89020</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2013-06-28T12:30:04Z</dc:date>
    </item>
    <item>
      <title>Quote:Dino R. wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936689#M89021</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Dino R. wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Ah, thanks a lot. This is kind of obvious, but I'm still surprised that the default behavior is to start all indices from 1.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;To do otherwise puts a big burden on the compiler that is better suited in the hands of the programmer. &amp;nbsp;Its also the reason I deal with a lot of code that resorts to [fortran]function func(u,v,w,ib,ie,jb,je,kb,ke)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;integer :: ib,ie,jb,je,kb,ke&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;real, dimension(ib:ie) :: u&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;real, dimension(jb,je) :: v&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; real, dimension(kb:ke) :: w&lt;/P&gt;
&lt;P&gt;[/fortran]&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 15:56:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936689#M89021</guid>
      <dc:creator>Casey</dc:creator>
      <dc:date>2013-06-28T15:56:00Z</dc:date>
    </item>
    <item>
      <title>Since Fortran pointers</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936690#M89022</link>
      <description>&lt;P&gt;Since Fortran pointers/allocatables contain information about the upper and lower limits of indices, I mainly use them to obtain summation indices. Thus if I pass a pointer, it may look like this:&lt;/P&gt;
&lt;P&gt;SUBROUTINE (a)&lt;/P&gt;
&lt;P&gt;INTEGER, POINTER, DIMENSION(:) :: a&lt;/P&gt;
&lt;P&gt;INTEGER :: i&lt;/P&gt;
&lt;P&gt;DO i = LBOUND(a,1), UBOUND(a,1)&lt;/P&gt;
&lt;P&gt;a(i) = ...&lt;/P&gt;
&lt;P&gt;END DO&lt;/P&gt;
&lt;P&gt;END SUBROUTINE&lt;/P&gt;
&lt;P&gt;On the CONTIGUOUS-attribute: I didn't specify it anywhere, but all my arrays are actually contiguous. Does it make sense to explicitly specify it everywhere? Or will the Compiler know that a pointer array, pointing at an allocated array is contiguous if i specify a contiguous range of indices?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2013 08:56:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-boundaries/m-p/936690#M89022</guid>
      <dc:creator>Dino_R_</dc:creator>
      <dc:date>2013-07-01T08:56:03Z</dc:date>
    </item>
  </channel>
</rss>

