<?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: Fortran calls C in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831439#M52682</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks Lars,&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;I've managed calling conventions and name mangling ;-)&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;I'm working on the problem how to use the (char**) in Fortran.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;There are two ideas:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;1. CVF has a lot of extensions that could solve the problem,e&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;.g. integer pointer. Unfortunately not standard.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;2. Probably better: write a C-wrapper.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;Toni&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 05 May 2005 03:26:20 GMT</pubDate>
    <dc:creator>Intel_C_Intel</dc:creator>
    <dc:date>2005-05-05T03:26:20Z</dc:date>
    <item>
      <title>Fortran calls C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831437#M52680</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;Hi,&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;I'm brushing up my Fortran- and C-knowledge &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;because I have to call C-functions &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;(I only have the static library and header)&lt;BR /&gt;from Fortran. The basic stuff (naming and calling&lt;BR /&gt;conventions) is already done and works, &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;one problem remains:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;How do I call the following:&lt;BR /&gt;extern void Cfunc1(char** Result);&lt;BR /&gt;which returns a pointer to a pointer to a string?&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;The other way round (passing a string to a Cfunction)&lt;BR /&gt;I managed with an interface:&lt;BR /&gt;extern void Cfunc2(const char* str);&lt;BR /&gt;INTEGER(4) FUNCTION Cfunc2[C, ALIAS:'_Cfunc2'](str)&lt;BR /&gt; CHARACTER*(*)str [REFERENCE]&lt;BR /&gt;END FUNCTION Cfunc2&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;Thx in advance for hints,&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;Toni&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 04 May 2005 01:28:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831437#M52680</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2005-05-04T01:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran calls C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831438#M52681</link>
      <description>Hello.

I you are using a C++ compiler, you can either use the compiler option /TC to avoid C++ mangling or write &amp;lt; extern "C" &amp;gt; before the function. Also you need to have the same calling convention, for examptle __stdcall or __cdecl to make it work. Regarding pointer to a pointer to a string, I think that it will be possible to pass the pointer from C to Fortran, but I am not sure how you could use that pointer the best way on the Fortran side. Maybe the workaround may be to pass pointer to string only and instead rewrite the code to pass all the string pointers you need to transfer.

Lars Petter</description>
      <pubDate>Wed, 04 May 2005 23:52:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831438#M52681</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2005-05-04T23:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran calls C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831439#M52682</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks Lars,&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;I've managed calling conventions and name mangling ;-)&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;I'm working on the problem how to use the (char**) in Fortran.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;There are two ideas:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;1. CVF has a lot of extensions that could solve the problem,e&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;.g. integer pointer. Unfortunately not standard.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;2. Probably better: write a C-wrapper.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;Toni&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 05 May 2005 03:26:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831439#M52682</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2005-05-05T03:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran calls C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831440#M52683</link>
      <description>There's an entire chapter in the CVF Programmer's Guide/IVF User Manual on mixed-language programming.  It tells you most everything you need to know.  There are also samples provided with CVF.</description>
      <pubDate>Thu, 05 May 2005 03:41:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831440#M52683</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-05-05T03:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran calls C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831441#M52684</link>
      <description>&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks Steve,&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;from these ressoruces I learnt to call C from Fortran,&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;even to access a C-DLL dynamically.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;The remaining problem is how to use a (char**) returned by a C-routine.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;Regards, Toni&lt;/FONT&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 05 May 2005 20:01:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831441#M52684</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2005-05-05T20:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran calls C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831442#M52685</link>
      <description>C is not my best language - that's a pointer to something which is a pointer to characters?  You'd do something like this&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;integer(int_ptr_kind()) :: pchar&lt;BR /&gt;character(*) :: string&lt;BR /&gt;pointer (p1, pchar)&lt;BR /&gt;pointer (p2, string)&lt;BR /&gt;&lt;BR /&gt;call c_routine (p1)&lt;BR /&gt;! p1 has the char** value&lt;BR /&gt;p2 = pchar ! Dereference through p1&lt;BR /&gt;! Now you can access string&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 May 2005 20:23:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831442#M52685</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-05-05T20:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran calls C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831443#M52686</link>
      <description>&lt;DIV&gt;Well, I'm not very experienced in C, too.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Your code looks good, I'll try it!&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Thanks, Toni&lt;/DIV&gt;</description>
      <pubDate>Fri, 06 May 2005 00:00:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-calls-C/m-p/831443#M52686</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2005-05-06T00:00:52Z</dc:date>
    </item>
  </channel>
</rss>

