<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Approximatrix Forums — Translate FORTRAN to C++ for CUDA]]></title>
		<link>https://forums.approximatrix.com/viewtopic.php?id=967</link>
		<atom:link href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=967&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Translate FORTRAN to C++ for CUDA.]]></description>
		<lastBuildDate>Fri, 22 Nov 2024 20:12:52 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Translate FORTRAN to C++ for CUDA]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=4392#p4392</link>
			<description><![CDATA[<div class="quotebox"><cite>grogley wrote:</cite><blockquote><p>Will SF compile a C++ subroutine (not the brightest bulb in the programing universe)?</p></blockquote></div><p>Yes, Simply Fortran for Windows includes g++, and the development environment should handle it.&nbsp; The only issue you will have is linking.&nbsp; You&#039;ll need to add a flag to <em>Linker</em> under <em>Compiler Flags</em> in <em>Project Options</em>:</p><div class="codebox"><pre><code>-lstdc++</code></pre></div><p>That additional flag is necessary purely because Simply Fortran will use the Fortran compiler frontend for linking, and it won&#039;t automatically include the C++ standard library.</p><div class="quotebox"><cite>grogley wrote:</cite><blockquote><p>In that event I can&#039;t use the SF environment, I have downloaded the latest GNU files for Windows</p></blockquote></div><p>This step was probably unnecessary, but that&#039;s okay.&nbsp; We include the C and C++ compilers as well as most of the Windows-specific libraries.</p><div class="quotebox"><cite>grogley wrote:</cite><blockquote><p>How can I be sure it is using the non-SF path for compile and link?</p></blockquote></div><p>You can execute the commands:</p><div class="codebox"><pre><code>gfortran --version</code></pre></div><div class="codebox"><pre><code>gcc --version</code></pre></div><div class="codebox"><pre><code>g++ --version</code></pre></div><p>The Simply Fortran compilers should include the text <em>GCC for Simply Fortran</em>.</p><div class="quotebox"><cite>grogley wrote:</cite><blockquote><p>Apparently the forum editor will not allow me to cut and paste the code.</p></blockquote></div><p>That should work; I do it regularly.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Fri, 22 Nov 2024 20:12:52 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=4392#p4392</guid>
		</item>
		<item>
			<title><![CDATA[Re: Translate FORTRAN to C++ for CUDA]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=4391#p4391</link>
			<description><![CDATA[<p>Thanks Jeff!</p><p>My starting point for this project is just get FORTRAN to call a C++ subroutine. It looks like I have to work outside the confines of SF compile and link stages... but if not how to do this since I think the C++ file needs to be compiled first to object code then linked to the FORTRAN compile link stage. Will SF compile a C++ subroutine (not the brightest bulb in the programing universe)?</p><p>In that event I can&#039;t use the SF environment, I have downloaded the latest GNU files for Windows but I think given the path for these new files, the compile stage is going to SF path. How can I be sure it is using the non-SF path for compile and link? </p><p>What I am doing specifically, a friend told me about Copilot (This a revelation to me, seems like cheating!) and it gave an example of a mixed FORTRAN calling a C++ subroutine. So I am trying to compile and link this example.</p><p>Apparently the forum editor will not allow me to cut and paste the code.</p><p>Thanks again in advance. Sorry to waste your time if this is not in the SF frameworks. <br />Rod</p>]]></description>
			<author><![CDATA[null@example.com (grogley)]]></author>
			<pubDate>Fri, 22 Nov 2024 16:01:06 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=4391#p4391</guid>
		</item>
		<item>
			<title><![CDATA[Re: Translate FORTRAN to C++ for CUDA]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=4390#p4390</link>
			<description><![CDATA[<p>Rod,</p><p>You&#039;ll want to use the <strong>ISO_C_BINDING</strong> intrinsic module for calling C++ routines. You will need to create a C interface to your C++ routines, though, but that issue is common to many C++ libraries that expose their API.&nbsp; Fortran has no concept of C++ classes, so they&#039;ll appear as opaque <em>type(c_ptr)</em> arguments in Fortran.</p><p>You&#039;ll want to look at the <a href="https://simplyfortran.com/docs/compiler/ISO_005fC_005fBINDING.html#ISO_005fC_005fBINDING">ISO_C_BINDING module</a> and the <a href="https://simplyfortran.com/docs/compiler/Interoperability-with-C.html#Interoperability-with-C">section on interoperability with C</a> as a starting point, at least.&nbsp; If you plan on really getting into this, you might consider a book on modern Fortran that would explain using ISO_C_BINDING.</p><p><em>EDIT</em>: You&#039;ll also likely run into linking issues.&nbsp; What your purporting to do isn&#039;t particularly easy or straightforward as you&#039;ll be using an additional compiler for all the CUDA code.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Wed, 20 Nov 2024 19:19:31 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=4390#p4390</guid>
		</item>
		<item>
			<title><![CDATA[Translate FORTRAN to C++ for CUDA]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=4389#p4389</link>
			<description><![CDATA[<p>Hello All,</p><p>Its been a couple of years since last post and I haven&#039;t seen this topic in the the forum and apologize if I missed it.</p><p>I have my OpenMP FORTRAN simulation that I am thinking about converting to use multi-processing capabilities of CUDA cores. I would like to continue to use Windows as my development and runtime platform. I have done a cursory look at this and this seems possible. However, I don&#039;t want to rewrite the entire code into C++. I think SF (never attempted this) supports C++ subroutines called from FORTRAN, would it be possible to create CUDA C++ subroutines called from in my SF FORTRAN compile and link?</p><p>Thanks in advance,<br />Rod</p>]]></description>
			<author><![CDATA[null@example.com (grogley)]]></author>
			<pubDate>Wed, 20 Nov 2024 14:49:26 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=4389#p4389</guid>
		</item>
	</channel>
</rss>
