<?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 variable size array at compilation time without allocate in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756556#M12043</link>
    <description>N_1() is an automatic array. If you let it be allocated on stack (the fastest way), you will incur a failure if the stack size limit isn't large enough.&lt;BR /&gt;As Ron said, ALLOCATE in principle is the same, except that you could check explicitly for errors, which is advisable for an allocation this large.&lt;BR /&gt;Automatic array was not standard until Fortran 90, although certain f77 compilers supported it as an extension.</description>
    <pubDate>Wed, 20 Jul 2011 14:22:44 GMT</pubDate>
    <dc:creator>TimP</dc:creator>
    <dc:date>2011-07-20T14:22:44Z</dc:date>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756553#M12040</link>
      <description>Hi I am having trouble with a simple declaration, and out of desesperation I decided to post in this forum.&lt;BR /&gt;&lt;BR /&gt;My
 problem is that i want to have an array that it's size is determined at
 compilation time. I do not want to use allocate (speed issues). I have 
use the technique in the following code for years:&lt;BR /&gt;&lt;BR /&gt;program main1&lt;BR /&gt;implicit none&lt;BR /&gt;integer, parameter :: i1_max = 2000&lt;BR /&gt;integer, parameter :: i2_max = 2000&lt;BR /&gt;call main2(i1_max,i2_max)&lt;BR /&gt;end program main1 &lt;BR /&gt;&lt;BR /&gt;subroutine main2(i1_max,i2_max)&lt;BR /&gt;implicit none&lt;BR /&gt;integer, intent(in) :: i1_max, i2_max&lt;BR /&gt;integer, dimension(i1_max,i2_max)  :: N_1&lt;BR /&gt;N_1(1,1) = 1;&lt;BR /&gt;end subroutine main2&lt;BR /&gt;&lt;BR /&gt;With the above code, I have no error at compilation time. &lt;BR /&gt;&lt;BR /&gt;However
 at execution time, I get a segmentation fault if i1_max = i2_max = 
2000. However I do not get any error if i1_max = i2_max = 20. (this are 
just test values, I did not amussed myselfs to try more)&lt;BR /&gt;&lt;BR /&gt;It is not a problem of memory, the machine has plenty of it (12Gb). &lt;BR /&gt;&lt;BR /&gt;On top of that, if I declare the size explicitly in the subroutine:&lt;BR /&gt;&lt;BR /&gt;integer, dimension(2000,2000):: N_1&lt;BR /&gt;&lt;BR /&gt;Then there is no problem either!!! Showing again that is no problem of memory.&lt;BR /&gt;&lt;BR /&gt;Just for information, I am using ubuntu11.04 in an intel xeon W3690, ifort2011.&lt;BR /&gt;Final
 note: if I compile the same code with gfortran I have no problems. 
However i would like to stay with ifort as it generates faster code...&lt;BR /&gt;&lt;BR /&gt;I really have no idea of what is going on. If somebody could help me out I would really appreciated.&lt;BR /&gt;&lt;BR /&gt;Jofre</description>
      <pubDate>Wed, 20 Jul 2011 13:03:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756553#M12040</guid>
      <dc:creator>jpedregosa</dc:creator>
      <dc:date>2011-07-20T13:03:06Z</dc:date>
    </item>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756554#M12041</link>
      <description>you need to read &lt;A href="http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/"&gt;http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;But your statement that you're doing this because of a speed advantage over ALLOCATE may only hold water if your data is pointer based. A plain, allocatable array without the pointer attribute will have zero performance penalty over what you're doing here. &lt;BR /&gt;&lt;BR /&gt;ron</description>
      <pubDate>Wed, 20 Jul 2011 13:56:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756554#M12041</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2011-07-20T13:56:11Z</dc:date>
    </item>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756555#M12042</link>
      <description>oh, and a couple of other notes:&lt;BR /&gt;&lt;BR /&gt;I don't see you using interfaces or modules. Your other subroutines and functions are in modules or have interface statements, correct? The reason I ask is you seem very performance concious. With old F77 external procedures you can get a lot of data copies for arguments. Creating interfaces or putting procedures in modules that are USEd can help the compiler with optimizations on call boundaries and in data disambiquity analysis.</description>
      <pubDate>Wed, 20 Jul 2011 14:02:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756555#M12042</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2011-07-20T14:02:46Z</dc:date>
    </item>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756556#M12043</link>
      <description>N_1() is an automatic array. If you let it be allocated on stack (the fastest way), you will incur a failure if the stack size limit isn't large enough.&lt;BR /&gt;As Ron said, ALLOCATE in principle is the same, except that you could check explicitly for errors, which is advisable for an allocation this large.&lt;BR /&gt;Automatic array was not standard until Fortran 90, although certain f77 compilers supported it as an extension.</description>
      <pubDate>Wed, 20 Jul 2011 14:22:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756556#M12043</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2011-07-20T14:22:44Z</dc:date>
    </item>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756557#M12044</link>
      <description>&lt;I&gt;However
 at execution time, I get a segmentation fault if i1_max = i2_max = 
2000..&lt;BR /&gt;It is not a problem of memory, the machine has plenty of it (12Gb). &lt;BR /&gt;On top of that, if I declare the size explicitly in the subroutine:&lt;BR /&gt;integer, dimension(2000,2000):: N_1&lt;BR /&gt;Then there is no problem either!!! Showing again that is no problem of memory.&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;Together, these statements establish that you do not have an adequate comprehension of the different ways in which memory is allocated and shared between programs on a modern multitasking operating system. You need to do some reading to understand the issues and make an intelligent selection that suits your purposes.&lt;BR /&gt;&lt;BR /&gt;
By trying to avoid dynamic allocation without thinking about the consequences you have invited failure.&lt;BR /&gt;&lt;BR /&gt;A local array, as in your program, is usually allocated on the stack. Stack allocation for local variables, subprogram arguments and &lt;SPAN style="text-decoration: underline;"&gt;small&lt;/SPAN&gt; arrays is convenient and efficient. That is why it is so commonly used. However, your array is &lt;SPAN style="text-decoration: underline;"&gt;not small&lt;/SPAN&gt;.&lt;BR /&gt;&lt;BR /&gt;The default stack size is operating system dependent, but is usually set to be a small fraction of the total virtually memory available, so that there is adequate stack for all the running processes under OS control. Your array requires 16 megabytes, which may be more than the default stack size on your OS.&lt;BR /&gt;&lt;BR /&gt;A static declaration such as&lt;BR /&gt;&lt;BR /&gt; integer, dimension(2000,2000):: N_1&lt;BR /&gt;&lt;BR /&gt;allocates the array for duration of your program, so other subroutines and other tasks do not "own" and possibly cannot access that memory until your task completes. Such tying up of a resource is often undesirable.&lt;BR /&gt;&lt;BR /&gt;Heap allocation, by using ALLOCATE, is the best fit for your requirements to the extent that your description defines them. It does require a few more lines of code but, as TimP has pointed out, you can check for successful allocation before attempting to use the array. &lt;BR /&gt;</description>
      <pubDate>Wed, 20 Jul 2011 15:42:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756557#M12044</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-07-20T15:42:25Z</dc:date>
    </item>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756558#M12045</link>
      <description>I am impress!!! Thanks for bothering answering. Ok, I am an experimental physicist who does a bit of molecular symulation (not really a computer science person) and so I tend to get large matrices and vectors. When finally I decided to switch to fortran90 (I used fortran77) five years ago, I found many posts in forums about how ALLOCATABLE arrays affected performance. Ok, forums are not god's word, but what the hell we are in one and I trust that the answer are given in a honest manner!&lt;BR /&gt;&lt;BR /&gt;Now that you guys have give me the key words, "heap allocation", I will try to find more information about it, and I will try to do some speed tests for my particular case about allocatable large arrays.&lt;BR /&gt;&lt;BR /&gt;Also, do you know how can affect a linux system a change on the stack size?&lt;BR /&gt;&lt;BR /&gt;However, there is still the mysteri that gfortran produced a code that executed without problems...&lt;BR /&gt;&lt;BR /&gt;Thanks again for your help,&lt;BR /&gt;Jofre</description>
      <pubDate>Thu, 21 Jul 2011 08:30:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756558#M12045</guid>
      <dc:creator>jpedregosa</dc:creator>
      <dc:date>2011-07-21T08:30:51Z</dc:date>
    </item>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756559#M12046</link>
      <description>If you want the same behavior as gfortran, add the switch -heap-arrays to the compile. gfortran always uses heap allocation for automatic arrays.</description>
      <pubDate>Thu, 21 Jul 2011 13:43:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756559#M12046</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-07-21T13:43:18Z</dc:date>
    </item>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756560#M12047</link>
      <description>&lt;I&gt;&amp;gt; I found many posts in forums about how ALLOCATABLE arrays affected performance&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;Judiciously used, ALLOCATE/DEALLOCATE will have an effect on performance that is probably too small to measure easily. &lt;BR /&gt;&lt;BR /&gt;That is, if the numbers of executions of ALLOCATE/DEALLOCATE statements (and, in Fortran 2003, automatic allocation, and deallocation of local ALLOCATEd variables) are kept down to reasonable levels -- for example, by not doing premature deallocation of a variable/array before a subprogram RETURN when it is known that the next call to the subroutine will result in the same variable/array being reallocated -- these statements will be serving their intended purpose in the language, and quite efficiently so.&lt;BR /&gt;&lt;BR /&gt;As with other newly introduced language features, ALLOCATE/DEALLOCATE may have been somewhat inefficient when they were first implemented. Perhaps, the reports that colored your opinion were based on those early compiler versions.&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;&amp;gt; Also, do you know how can affect a linux system a change on the stack size?&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;Try &lt;B&gt;man ulimit&lt;/B&gt; .</description>
      <pubDate>Fri, 22 Jul 2011 10:49:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756560#M12047</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-07-22T10:49:26Z</dc:date>
    </item>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756561#M12048</link>
      <description>&lt;P&gt;Depending on the OS's age and the user's shell, man ulimit might point to somewhere else (e.g., the unimplemented or the ulimit.h man page).  If bash is the user's default shell, ulimit is probably a built-in (like e.g., cd or pwd), so &lt;STRONG&gt;info --index-search=ulimit bash&lt;/STRONG&gt; is a better option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 16:03:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756561#M12048</guid>
      <dc:creator>John4</dc:creator>
      <dc:date>2011-07-22T16:03:35Z</dc:date>
    </item>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756562#M12049</link>
      <description>Good point. I have no experience with Ubuntu, so I gave a tentative pointer.&lt;BR /&gt;&lt;BR /&gt;However, I have a vague recollection of at least some releases of Ubuntu using not &lt;I&gt;bash&lt;/I&gt; but &lt;I&gt;dash&lt;/I&gt; as the default shell.&lt;BR /&gt;&lt;BR /&gt;A user of any version of Linux/Unix will need to be able to access the documentation for the shell and OS commands.</description>
      <pubDate>Sun, 24 Jul 2011 02:21:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756562#M12049</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-07-24T02:21:06Z</dc:date>
    </item>
    <item>
      <title>variable size array at compilation time without allocate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756563#M12050</link>
      <description>&lt;P&gt;On Ubuntu, &lt;STRONG&gt;dash&lt;/STRONG&gt; is the default for &lt;STRONG&gt;sh&lt;/STRONG&gt; (so it affects any script for which the shebang line is &lt;STRONG&gt;#!/bin/sh&lt;/STRONG&gt;), but scripts that use &lt;STRONG&gt;#!/bin/bash&lt;/STRONG&gt; explicitly are not affected ---and the default shell for user accounts is still &lt;STRONG&gt;bash&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;dash&lt;/STRONG&gt; is supposed to be lighter an stricter than &lt;STRONG&gt;bash&lt;/STRONG&gt;, so installing software is much faster ---one drawback, is that system() is usually implemented in terms of /bin/sh, so Fortran's EXECUTE_COMMAND_LINE will probably be affected by it as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jul 2011 22:14:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/variable-size-array-at-compilation-time-without-allocate/m-p/756563#M12050</guid>
      <dc:creator>John4</dc:creator>
      <dc:date>2011-07-24T22:14:37Z</dc:date>
    </item>
  </channel>
</rss>

