<?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 Array indices start in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888427#M77495</link>
    <description>Dear all.&lt;BR /&gt;&lt;BR /&gt;I have a question about the index numbering of arrays in Fortran. Consider this small code example:&lt;BR /&gt;&lt;BR /&gt;module IndexModule&lt;BR /&gt;contains&lt;BR /&gt;subroutine Asub(A)&lt;BR /&gt; integer, allocatable :: A(:)&lt;BR /&gt; allocate(A(3))&lt;BR /&gt; A(1) = 1 ; A(2) = 2 ; A(3) = 3&lt;BR /&gt;end subroutine Asub&lt;BR /&gt;end module IndexModule&lt;BR /&gt;&lt;BR /&gt;program IndexTest&lt;BR /&gt; use IndexModule&lt;BR /&gt; implicit none&lt;BR /&gt; integer, allocatable :: A(:)&lt;BR /&gt;&lt;BR /&gt; call Asub(A)&lt;BR /&gt;&lt;BR /&gt; !write(*,*) A(1), A(2), A(3)&lt;BR /&gt; write(*,*) A(0), A(1), A(2)&lt;BR /&gt;end program IndexTest&lt;BR /&gt;&lt;BR /&gt;When I compile and run the program as it is shown it runs fine. But if I uncomment the commented write line I get and array bounds exceeded error. A closer incpection in the debugger reveals what is wrong. When A is allocated in the subroutine it has indices 1, 2, 3, as expected. But when it is returned to the mail program it has indices 0, 1, 2. Why is that? It should be mentioned that I use CVF 6.6 (with Windows XP) but plan to migrate to IVF in the near future. This behaviour has caused some nuicances in my programs, as I then have to check the lower bounds of my subroutine-generated arrays using lbound. Am I doing anything wrong?&lt;BR /&gt;&lt;BR /&gt;Best regards, j_clausen</description>
    <pubDate>Thu, 04 Jun 2009 07:23:08 GMT</pubDate>
    <dc:creator>j_clausen</dc:creator>
    <dc:date>2009-06-04T07:23:08Z</dc:date>
    <item>
      <title>Array indices start</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888427#M77495</link>
      <description>Dear all.&lt;BR /&gt;&lt;BR /&gt;I have a question about the index numbering of arrays in Fortran. Consider this small code example:&lt;BR /&gt;&lt;BR /&gt;module IndexModule&lt;BR /&gt;contains&lt;BR /&gt;subroutine Asub(A)&lt;BR /&gt; integer, allocatable :: A(:)&lt;BR /&gt; allocate(A(3))&lt;BR /&gt; A(1) = 1 ; A(2) = 2 ; A(3) = 3&lt;BR /&gt;end subroutine Asub&lt;BR /&gt;end module IndexModule&lt;BR /&gt;&lt;BR /&gt;program IndexTest&lt;BR /&gt; use IndexModule&lt;BR /&gt; implicit none&lt;BR /&gt; integer, allocatable :: A(:)&lt;BR /&gt;&lt;BR /&gt; call Asub(A)&lt;BR /&gt;&lt;BR /&gt; !write(*,*) A(1), A(2), A(3)&lt;BR /&gt; write(*,*) A(0), A(1), A(2)&lt;BR /&gt;end program IndexTest&lt;BR /&gt;&lt;BR /&gt;When I compile and run the program as it is shown it runs fine. But if I uncomment the commented write line I get and array bounds exceeded error. A closer incpection in the debugger reveals what is wrong. When A is allocated in the subroutine it has indices 1, 2, 3, as expected. But when it is returned to the mail program it has indices 0, 1, 2. Why is that? It should be mentioned that I use CVF 6.6 (with Windows XP) but plan to migrate to IVF in the near future. This behaviour has caused some nuicances in my programs, as I then have to check the lower bounds of my subroutine-generated arrays using lbound. Am I doing anything wrong?&lt;BR /&gt;&lt;BR /&gt;Best regards, j_clausen</description>
      <pubDate>Thu, 04 Jun 2009 07:23:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888427#M77495</guid>
      <dc:creator>j_clausen</dc:creator>
      <dc:date>2009-06-04T07:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Array indices start</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888428#M77496</link>
      <description>&lt;DIV style="margin:0px;"&gt;In IVF, for your code, the array has values in elements 1, 2 and 3 as expected. A run-time error is then flagged forWRITE A(0).&lt;BR /&gt;&lt;BR /&gt;David&lt;/DIV&gt;
&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jun 2009 08:04:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888428#M77496</guid>
      <dc:creator>DavidWhite</dc:creator>
      <dc:date>2009-06-04T08:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Array indices start</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888429#M77497</link>
      <description>CVF had an early implementation of this feature (&lt;A href="http://www.nag.co.uk/nagware/np/doc/TR.asp"&gt;TR15581&lt;/A&gt;) and it was rather buggy. I heartily recommend upgrading to IVF, especially if you plan on using newer language features. &lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jun 2009 08:40:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888429#M77497</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2009-06-04T08:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Array indices start</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888430#M77498</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Thank you both&lt;BR /&gt;&lt;BR /&gt;That's what I like to hear, i.e. that this is not a general Fortran issue. This will make the code in IVF much prettier than that of CVF.&lt;BR /&gt;&lt;BR /&gt;j_clausen&lt;/DIV&gt;</description>
      <pubDate>Thu, 04 Jun 2009 09:04:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888430#M77498</guid>
      <dc:creator>j_clausen</dc:creator>
      <dc:date>2009-06-04T09:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: Array indices start</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888431#M77499</link>
      <description>&lt;P&gt;I have now migrated to Intel Visual Fortran and the problem in my initial post has vanished, as mentioned by David. This leads me to a question: Does the standard say anything about the indexing conventions? I.e. does Compaq Fortran comply with the Fortran 95 standard, even though the code sample shown initiallydon't work?&lt;/P&gt;
&lt;P&gt;j_clausen&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2010 07:19:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888431#M77499</guid>
      <dc:creator>j_clausen</dc:creator>
      <dc:date>2010-02-23T07:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Array indices start</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888432#M77500</link>
      <description>&lt;P&gt;Well, the Compaq Fortran had a bug in its implementation, so it does not quite make sense to consider it within the framework on the Standard.&lt;/P&gt;
&lt;P&gt;The question "does the standard say anything about the indexing conventions" is too broad to be succinctly answered. The standard says quite a bit about "indexing conventions", because they have to be uniform across platforms, so that you can produce portable programs.&lt;/P&gt;
&lt;P&gt;With my mind-reading hat on, I presume that you need the information about what happens when an array is passed to a routine. The short answer is that POINTER and ALLOCATABLE array preserve their bounds across routine boundaries, but assumed-shape dummies get remapped to lower bound of 1:
&lt;PRE&gt;[fortran]integer, target::      I(2:5)
integer, pointer::     P(:)
integer, allocatable:: A(:)

P=&amp;gt;I

call Test(I, P, A)
write(*,*) "I: ", lbound(I), ubound(I) !2,5
write(*,*) "P: ", lbound(P), ubound(P) !2,5
write(*,*) "A: ", lbound(A), ubound(A) !2,5

contains

subroutine Test(I, P, A)
integer, target::      I(:)
integer, pointer::     P(:)
integer, allocatable:: A(:)
write(*,*) "I: ", lbound(I), ubound(I) !1,4
write(*,*) "P: ", lbound(P), ubound(P) !2,5
allocate(A(2:5))
write(*,*) "A: ", lbound(A), ubound(A) !2,5
end subroutine Test
end program 
[/fortran]&lt;/PRE&gt;
&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2010 11:07:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888432#M77500</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2010-02-23T11:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Array indices start</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888433#M77501</link>
      <description>&lt;P&gt;Thank you very much Jugoslav. Your mind-reading hat works perfectly.&lt;/P&gt;
&lt;P&gt;j_clausen&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2010 14:30:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indices-start/m-p/888433#M77501</guid>
      <dc:creator>j_clausen</dc:creator>
      <dc:date>2010-02-23T14:30:20Z</dc:date>
    </item>
  </channel>
</rss>

