<?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 StackOverflow Exception when Called from Managed Code in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853270#M66727</link>
    <description>David,&lt;DIV&gt;&lt;SPAN style="font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;But it were corrupted, why for small values of ints, there were no sign of corruption?&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Also, in my fortran code, I explicitly specify the pass in parameters as value:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;[fortran]!DEC$ ATTRIBUTES VALUE :: maxncv,ldv  [/fortran]&lt;/PRE&gt;

So I don't think there is any issue of corruption&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 06 Apr 2010 05:48:56 GMT</pubDate>
    <dc:creator>Ngu_Soon_Hui</dc:creator>
    <dc:date>2010-04-06T05:48:56Z</dc:date>
    <item>
      <title>StackOverflow Exception when Called from Managed Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853266#M66723</link>
      <description>I asked &lt;A href="http://stackoverflow.com/questions/2504977/stackoverflow-exception-in-umanaged-dll-when-called-from-managed-dll"&gt;this question here&lt;/A&gt;. But since this is more relevant to fortran compiler, so I reask the question again.&lt;DIV&gt;&lt;SPAN style="font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Basically, I have fortran dll as my backend, and C# as my front end. My backend is something like this ( trimmed down):&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;[fxfortran] subroutine chartest(maxncv,ldv)

  !DEC$ ATTRIBUTES DLLEXPORT::chartest
  !DEC$ ATTRIBUTES ALIAS:'chartest'::chartest
   !DEC$ ATTRIBUTES VALUE :: maxncv,ldv

 &amp;amp;    

   integer, intent(in)  :: maxncv, ldv

  Double precision
 &amp;amp;                  v(ldv,maxncv),d(maxncv,2)

   print *, 'hello'

  end[/fxfortran]&lt;/PRE&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;And my C# code is something like this:&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;[bash]  public static extern void chartest(

       [MarshalAs(UnmanagedType.I4)] int maxncv,
          [MarshalAs(UnmanagedType.I4)] int ldv


   );[/bash]&lt;/PRE&gt; &lt;/DIV&gt;&lt;DIV&gt;If I call&lt;CODE&gt;chartest(546, 547)&lt;/CODE&gt;, I would get a stackoverflowexception.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I understand and verify that by&lt;A href="http://software.intel.com/en-us/forums/showthread.php?t=53881"&gt; turning on the/heap_arrays I can overcome this exception&lt;/A&gt;, but from what I've read, my code shouldn't generate any stackoverflowexception, since the array assignment is done inside fortran code. Is there anything missing here?&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;If not then I have to turn on the \\heap_arrays option as mentioned. Is there is a better solution?&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I'm using version 11.0.066&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Apr 2010 02:19:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853266#M66723</guid>
      <dc:creator>Ngu_Soon_Hui</dc:creator>
      <dc:date>2010-04-06T02:19:09Z</dc:date>
    </item>
    <item>
      <title>StackOverflow Exception when Called from Managed Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853267#M66724</link>
      <description>Suggest you search the forum for C#. From what I can see, you need to use REFERENCE rather than VALUE:&lt;BR /&gt;&lt;BR /&gt;By default scalar type like integer is passed by reference in fortran so its corresponding in C# should be declared as reference type.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;David</description>
      <pubDate>Tue, 06 Apr 2010 02:32:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853267#M66724</guid>
      <dc:creator>DavidWhite</dc:creator>
      <dc:date>2010-04-06T02:32:52Z</dc:date>
    </item>
    <item>
      <title>StackOverflow Exception when Called from Managed Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853268#M66725</link>
      <description>Thanks for your advice, but I'm not sure whether by changing to "passed by reference ", will it solve my problem?&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;For small input parameters, my code can run fine, so I don't think pass by reference/ value is the problem here.&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Apr 2010 02:48:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853268#M66725</guid>
      <dc:creator>Ngu_Soon_Hui</dc:creator>
      <dc:date>2010-04-06T02:48:52Z</dc:date>
    </item>
    <item>
      <title>StackOverflow Exception when Called from Managed Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853269#M66726</link>
      <description>My concern was about the value of the array size which you are passing as an argument. Is the value on in C# and in Fortran the same or is it being corrupted? You may need to use STDCALL for the argument passing as well.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;David</description>
      <pubDate>Tue, 06 Apr 2010 05:11:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853269#M66726</guid>
      <dc:creator>DavidWhite</dc:creator>
      <dc:date>2010-04-06T05:11:20Z</dc:date>
    </item>
    <item>
      <title>StackOverflow Exception when Called from Managed Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853270#M66727</link>
      <description>David,&lt;DIV&gt;&lt;SPAN style="font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;But it were corrupted, why for small values of ints, there were no sign of corruption?&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Also, in my fortran code, I explicitly specify the pass in parameters as value:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;[fortran]!DEC$ ATTRIBUTES VALUE :: maxncv,ldv  [/fortran]&lt;/PRE&gt;

So I don't think there is any issue of corruption&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Apr 2010 05:48:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853270#M66727</guid>
      <dc:creator>Ngu_Soon_Hui</dc:creator>
      <dc:date>2010-04-06T05:48:56Z</dc:date>
    </item>
    <item>
      <title>StackOverflow Exception when Called from Managed Code</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853271#M66728</link>
      <description>Your Fortran local arrays d and v are "automatic" which means they will be created on the stack by default. You can either use /heap_arrays or change the arrays to allocatable and add code to manage the allocate and deallocate.</description>
      <pubDate>Tue, 06 Apr 2010 08:29:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/StackOverflow-Exception-when-Called-from-Managed-Code/m-p/853271#M66728</guid>
      <dc:creator>Andrew_Smith</dc:creator>
      <dc:date>2010-04-06T08:29:22Z</dc:date>
    </item>
  </channel>
</rss>

