<?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 Re: Dynamic DLL Loading in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875061#M73561</link>
    <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;If you are using /iface:cvf, then your C++ code will need to use __stdcall in the prototype for the Fortran routine. You may not need to add an ALIAS - how is the routine declared in C++?&lt;/P&gt;
&lt;P&gt;Yes, pass by reference is the default. This can change if you use certain attributes such as C or STDCALL in directives. You can also specify VALUE on a !DEC$ ATTRIBUTES directive for the argument, or can use the Fortran 2003 VALUE attribute. The difference is that with !DEC$ ATTRIBUTES VALUE you cannot modify the argument inside the routine, whereas with the F2003 VALUE you can but are modifying a temporary copy that is discarded on exit.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Oct 2008 18:17:15 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2008-10-02T18:17:15Z</dc:date>
    <item>
      <title>Dynamic DLL Loading</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875060#M73560</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I have a cosole program written in Fortran and I want to dynamically load a DLL, which can be written by a thrid party. The problem is that the DLL can be written in C++ or Fortran. The headers to the routines in the DLL are preset. What flags have to be specified in the DLL:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;on the DLLEXPORT line? (pressumably something like ATTRIBUTES DLLEXPORT, ALIAS:"USERFUNC" :: USERFUNC)&lt;/LI&gt;&lt;LI&gt;on the argument declaration lines? (REFERENCE or VALUE)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;so that the routines in the DLL can interface with the main Fortran program. What attributes should I include so that the correct routine names are exported to my Fortran application? I use the /iface:CVF for all my files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On a side issue:&lt;/P&gt;&lt;P&gt;As I understand, variables in Fortran are passed by reference rather than by value. Correct me if I'm wrong! If you take the following pseudo-code:&lt;/P&gt;&lt;P&gt;program main&lt;/P&gt;&lt;P&gt; i=0&lt;/P&gt;&lt;P&gt; call sub(i)&lt;/P&gt;&lt;P&gt; print*,"i=",i&lt;/P&gt;&lt;P&gt;end program&lt;/P&gt;&lt;P&gt;sub(j)&lt;/P&gt;&lt;P&gt; j=j+1&lt;/P&gt;&lt;P&gt; print*,"j=",j&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;P&gt;If variables are passed by reference then the output is: j=1, i=1.&lt;/P&gt;&lt;P&gt;If variables are passed by value, then the output is: j=1, i=0.&lt;/P&gt;&lt;P&gt;Am I getting this right?&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;Daniel.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Oct 2008 16:37:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875060#M73560</guid>
      <dc:creator>Ilie__Daniel</dc:creator>
      <dc:date>2008-10-02T16:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic DLL Loading</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875061#M73561</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;If you are using /iface:cvf, then your C++ code will need to use __stdcall in the prototype for the Fortran routine. You may not need to add an ALIAS - how is the routine declared in C++?&lt;/P&gt;
&lt;P&gt;Yes, pass by reference is the default. This can change if you use certain attributes such as C or STDCALL in directives. You can also specify VALUE on a !DEC$ ATTRIBUTES directive for the argument, or can use the Fortran 2003 VALUE attribute. The difference is that with !DEC$ ATTRIBUTES VALUE you cannot modify the argument inside the routine, whereas with the F2003 VALUE you can but are modifying a temporary copy that is discarded on exit.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Oct 2008 18:17:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875061#M73561</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-10-02T18:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic DLL Loading</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875062#M73562</link>
      <description>&lt;DIV style="margin:0px;"&gt;The routine is exported as __stdcall (void EXPORT __stdcall func1(double&amp;amp;arg) ).&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Oct 2008 11:36:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875062#M73562</guid>
      <dc:creator>Ilie__Daniel</dc:creator>
      <dc:date>2008-10-03T11:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic DLL Loading</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875063#M73563</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;Ok. In that case the directive you'll want is this:&lt;/P&gt;
&lt;P&gt;!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE :: func1&lt;/P&gt;
&lt;P&gt;This will apply the correct name case (lowercase) and decoration and also specify pass-by-reference.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Oct 2008 13:22:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875063#M73563</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-10-03T13:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic DLL Loading</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875064#M73564</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/336209"&gt;Steve Lionel (Intel)&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;EM&gt;
&lt;P&gt;Ok. In that case the directive you'll want is this:&lt;/P&gt;
&lt;P&gt;!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE :: func1&lt;/P&gt;
&lt;P&gt;This will apply the correct name case (lowercase) and decoration and also specify pass-by-reference.&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;One more thing, Steve: Is it mandatory to specify thedirective in uppercase?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2008 13:34:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875064#M73564</guid>
      <dc:creator>Ilie__Daniel</dc:creator>
      <dc:date>2008-10-06T13:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic DLL Loading</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875065#M73565</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/251341"&gt;Daniel I.&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;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;One more thing, Steve: Is it mandatory to specify thedirective in uppercase?&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;No. It's just a style thing - it stands out in the code better.&lt;/P&gt;
&lt;P&gt;Les&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2008 14:12:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Dynamic-DLL-Loading/m-p/875065#M73565</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2008-10-06T14:12:23Z</dc:date>
    </item>
  </channel>
</rss>

