<?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 indexing in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903083#M81354</link>
    <description>I know this post is super old but no one really addressed this guys problem (I stumbled across this post while trying to solve another problem of my own).&lt;BR /&gt;&lt;BR /&gt;KEYNR(42,50) has 2100 array slots (42x50=2100). He is trying to initialize all the (i,j) array slots to the value to zero.&lt;BR /&gt;&lt;BR /&gt;The problem is that in the initializing loop he is incrementing the i value from 1 to 2100 and fixing j value at 1, so the array he is attempting to zero has the dimensions KEYNR(1:2100,1). Since he defined the array as KEYNR(1:42,1:50) (by default arrays start as 1 in Fortran unless otherwise specified) the compiler is giving him a out of bounds error when the loop tries to set KEYNR(43,1)=0.&lt;BR /&gt;&lt;BR /&gt;The correct solution is not to turn off bounds checking but to code the proper loop as follows:&lt;BR /&gt;&lt;BR /&gt;DO J=1,42
&lt;BR /&gt;  DO K=1,50&lt;BR /&gt; KEYNR(J,K)=0&lt;BR /&gt; END DO&lt;BR /&gt;END DO&lt;BR /&gt;&lt;BR /&gt;I know this is a simple problem but I figure it's worth posting a solution in case someone new to programming or new to Fortran comes across this post.</description>
    <pubDate>Fri, 20 Jul 2012 16:12:04 GMT</pubDate>
    <dc:creator>Ashley_Weinstein</dc:creator>
    <dc:date>2012-07-20T16:12:04Z</dc:date>
    <item>
      <title>Array indexing</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903078#M81349</link>
      <description>I have an array that is defined like so:
&lt;BR /&gt;
&lt;BR /&gt;      COMMON/KEYS/KEYNR(42,50),KDIAG(12)
&lt;BR /&gt;      CHARACTER*4 CKEYNR(42,50)
&lt;BR /&gt;      EQUIVALENCE (CKEYNR,KEYNR)
&lt;BR /&gt;
&lt;BR /&gt;And used like this:
&lt;BR /&gt;      DO 605 K=1,2100
&lt;BR /&gt;  605 KEYNR(K,1)=0
&lt;BR /&gt;
&lt;BR /&gt;And I'm getting the following error:
&lt;BR /&gt;
&lt;BR /&gt;forrtl: severe error (408): fort: (2): Subscript #1 of the array KEYNR has value 43 which is greater than the upper bound of 42
&lt;BR /&gt;
&lt;BR /&gt;Any suggestions on how to fix this will be appreciated. Note that I, unfortunately, require a compiler-based fix and not a code fix, as this is an ancient 10,000+ line FORTRAN code base, with similar loops throughout, and works right now with 4 other compilers/platforms and I'm pretty sure any code change will introduce issues elsewhere.
&lt;BR /&gt;
&lt;BR /&gt;Thanks,
&lt;BR /&gt;
&lt;BR /&gt;   -k.</description>
      <pubDate>Sat, 16 Aug 2008 19:08:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903078#M81349</guid>
      <dc:creator>mankoff</dc:creator>
      <dc:date>2008-08-16T19:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Array indexing</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903079#M81350</link>
      <description>You have not shown the dimensions specified for array KEYNR. What are they? I would guess INTEGER*4 KEYNR(2100,1) would work.</description>
      <pubDate>Sat, 16 Aug 2008 19:13:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903079#M81350</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2008-08-16T19:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Array indexing</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903080#M81351</link>
      <description>Oops sorry. I've edited the post to show that. It is defined like so:
&lt;BR /&gt;
&lt;BR /&gt;      COMMON/KEYS/KEYNR(42,50),KDIAG(12)
&lt;BR /&gt;
&lt;BR /&gt;</description>
      <pubDate>Sat, 16 Aug 2008 19:33:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903080#M81351</guid>
      <dc:creator>mankoff</dc:creator>
      <dc:date>2008-08-16T19:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: Array indexing</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903081#M81352</link>
      <description>&lt;P&gt;I could be wrong but it looks like you need either another equivilance with the one-dimensional intepretation or you need to turn off array bounds checking.&lt;/P&gt;
&lt;P&gt;The newer compilers are fairly intollerant of code that does not conform to the standards. One good reason to indulge the compiler in its intollerance is that nonconforming code may disable optimization.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Aug 2008 13:38:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903081#M81352</guid>
      <dc:creator>Steve_Nuchia</dc:creator>
      <dc:date>2008-08-19T13:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Array indexing</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903082#M81353</link>
      <description>&lt;P&gt;In the example you've shown, it will work ok if you turn off array bounds checking.&lt;/P&gt;
&lt;P&gt;The code is counting on the way that arrays are laid out in memory. In memory the array elements are laid out like this:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;KEYNR(1,1)&lt;/P&gt;
&lt;P&gt;KEYNR(2,1)&lt;/P&gt;
&lt;P&gt;KEYNR(3,1)&lt;/P&gt;
&lt;P&gt;so by writing the loop like it is, the code is setting 2100 consecutive words to 0, all of which are part of the&lt;/P&gt;
&lt;P&gt;KEYNR array. This is the sort of "clever" programming you sometimes run into in old code where speed was&lt;/P&gt;
&lt;P&gt;more important than clarity. &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;In modern Fortran, you could replace this with&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;KEYNR = 0&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Aug 2008 18:31:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903082#M81353</guid>
      <dc:creator>jparsly</dc:creator>
      <dc:date>2008-08-19T18:31:04Z</dc:date>
    </item>
    <item>
      <title>Array indexing</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903083#M81354</link>
      <description>I know this post is super old but no one really addressed this guys problem (I stumbled across this post while trying to solve another problem of my own).&lt;BR /&gt;&lt;BR /&gt;KEYNR(42,50) has 2100 array slots (42x50=2100). He is trying to initialize all the (i,j) array slots to the value to zero.&lt;BR /&gt;&lt;BR /&gt;The problem is that in the initializing loop he is incrementing the i value from 1 to 2100 and fixing j value at 1, so the array he is attempting to zero has the dimensions KEYNR(1:2100,1). Since he defined the array as KEYNR(1:42,1:50) (by default arrays start as 1 in Fortran unless otherwise specified) the compiler is giving him a out of bounds error when the loop tries to set KEYNR(43,1)=0.&lt;BR /&gt;&lt;BR /&gt;The correct solution is not to turn off bounds checking but to code the proper loop as follows:&lt;BR /&gt;&lt;BR /&gt;DO J=1,42
&lt;BR /&gt;  DO K=1,50&lt;BR /&gt; KEYNR(J,K)=0&lt;BR /&gt; END DO&lt;BR /&gt;END DO&lt;BR /&gt;&lt;BR /&gt;I know this is a simple problem but I figure it's worth posting a solution in case someone new to programming or new to Fortran comes across this post.</description>
      <pubDate>Fri, 20 Jul 2012 16:12:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903083#M81354</guid>
      <dc:creator>Ashley_Weinstein</dc:creator>
      <dc:date>2012-07-20T16:12:04Z</dc:date>
    </item>
    <item>
      <title>Array indexing</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903084#M81355</link>
      <description>Ashley, I think he knows that. The code took advantage of a lack of array bounds checking and the knowledge that Fortran arrays are in column-major order so the loop to initialize 2100 elements would, in the absence of bounds checking, actually initialize the 42x50 array.&lt;BR /&gt;&lt;BR /&gt;You are correct, of course, that this is not legal Fortran and that bounds checking would complain. You are also correct on the proper fix. But he said at the outset that he didn't want to change the code and wanted a way to tell the compiler to ignore the error.</description>
      <pubDate>Fri, 20 Jul 2012 16:46:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903084#M81355</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2012-07-20T16:46:23Z</dc:date>
    </item>
    <item>
      <title>I am getting similar error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903085#M81356</link>
      <description>&lt;P&gt;I am getting similar error involving array indixing in my code for the array defined as follows in main program. The array is returned from a subroutine that reads a text file via dummy array :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;real,dimension(:), allocatable :: co2ser(:)&lt;/P&gt;
&lt;P&gt;allocate (co2ser(1:30))&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The program compiles without erro but the executable returns this error when I run it:&lt;/P&gt;
&lt;P&gt;"forrtl: severe &amp;lt;408&amp;gt; fort: &amp;lt;11&amp;gt;: subscript #1 of the array CO2SER has value 0 which is less than the lower bound of 1."&lt;/P&gt;
&lt;P&gt;The array was populated from a text file (unit=11) with a vector of 30 elements (30x1) by a subroutine in a module. I know which array is causing the problem just don't know how to fix it.&lt;/P&gt;
&lt;P&gt;Any help is appreciated.&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2013 20:57:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903085#M81356</guid>
      <dc:creator>Seyoum_G_</dc:creator>
      <dc:date>2013-11-12T20:57:00Z</dc:date>
    </item>
    <item>
      <title>You have to locate the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903086#M81357</link>
      <description>&lt;P&gt;You have to locate the portion of code where the array is being referenced with an out-of-bounds index (index = 0 in your case). If you use the /traceback option, in addition to the current options that trapped the invalid subscript, you will find the segment(s) of code that you need to fix.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2013 23:13:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903086#M81357</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2013-11-12T23:13:13Z</dc:date>
    </item>
    <item>
      <title>Isn't this the intel compiler</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903087#M81358</link>
      <description>&lt;P&gt;Isn't this the intel compiler's bug reported earlier (&amp;nbsp;http://software.intel.com/en-us/forums/topic/335404)&amp;nbsp;concerning allocatable array assignment error because my array is allocatable and I am using Frortan 12&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2013 20:20:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903087#M81358</guid>
      <dc:creator>Seyoum_G_</dc:creator>
      <dc:date>2013-11-15T20:20:00Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt; real,dimension(:),</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903088#M81359</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt;&amp;nbsp;real,dimension(:), allocatable :: co2ser(:)&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The above syntax would declare an array of arrays (witout using a user defined type). I think this is illegal syntax (except for character). Steve or IanH may have more athoratative input.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2013 21:37:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903088#M81359</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2013-11-15T21:37:56Z</dc:date>
    </item>
    <item>
      <title>I am not sure what was</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903089#M81360</link>
      <description>&lt;P&gt;I am not sure what was intended with:&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&amp;nbsp;[fortran]real,dimension(:), allocatable :: co2ser(:)&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;allocate (co2ser(1:30)) [/fortran]&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;But I had a look under debug and this declaration gives you get a one dimensional real&amp;nbsp;array with elements 1 to 30. Your error message&amp;nbsp;says you referenced element&amp;nbsp;zero which is indeed an&amp;nbsp;error as 0 is not in the 1 to 30 range.&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;I am not sure what your code was expecting, did you really want to allocate co2ser(0:29)?&amp;nbsp; But whatever, some rework is required!&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;I would suggest posting a more complete code sampe&amp;nbsp;and someone will be more able &amp;nbsp;to assist.&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;Andrew&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2013 23:19:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903089#M81360</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2013-11-15T23:19:00Z</dc:date>
    </item>
    <item>
      <title>The two specifications of (:)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903090#M81361</link>
      <description>&lt;P&gt;The two specifications of (:) there are redundant. I'd have to check the standard to see if it's allowed to have both...&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2013 01:00:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903090#M81361</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-11-16T01:00:47Z</dc:date>
    </item>
    <item>
      <title>Dear all,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903091#M81362</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;Thank you for all your comments and helps. Every suggestion you provided was helpful as &amp;nbsp;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I finally found where the problem was. The codes for allocating and defining the array were&amp;nbsp;correct in terms of syntax. However, t&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;he parameter (k=1,30&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;), which I used to get elements of&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;co2ser &lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;(one at a time) was supposed to be provided by second subroutine but it happend that it only makes k aviable after the third &lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;subroutine&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&amp;nbsp;looking for elements of co2ser attempted&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&amp;nbsp;to get the values in co2ser array&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;and as a result&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&amp;nbsp;c&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;o2ser(k) could not be reurned. I fixed that and now it works.&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Thanks&amp;nbsp;again&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2013 18:14:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Array-indexing/m-p/903091#M81362</guid>
      <dc:creator>Seyoum_G_</dc:creator>
      <dc:date>2013-11-18T18:14:34Z</dc:date>
    </item>
  </channel>
</rss>

