<?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 Thanks for your reply. New to in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166014#M144360</link>
    <description>&lt;P&gt;Thanks for your reply. New to Fortran, didn't even that was an option&amp;nbsp;to allocate it to 0&amp;nbsp;size. That makes sense.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jun 2019 23:58:36 GMT</pubDate>
    <dc:creator>Mahajan__Bharat1</dc:creator>
    <dc:date>2019-06-17T23:58:36Z</dc:date>
    <item>
      <title>Undefined array in Fortran 2008 automatic LHS memory allocation</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166012#M144358</link>
      <description>&lt;P&gt;I have noticed that the following piece of code works every time when I compile it&amp;nbsp;using ifort:&lt;/P&gt;&lt;P&gt;program test&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;implicit &amp;nbsp;none&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;real, dimension(:), allocatable :: a &amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;a = [a, 2.0]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;print *, a&lt;BR /&gt;end program test&lt;/P&gt;&lt;P&gt;In the above, 'a' is undefined and yet it is being used in the statement "a = [a,.2.0]. The above code prints "2.0" correctly. If you compile it using&amp;nbsp;gfortran, then sometimes you will see segfault and sometimes not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the question is: Is it safe to use an allocatable array this way when you are only compiling using ifort. I mean does ifort compiler recognizes this code as valid and knows that if 'a' is not allocated already then just allocate a one real size of memory for it?&lt;/P&gt;&lt;P&gt;I find this "feature" very convenient when using Fortran 2008's LHS reallocation. Otherwise, we have to do this:&lt;/P&gt;&lt;P&gt;if (.NOT. allocated(a)) then&lt;/P&gt;&lt;P&gt;&amp;nbsp; a = 2.0&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;a = [a, 2.0]&lt;/P&gt;&lt;P&gt;end if&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above code works with gfortran as well as ifort but its not very pleasing to me especially inside a loop.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jun 2019 23:18:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166012#M144358</guid>
      <dc:creator>Mahajan__Bharat1</dc:creator>
      <dc:date>2019-06-16T23:18:18Z</dc:date>
    </item>
    <item>
      <title>It's not a feature, it's an</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166013#M144359</link>
      <description>&lt;P&gt;It's not a feature, it's an error in your program. If you compile with pointer checking enabled, you get:&lt;/P&gt;
&lt;PRE class="brush:plain; class-name:dark;"&gt;forrtl: severe (408): fort: (8): Attempt to fetch from allocatable variable A when it is not allocated&lt;/PRE&gt;

&lt;P&gt;You cannot and should not depend on the behavior when it is undefined.&lt;/P&gt;
&lt;P&gt;Why not allocate the array to zero size initially? Then you don't need to do the test each time.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 20:49:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166013#M144359</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2019-06-17T20:49:11Z</dc:date>
    </item>
    <item>
      <title>Thanks for your reply. New to</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166014#M144360</link>
      <description>&lt;P&gt;Thanks for your reply. New to Fortran, didn't even that was an option&amp;nbsp;to allocate it to 0&amp;nbsp;size. That makes sense.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 23:58:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166014#M144360</guid>
      <dc:creator>Mahajan__Bharat1</dc:creator>
      <dc:date>2019-06-17T23:58:36Z</dc:date>
    </item>
    <item>
      <title>Quote:Mahajan, Bharat wrote</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166015#M144361</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Mahajan, Bharat wrote:&lt;BR /&gt;Thanks for your reply. New to Fortran, didn't even that was an option&amp;nbsp;to allocate it to 0&amp;nbsp;size. That makes sense.&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't feel too bad, I have been using Fortran many years and I didn't know allocating to 0 size was possible. :-(&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 10:47:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166015#M144361</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2019-06-18T10:47:18Z</dc:date>
    </item>
    <item>
      <title>allocating to zero size...</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166016#M144362</link>
      <description>&lt;P&gt;allocating to zero size... How cool is that, and how disappointing no Fortran book mentions it.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 20:40:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166016#M144362</guid>
      <dc:creator>DataScientist</dc:creator>
      <dc:date>2019-06-19T20:40:15Z</dc:date>
    </item>
    <item>
      <title>I am pretty sure you are</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166017#M144363</link>
      <description>&lt;P&gt;I am pretty sure you are mistaken about no Fortran book mentioning that. The Modern Fortran series by Metcalf, Reid and Cohen does mention it (unless I am terribly mistaken) - it is an example where a language feature helps to formulate algorithms in a clear style. Being able to use zero-length arrays means that you do not have to use a special case for that particular situation.&lt;/P&gt;&lt;P&gt;I suppose it is something one can lightly overlook. Just to be sure, I checked the text of Programming in Fortran 90/95 by J. S. Morgan and J. L. Schonfelder (2000 - very old indeed, but I just had that available). zero-length arrays are not discussed in length it would seem, but the description of the intrinsic functions and subroutines is flooded with such cases ;).&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 06:45:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166017#M144363</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2019-06-20T06:45:39Z</dc:date>
    </item>
    <item>
      <title>Indeed, the current edition</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166018#M144364</link>
      <description>&lt;P&gt;Indeed, the current edition of MFE has&amp;nbsp;&lt;STRONG&gt;7.2 Zero-sized arrays&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 07:51:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Undefined-array-in-Fortran-2008-automatic-LHS-memory-allocation/m-p/1166018#M144364</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2019-06-20T07:51:43Z</dc:date>
    </item>
  </channel>
</rss>

