<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Approximatrix Forums — undefined reference to a subroutine]]></title>
		<link>http://forums.approximatrix.com/viewtopic.php?id=973</link>
		<atom:link href="http://forums.approximatrix.com/extern.php?action=feed&amp;tid=973&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in undefined reference to a subroutine.]]></description>
		<lastBuildDate>Thu, 30 Jan 2025 23:58:29 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: undefined reference to a subroutine]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=4426#p4426</link>
			<description><![CDATA[<p>yes, and tried the f90 extension, some incompatible issues with syntax erros, invalid characters, etc... from those subroutines. Thanks.</p>]]></description>
			<author><![CDATA[null@example.com (mt1234)]]></author>
			<pubDate>Thu, 30 Jan 2025 23:58:29 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=4426#p4426</guid>
		</item>
		<item>
			<title><![CDATA[Re: undefined reference to a subroutine]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=4423#p4423</link>
			<description><![CDATA[<p>Did you put them directly in a file named <em>my_subroutines.mod</em>? <strong>Module files (.mod)</strong> are output by the compiler when it encounters a module statement in a <strong>Fortran source file (.f90, etc.)</strong>.&nbsp; You should <strong>never</strong> be manually creating a <strong>.mod</strong> file.&nbsp; The should just be in a normal Fortran source file, perhaps <em>my_subroutines.f90</em>.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Thu, 30 Jan 2025 21:32:28 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=4423#p4423</guid>
		</item>
		<item>
			<title><![CDATA[Re: undefined reference to a subroutine]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=4422#p4422</link>
			<description><![CDATA[<p>Thanks. It seems that my problems are just compounding on top of each other. I put the subroutine in question along with 9 or 10 of its dependencies in a module but the main program won&#039;t compile, complaining that File &#039;my_subroutines.mod&#039; opened at (1) is not a GNU Fortran module file. These are subroutines from my old nag library. I&#039;ll keep trying.</p>]]></description>
			<author><![CDATA[null@example.com (mt1234)]]></author>
			<pubDate>Thu, 30 Jan 2025 19:02:38 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=4422#p4422</guid>
		</item>
		<item>
			<title><![CDATA[Re: undefined reference to a subroutine]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=4421#p4421</link>
			<description><![CDATA[<p>The call to <em>G05FEF</em> is indeed undefined. When you declare <em>implicit none</em>, the Fortran compiler will not make any assumptions about anything, especially the signature of a subroutine.&nbsp; You need to do something such that the Fortran compiler knows what <em>G05FEF</em> is.</p><p>The more modern technique would be to place <em>G05FEF</em> in a module:</p><div class="codebox"><pre><code>module my_subroutines
implicit none

    contains

    subroutine G05FEF(a, b, i, s, fail_flag)
        ! body of G05FEF
        ! ...
    end subroutine G05FEF

end module my_subroutines</code></pre></div><p>and then your program would just be:</p><div class="codebox"><pre><code>program test
use my_subroutines
implicit none

Double Precision s(10)
INTEGER IFAIL

Call G05FEF(0.5D0,0.5D0,10,s,IFAIL)

print *, &quot;s is&quot;, s

end program test</code></pre></div><p>If <em>G05FEF</em> is already in a module, make sure you add the module to your program with a <strong>USE</strong> statement.</p><p>Alternatively, you can create an interface block to define the subroutine in your main program:</p><div class="codebox"><pre><code>program test
implicit none

Double Precision s(10)
INTEGER IFAIL

interface
    subroutine G05FEF(a, b, i, s, fail_flag)
    real(kind=8)::a, b
    integer::i, fail_flag
    real(kind=8), dimension(*)::s
end interface

Call G05FEF(0.5D0,0.5D0,10,s,IFAIL)

print *, &quot;s is&quot;, s

end program test</code></pre></div><p>It can be a bit messier, but it allows using legacy routines that aren&#039;t inside a module.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Thu, 30 Jan 2025 14:02:35 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=4421#p4421</guid>
		</item>
		<item>
			<title><![CDATA[undefined reference to a subroutine]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=4420#p4420</link>
			<description><![CDATA[<p>Just installed Simply Fortran on Windows11, tried to build and run a simple program</p><p>program test<br />implicit none</p><p>Double Precision s(10)<br />INTEGER IFAIL</p><p>Call G05FEF(0.5D0,0.5D0,10,s,IFAIL)</p><p>print *, &quot;s is&quot;, s</p><p>end program test</p><p>that calls some functions and routines, which I added to the project outline. Project building&nbsp; looks fine, with message Generating Makefile ... Okay, * Complete*, but when I compile and run the program file, I get the message undefined reference to &#039;g05fef_&#039;. Any help is greatly appreciated.</p>]]></description>
			<author><![CDATA[null@example.com (mt1234)]]></author>
			<pubDate>Wed, 29 Jan 2025 22:05:46 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=4420#p4420</guid>
		</item>
	</channel>
</rss>
