<?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 Stack overflow because of too many functions? in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811741#M43072</link>
    <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=90977" class="basic" href="https://community.intel.com/en-us/profile/90977/"&gt;onkelhotte&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px; border-style: inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;&lt;DIV class="dp-highlighter"&gt;&lt;OL class="dp-sh" start="1"&gt;&lt;LI&gt;&lt;SPAN&gt;subroutineFSET_NBRAMMEGESAMT(inValue)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="alt"&gt;&lt;SPAN&gt;.. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="alt"&gt;&lt;SPAN&gt;integer(C_INT)&lt;SPAN class="keyword"&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;FGET_NBRAMMEGESAMT()&lt;/SPAN&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think it will fix your problem, but you are missing BIND(C) clauses on those statements.&lt;/P&gt;</description>
    <pubDate>Thu, 31 May 2012 21:12:03 GMT</pubDate>
    <dc:creator>IanH</dc:creator>
    <dc:date>2012-05-31T21:12:03Z</dc:date>
    <item>
      <title>Stack overflow because of too many functions?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811735#M43066</link>
      <description>Hi there,&lt;BR /&gt;&lt;BR /&gt;I know this is not directlya fortran problem, but maybe someone with a greater programming experience can help me here...&lt;BR /&gt;&lt;BR /&gt;Iwrote asimulation of an industrial furnace system inQuickWin.In the future, this program willrun at a real furnace for temperature calculations etc.&lt;BR /&gt;&lt;BR /&gt;Because the QuickWin UI is not very modern, I should give it a face lift. So I did the following:&lt;BR /&gt;- I divided the QuickWin UI as a main program and the calculation kernel as a DLL&lt;BR /&gt;- The new GUI will be implemented with WPF and uses the calculation DLL&lt;BR /&gt;&lt;BR /&gt;So I thought about the data exchange. Because the calculation DLL has to be in a seperate software evironment where CORBA is being used, I chose CORBA to avoid work in the future.&lt;BR /&gt;&lt;BR /&gt;I wrote a C++ lib which provides a CORBA Server (mico to be precise). This lib is being linked to the calculation DLL, the CORBA idl files are being imported to WPF by IIOP.net. I tested how to exchange float values, characters, type fields, multidimensional arrays... All worked fine.&lt;BR /&gt;&lt;BR /&gt;And now comes my problem:&lt;BR /&gt;I wrote a converter, that coded an interface for every variable we have in our module, which both the UI and the calculation DLL uses. When I called from WPF any interfacefunction, I get a stack overflow error.&lt;BR /&gt;Then I reduced the number of functions. At first, there were 558. When I reduce them to 130, it works fine.&lt;BR /&gt;&lt;BR /&gt;I increased the stack size in my fortran calculation DLL to 2100000000 and /LARGEADDRESSAWARE (Support Addresses Larger Than 2 GB) as a linker option, but this didnt help. In my WPF project I cannot influence the stack size.&lt;BR /&gt;&lt;BR /&gt;Has anybody an idea what this could be?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;Markus</description>
      <pubDate>Thu, 31 May 2012 07:23:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811735#M43066</guid>
      <dc:creator>onkelhotte</dc:creator>
      <dc:date>2012-05-31T07:23:30Z</dc:date>
    </item>
    <item>
      <title>Stack overflow because of too many functions?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811736#M43067</link>
      <description>Could you try /heap-arrays ?</description>
      <pubDate>Thu, 31 May 2012 12:35:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811736#M43067</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2012-05-31T12:35:41Z</dc:date>
    </item>
    <item>
      <title>Stack overflow because of too many functions?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811737#M43068</link>
      <description>No, /heap-arrays didnt do the trick.&lt;BR /&gt;&lt;BR /&gt;The output window tells me:&lt;BR /&gt;First-chance exception at 0x10d56de7 (DFC_Kernel.dll) in DFC_GUI.exe: 0xC00000FD: Stack overflow.&lt;BR /&gt;&lt;BR /&gt;DFC_Kernel.dll is my Fortran dll and DFC_GUI.exe the WPF GUI.&lt;BR /&gt;&lt;BR /&gt;MICO, the CORBA server I use, is comfortable with such an amount of methods declared in the idl files.&lt;BR /&gt;&lt;BR /&gt;I will code a few days on another project to get my head clean and then I will try again :-)&lt;BR /&gt;&lt;BR /&gt;Markus</description>
      <pubDate>Thu, 31 May 2012 12:52:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811737#M43068</guid>
      <dc:creator>onkelhotte</dc:creator>
      <dc:date>2012-05-31T12:52:15Z</dc:date>
    </item>
    <item>
      <title>Stack overflow because of too many functions?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811738#M43069</link>
      <description>Merely having a large number of functions should not cause stack overflow. What matters is the call chain length. Is is possible that you have indirect recursion that has gone undetected?&lt;BR /&gt;&lt;BR /&gt; A: ... call B;...&lt;BR /&gt; B: ... call C;...&lt;BR /&gt;.......&lt;BR /&gt;.......&lt;BR /&gt; P: ... call Q;...&lt;BR /&gt; Q: ... call B;... &amp;lt;&amp;lt;=== indirect recursion&lt;BR /&gt; R: ... call S;...&lt;BR /&gt;</description>
      <pubDate>Thu, 31 May 2012 13:52:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811738#M43069</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2012-05-31T13:52:57Z</dc:date>
    </item>
    <item>
      <title>Stack overflow because of too many functions?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811739#M43070</link>
      <description>No, nothing like that. Here is one example:&lt;BR /&gt;&lt;BR /&gt;[bash]Corba IDL File:
    void set_nBrammeGesamt(in long value);
    long get_nBrammeGesamt();

C++ Header:
    void set_nBrammeGesamt(CORBA::Long);
    CORBA::Long get_nBrammeGesamt();

C++ Code:
    extern "C" void FSET_NBRAMMEGESAMT(CORBA::Long*);
    void DataExchange_i::set_nBrammeGesamt(CORBA::Long value)
    {
        FSET_NBRAMMEGESAMT(&amp;amp;value);
    }
    extern "C" CORBA::Long FGET_NBRAMMEGESAMT();
    CORBA::Long DataExchange_i::get_nBrammeGesamt()
    {
        return FGET_NBRAMMEGESAMT();
    }

Fortran Code:
    subroutine FSET_NBRAMMEGESAMT(inValue)
    use Shared_Common !nBrammeGesamt is stored in that module
    implicit none
    INTEGER(KIND=4) inValue
    nBrammeGesamt = inValue
    return
    end subroutine FSET_NBRAMMEGESAMT

    integer(C_INT) function FGET_NBRAMMEGESAMT()
    use,intrinsic :: ISO_C_BINDING
    use Shared_Common
    implicit none
    FGET_NBRAMMEGESAMT = nBrammeGesamt
    return
    end function FGET_NBRAMMEGESAMT&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;[/bash]I have 269 variables stored in shared_common, so there are 538 set/get methods declared in that way. There is no recursion in them, they just get or set a value in the module shared_common.&lt;BR /&gt;&lt;BR /&gt;My next step would be to go around that problem by declaring a few type / structs to get or set a bunch variables to decrease the amount of methods.&lt;BR /&gt;&lt;BR /&gt;Markus</description>
      <pubDate>Thu, 31 May 2012 14:17:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811739#M43070</guid>
      <dc:creator>onkelhotte</dc:creator>
      <dc:date>2012-05-31T14:17:38Z</dc:date>
    </item>
    <item>
      <title>Stack overflow because of too many functions?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811740#M43071</link>
      <description>&amp;gt;&amp;gt;I increased the stack size in my fortran calculation DLL to 2100000000 and /LARGEADDRESSAWARE (Support Addresses Larger Than 2 GB) as a linker option, but this didnt help&lt;BR /&gt;&lt;BR /&gt;On Win32, Large Address is less than 3GB.&lt;BR /&gt;The DLL does not "declare" the stack size (unless it creates additional threads).&lt;BR /&gt;Increase the stack size on the app that calls the DLL (the DLL uses the caller's stack).&lt;BR /&gt;&lt;BR /&gt;Do not set your app stack to 2100000000 as it might not run.&lt;BR /&gt;Use something reasonable 100000000 (100MB) assuming not-multi-threaded&lt;BR /&gt;&lt;BR /&gt;If you still run outof stack space, verify that your C to F to C callingsequence agree (args and stack clean-up). When the calling conventions do not aggree, sometimes the calls "work", but the stack is not cleaned-up on the return. (IOW you lose stack on each call - without crash of app).&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey</description>
      <pubDate>Thu, 31 May 2012 17:37:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811740#M43071</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-05-31T17:37:32Z</dc:date>
    </item>
    <item>
      <title>Stack overflow because of too many functions?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811741#M43072</link>
      <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=90977" class="basic" href="https://community.intel.com/en-us/profile/90977/"&gt;onkelhotte&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px; border-style: inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;&lt;DIV class="dp-highlighter"&gt;&lt;OL class="dp-sh" start="1"&gt;&lt;LI&gt;&lt;SPAN&gt;subroutineFSET_NBRAMMEGESAMT(inValue)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="alt"&gt;&lt;SPAN&gt;.. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI class="alt"&gt;&lt;SPAN&gt;integer(C_INT)&lt;SPAN class="keyword"&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;FGET_NBRAMMEGESAMT()&lt;/SPAN&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think it will fix your problem, but you are missing BIND(C) clauses on those statements.&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2012 21:12:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811741#M43072</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2012-05-31T21:12:03Z</dc:date>
    </item>
    <item>
      <title>Stack overflow because of too many functions?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811742#M43073</link>
      <description>&lt;P&gt;I tried it, but then I get linker errors, so I have to change something on the C++ side.&lt;BR /&gt;Although I cant use my character functions any more, because just 1 character is allowed then...&lt;BR /&gt;&lt;BR /&gt; subroutine FSET_LAYOUTERRORSTRING(inValue) !bind(C)&lt;BR /&gt; use Shared_Common&lt;BR /&gt; implicit none&lt;BR /&gt; CHARACTER*20 inValue&lt;BR /&gt; layOutErrorString = inValue&lt;BR /&gt; return&lt;BR /&gt; end subroutine FSET_LAYOUTERRORSTRING&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I will investigate it maybe later, but thanks for the advice. Maybe it helps.&lt;BR /&gt;&lt;BR /&gt;Markus&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2012 06:16:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811742#M43073</guid>
      <dc:creator>IDZ_A_Intel</dc:creator>
      <dc:date>2012-06-01T06:16:55Z</dc:date>
    </item>
    <item>
      <title>Stack overflow because of too many functions?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811743#M43074</link>
      <description>Hi Jim,&lt;BR /&gt;&lt;BR /&gt;my calling process isWPF, Im not sure how I can increase the stack size there. There are not many .NETproject settings (just "optimize","debug unmanaged code" and a few more).&lt;BR /&gt;&lt;BR /&gt;I will investigate on the stack clean up maybe later today, but surely on monday.&lt;BR /&gt;&lt;BR /&gt;Markus&lt;BR /&gt;&lt;BR /&gt;PS: After I increased the stack and because it didnt work, I resetted it directly to a normal value, thanks for the hint.</description>
      <pubDate>Fri, 01 Jun 2012 06:23:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811743#M43074</guid>
      <dc:creator>onkelhotte</dc:creator>
      <dc:date>2012-06-01T06:23:32Z</dc:date>
    </item>
    <item>
      <title>Stack overflow because of too many functions?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811744#M43075</link>
      <description>Try BIND(C,NAME='FSET_LAYOUTERRORSTRING')&lt;BR /&gt;&lt;BR /&gt;If you don't explicitly specify a binding label then it defaults to a lower case variant of the fortran procedure's name.&lt;BR /&gt;&lt;BR /&gt;ifort (and other fortran compilers) pass an extra "hidden" argument for each character dummy argument for the length of the actual argument character variable. (BIND(C) suppresses that - hence the restriction on only passing length one character). Are you passing those hidden arguments out from your C++ side? Failure to do so could cause rather spectacular crashes. Consult the ifort docs about where the hidden arguments go in the calling sequence - it is compiler and compiler option specific. &lt;BR /&gt;&lt;BR /&gt;(Note that putting in BIND(C) and having Fortran receive strings as character arrays is much more robust and portable, so much so that I personally wouldn't even contemplate not using that feature today for inter-language work.)&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Jun 2012 07:21:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Stack-overflow-because-of-too-many-functions/m-p/811744#M43075</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2012-06-01T07:21:22Z</dc:date>
    </item>
  </channel>
</rss>

