<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Automatic generation of a C header from Fortran code?</title>
	<atom:link href="http://blue-dwarf.de/wp/2009/10/31/automatic-generation-of-a-c-header-from-fortran-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://blue-dwarf.de/wp/2009/10/31/automatic-generation-of-a-c-header-from-fortran-code/</link>
	<description>Frank&#039;s blog and obviously not an early-type main sequence star</description>
	<lastBuildDate>Sun, 15 Nov 2009 18:00:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Frank</title>
		<link>http://blue-dwarf.de/wp/2009/10/31/automatic-generation-of-a-c-header-from-fortran-code/comment-page-1/#comment-3537</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 Nov 2009 08:49:18 +0000</pubDate>
		<guid isPermaLink="false">http://blue-dwarf.de/wp/?p=610#comment-3537</guid>
		<description>@jldugger; ANTLR grammar:
The first interesting Google hit for &quot;Fortran ANTLR grammar&quot; pointed to the &lt;a href=&quot;http://fortran-parser.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;Open Fortran Parser&lt;/a&gt; which looked promising but I encountered some problems while compiling it that I couldn&#039;t fix easily. Thus I didn&#039;t look further into it.

@Alberto; ISO_C_BINDING + Doxygen parser:
Alberto, you are of course right that the intrinsic Fortran 2003 module ISO_C_BINDING solves the problem of name mangling and knowing the right C types for the corresponding Fortran types. But if one is bound to older Fortran standards this is not an option. I also tried to &quot;misuse&quot; Doxygen for what I want to accomplish but instead of touching the parser code, I looked into transforming Doxygen&#039;s XML output to C declarations. But it seemed that the types of function parameters weren&#039;t available in the XML output. So I also skipped this option.

@PeterP; DWARF debugging infos:
Using debugging infos from object files to create source code is another interesting idea. I actually wrote a simple and half done script (&lt;a href=&quot;http://blue-dwarf.de/download/misc/dwarf2cdecl.py.txt&quot; rel=&quot;nofollow&quot;&gt;dwarf2cdecl.py&lt;/a&gt;) that can extract functions with their parameters from the output of &lt;code&gt;dwarfdump -di&lt;/code&gt;. However, I think that this approach is to fragile and not as straightforward as I&#039;d like it.

So I&#039;m still open to suggestions.</description>
		<content:encoded><![CDATA[<p>@jldugger; ANTLR grammar:<br />
The first interesting Google hit for &#8220;Fortran ANTLR grammar&#8221; pointed to the <a href="http://fortran-parser.sourceforge.net/" rel="nofollow">Open Fortran Parser</a> which looked promising but I encountered some problems while compiling it that I couldn&#8217;t fix easily. Thus I didn&#8217;t look further into it.</p>
<p>@Alberto; ISO_C_BINDING + Doxygen parser:<br />
Alberto, you are of course right that the intrinsic Fortran 2003 module ISO_C_BINDING solves the problem of name mangling and knowing the right C types for the corresponding Fortran types. But if one is bound to older Fortran standards this is not an option. I also tried to &#8220;misuse&#8221; Doxygen for what I want to accomplish but instead of touching the parser code, I looked into transforming Doxygen&#8217;s XML output to C declarations. But it seemed that the types of function parameters weren&#8217;t available in the XML output. So I also skipped this option.</p>
<p>@PeterP; DWARF debugging infos:<br />
Using debugging infos from object files to create source code is another interesting idea. I actually wrote a simple and half done script (<a href="http://blue-dwarf.de/download/misc/dwarf2cdecl.py.txt" rel="nofollow">dwarf2cdecl.py</a>) that can extract functions with their parameters from the output of <code>dwarfdump -di</code>. However, I think that this approach is to fragile and not as straightforward as I&#8217;d like it.</p>
<p>So I&#8217;m still open to suggestions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PeterP</title>
		<link>http://blue-dwarf.de/wp/2009/10/31/automatic-generation-of-a-c-header-from-fortran-code/comment-page-1/#comment-3501</link>
		<dc:creator>PeterP</dc:creator>
		<pubDate>Sun, 01 Nov 2009 20:40:02 +0000</pubDate>
		<guid isPermaLink="false">http://blue-dwarf.de/wp/?p=610#comment-3501</guid>
		<description>If your Fortran compiler can be set to generate output object files in the ELF format (see http://en.wikipedia.org/wiki/Executable_and_Linkable_Format) with debug info, type information for all symbols in the global symbol table can be found in the debug sections (see http://dwarfstd.org/Dwarf3.pdf for the debug info specification).

It should be straightforward to convert this into the corresponding C declarations.
As the info comes from the object file, this also means that the mapping from unmangled to mangled names must be in the file, too (otherwise source code debugging would not work), courtesy of your compiler!</description>
		<content:encoded><![CDATA[<p>If your Fortran compiler can be set to generate output object files in the ELF format (see <a href="http://en.wikipedia.org/wiki/Executable_and_Linkable_Format)" rel="nofollow">http://en.wikipedia.org/wiki/Executable_and_Linkable_Format)</a> with debug info, type information for all symbols in the global symbol table can be found in the debug sections (see <a href="http://dwarfstd.org/Dwarf3.pdf" rel="nofollow">http://dwarfstd.org/Dwarf3.pdf</a> for the debug info specification).</p>
<p>It should be straightforward to convert this into the corresponding C declarations.<br />
As the info comes from the object file, this also means that the mapping from unmangled to mangled names must be in the file, too (otherwise source code debugging would not work), courtesy of your compiler!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alberto</title>
		<link>http://blue-dwarf.de/wp/2009/10/31/automatic-generation-of-a-c-header-from-fortran-code/comment-page-1/#comment-3500</link>
		<dc:creator>Alberto</dc:creator>
		<pubDate>Sun, 01 Nov 2009 09:02:15 +0000</pubDate>
		<guid isPermaLink="false">http://blue-dwarf.de/wp/?p=610#comment-3500</guid>
		<description>As you say, the problem has two parts:

1. Name mangling, different between compilers.
2. Writing the prototype.

In order to solve the first, consider using the new ISO C bindings. Take a look from the page 31 in ftp://ftp.nag.co.uk/sc22wg5/N1601-N1650/N1648.pdf . 

The second part would be a matter of writing a filter, or learning from Doxygen code how it parses Fortran structures.</description>
		<content:encoded><![CDATA[<p>As you say, the problem has two parts:</p>
<p>1. Name mangling, different between compilers.<br />
2. Writing the prototype.</p>
<p>In order to solve the first, consider using the new ISO C bindings. Take a look from the page 31 in <a href="ftp://ftp.nag.co.uk/sc22wg5/N1601-N1650/N1648.pdf" rel="nofollow">ftp://ftp.nag.co.uk/sc22wg5/N1601-N1650/N1648.pdf</a> . </p>
<p>The second part would be a matter of writing a filter, or learning from Doxygen code how it parses Fortran structures.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jldugger</title>
		<link>http://blue-dwarf.de/wp/2009/10/31/automatic-generation-of-a-c-header-from-fortran-code/comment-page-1/#comment-3499</link>
		<dc:creator>jldugger</dc:creator>
		<pubDate>Sun, 01 Nov 2009 00:50:18 +0000</pubDate>
		<guid isPermaLink="false">http://blue-dwarf.de/wp/?p=610#comment-3499</guid>
		<description>I don&#039;t know of such a tool, but you can probably find an ANTLR grammar for fortran and write a quick program to process the AST for declarations. Just implement the right toString() functions and a decorator and you&#039;re done!</description>
		<content:encoded><![CDATA[<p>I don&#8217;t know of such a tool, but you can probably find an ANTLR grammar for fortran and write a quick program to process the AST for declarations. Just implement the right toString() functions and a decorator and you&#8217;re done!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
