<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Approximatrix Forums — Problem with modules]]></title>
		<link>http://forums.approximatrix.com/viewtopic.php?id=896</link>
		<atom:link href="http://forums.approximatrix.com/extern.php?action=feed&amp;tid=896&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Problem with modules.]]></description>
		<lastBuildDate>Wed, 10 May 2023 20:28:25 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Problem with modules]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=4106#p4106</link>
			<description><![CDATA[<p>It sounds like you&#039;re not including <em>both</em> Fortran source files in your project in the second case.&nbsp; The compiler (the linker, to be technically correct), cannot find the definition of the procedure.&nbsp; I&#039;m guessing it is because you are compiling the new Fortran file in the same directory as the original (such that it sees the module&#039;s compiler definition output).&nbsp; However, the linker has no reason to go looking for any particular object file unless the original source file is included in a project.</p><p>Try adding the module&#039;s source file to your project with <em>testmain.f90</em> and everything should work as expected.</p><p>Just a note: <strong>*.mod</strong> files produced by the Fortran compiler do <em>not</em> contain any compiled code.&nbsp; Rather they contain some definitions that the compiler might need when dealing with modules.&nbsp; Object files contain the actual compiled code.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Wed, 10 May 2023 20:28:25 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=4106#p4106</guid>
		</item>
		<item>
			<title><![CDATA[Problem with modules]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=4105#p4105</link>
			<description><![CDATA[<p>I&#039;m new to modern Fortran, and to Simply Fortran, which I downloaded a few days ago.&nbsp; Here&#039;s my problem.&nbsp; I built the following module:</p><p>module months<br />&nbsp; &nbsp; implicit none<br />&nbsp; &nbsp; integer, parameter, dimension(12) :: days_per_month = [31,28,31,30,31,30,31,31,30,31,30,31]<br />&nbsp; &nbsp; character(len = 9), parameter, dimension(12) :: month_names = [character(len=9) :: &#039;January&#039;,&#039;February&#039;,&#039;March&#039;,&#039;April&#039;,&#039;May&#039;,&amp;<br />&nbsp; &nbsp; &#039;June&#039;,&#039;July&#039;,&#039;August&#039;,&#039;September&#039;,&#039;October&#039;,&#039;November&#039;,&#039;December&#039;]<br />end module</p><p>The following program compiles and runs:</p><p>program test<br />use months<br />implicit none</p><p>write(*,*) days_per_month(1)</p><p>end program</p><p>but this program won&#039;t even compile:</p><p>program test<br />use months<br />implicit none</p><p>integer :: i</p><p>do i = 1,12<br />write(*,*) days_per_month(i)<br />end do</p><p>end program</p><p>The error message that I get is:</p><p>Generating target.exe<br />build\testmain.o:testmain.f90:(.rdata$.refptr.__months_MOD_days_per_month[.refptr.__months_MOD_days_per_month]+0x0): undefined reference to `__months_MOD_days_per_month&#039;<br />collect2.exe: error: ld returned 1 exit status<br />Error: Last command making (target.exe) returned a bad status<br />Error: Make execution terminated</p><p>* Failed *</p><p>The file is saved as test.f90, and I did not change any compiler defaults.&nbsp; What am I doing wrong??</p>]]></description>
			<author><![CDATA[null@example.com (bobsrussell)]]></author>
			<pubDate>Wed, 10 May 2023 00:51:54 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=4105#p4105</guid>
		</item>
	</channel>
</rss>
