<?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 calling C# dll from FORTRAN in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811262#M42812</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;How can we call C# dll from Fortran? I googled a bit and found some examples where we can call Fortran dll from C#. However, I hardly find any example in the converse way. I would appreciate any suggestions.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;Krishna</description>
    <pubDate>Wed, 06 Oct 2010 06:01:27 GMT</pubDate>
    <dc:creator>krishnabc</dc:creator>
    <dc:date>2010-10-06T06:01:27Z</dc:date>
    <item>
      <title>calling C# dll from FORTRAN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811262#M42812</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;How can we call C# dll from Fortran? I googled a bit and found some examples where we can call Fortran dll from C#. However, I hardly find any example in the converse way. I would appreciate any suggestions.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;Krishna</description>
      <pubDate>Wed, 06 Oct 2010 06:01:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811262#M42812</guid>
      <dc:creator>krishnabc</dc:creator>
      <dc:date>2010-10-06T06:01:27Z</dc:date>
    </item>
    <item>
      <title>calling C# dll from FORTRAN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811263#M42813</link>
      <description>I think the most robust way is to create a wrapper dll in managed C++ (compiled with /CLR) switch. Managed C++ is the simplest bridge between managed and unmanaged code (actually, that is the very reason that Microsoft created it).&lt;BR /&gt;&lt;BR /&gt;Here are few code snippets from an actual application. Fortran code uses C interoperability to call managed C++ function, which calls C# implementation. C++ methods are static, i.e. they do not require passing of a class object.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[csharp]//C# implementation&lt;BR /&gt;public class DMSLogger
{
...
  public static void Log(LogLevel level, string formatString)
  {
      //body of log
  }
}&lt;BR /&gt;[/csharp]&lt;/PRE&gt;

&lt;PRE&gt;[cpp]//in .h file:
class DMSLogger {&lt;BR /&gt; ...&lt;BR /&gt; static void DLLEXPORT Log(LogLevel level, char* message, char* filename, int line);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;//in .cpp file:
void DMSLogger::Log(LogLevel level, char* message, char* filename, int line)
{
  msg = gcnew System::String(message);
  ...
  //Call the C# method
  ManagedLogger::DMSLogger::Log(level ,msg);
}

//Fortran-callable C wrapper:
extern "C"
{
  void DLLEXPORT DMSLogger_Log(DMSLogger::LogLevel level, char* message)
  {
    DMSLogger::Log(level, message, "", 0);
  }
}
[/cpp]&lt;/PRE&gt; 

&lt;BR /&gt;Finally, the Fortran interface and call:&lt;BR /&gt;&lt;PRE&gt;[fortran]interface
  subroutine DMSLogger_Log(level, message) bind(C, name="DMSLogger_Log")
      import
      integer(LogLevel), value:: level
      character:: message(*)
   end subroutine
end interface
...
call DMSLogger_Log(Error, "LoadFlow_SetCustomData has failed. Aborting...")
[/fortran]&lt;/PRE&gt; &lt;BR /&gt;This has one wrapper more than you probably need (long story...), but you should be able to call the &lt;BR /&gt;managed method directly from an extern "C" C++ CLR wrapper (DMSLogger_Log in my example).&lt;BR /&gt;</description>
      <pubDate>Wed, 06 Oct 2010 09:00:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811263#M42813</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2010-10-06T09:00:25Z</dc:date>
    </item>
    <item>
      <title>calling C# dll from FORTRAN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811264#M42814</link>
      <description>Thank you for your nice suggestion. I'll go through it.&lt;BR /&gt;&lt;BR /&gt;Krishna</description>
      <pubDate>Wed, 06 Oct 2010 10:36:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811264#M42814</guid>
      <dc:creator>krishnabc</dc:creator>
      <dc:date>2010-10-06T10:36:05Z</dc:date>
    </item>
    <item>
      <title>calling C# dll from FORTRAN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811265#M42815</link>
      <description>I and my colleage tried to link the Fortran with managed C++ DLL, butwe got the linking problem at the first place. We got the following error:&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;&amp;gt;FortranCA.obj : error LNK2019: unresolved external symbol _maxx referenced in function _MAIN__&lt;/P&gt;&lt;P&gt;&amp;gt;Debug\FortranCA.exe : fatal error LNK1120: 1 unresolved externals&lt;BR /&gt;&lt;BR /&gt;I thinkwe are missing something. The example code is attached for more details. This example is a slightly modified version of the example from &lt;BR /&gt;&lt;A href="http://software.intel.com/en-us/forums/showthread.php?t=66501"&gt;http://software.intel.com/en-us/forums/showthread.php?t=66501&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2010 04:59:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811265#M42815</guid>
      <dc:creator>krishnabc</dc:creator>
      <dc:date>2010-10-20T04:59:36Z</dc:date>
    </item>
    <item>
      <title>calling C# dll from FORTRAN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811266#M42816</link>
      <description>See the attachment. You had several errors:&lt;BR /&gt;&lt;BR /&gt;1) The DEC$ATTRIBUTES ALIAS was misspelled (two colons instead of one). (now commented out)&lt;BR /&gt;2) In general, do not mix BIND(C) and !DEC$ATTRIBUTES; they don't go along well. I commented out the later, and added NAME= to the former&lt;BR /&gt;3) There is no real need for STDCALL (and since it doesn't go along with BIND(C), I removed it)&lt;BR /&gt;4) The solution setup was messy (and still is, partly). I reconfigured both projects to produce output in $(SolutionDir)$(ConfigurationName). &lt;BR /&gt;&lt;BR /&gt;For some reason, Project/Dependencies does not make linker recognize location of CPPLib. I had to add it through Linker/Input/Additional dependencies. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Oct 2010 09:37:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811266#M42816</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2010-10-20T09:37:32Z</dc:date>
    </item>
    <item>
      <title>calling C# dll from FORTRAN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811267#M42817</link>
      <description>&lt;P&gt;Dear Jugoslav,&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your valuable comments. However, I am unable to download the correction version. It says "Page not found". Can I give you a troubleto upload it again?&lt;BR /&gt;&lt;BR /&gt;Krishna&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2010 09:55:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811267#M42817</guid>
      <dc:creator>krishnabc</dc:creator>
      <dc:date>2010-10-20T09:55:24Z</dc:date>
    </item>
    <item>
      <title>calling C# dll from FORTRAN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811268#M42818</link>
      <description>It works for me, even when I'm logged out. Try refreshing the page, or perhaps another browser?</description>
      <pubDate>Wed, 20 Oct 2010 10:45:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811268#M42818</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2010-10-20T10:45:50Z</dc:date>
    </item>
    <item>
      <title>calling C# dll from FORTRAN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811269#M42819</link>
      <description>Download worked for me too.&lt;BR /&gt;Les</description>
      <pubDate>Wed, 20 Oct 2010 10:55:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811269#M42819</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2010-10-20T10:55:55Z</dc:date>
    </item>
    <item>
      <title>calling C# dll from FORTRAN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811270#M42820</link>
      <description>Many thanks. Today I can download after clearing Cookies, etc. Actually this is my first experience of mixed language programming. We (I and my colleague) tried several possibilities and were struggling over the past few days. We had also tried the way you have corrected, but somehow we were unable to make it work. We greatly appreciate your help and correction.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Oct 2010 02:09:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-C-dll-from-FORTRAN/m-p/811270#M42820</guid>
      <dc:creator>krishnabc</dc:creator>
      <dc:date>2010-10-21T02:09:34Z</dc:date>
    </item>
  </channel>
</rss>

