<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — code.f do loop with real values warning]]></title>
	<link rel="self" href="http://forums.approximatrix.com/extern.php?action=feed&amp;tid=473&amp;type=atom" />
	<updated>2015-06-12T07:30:38Z</updated>
	<generator>PunBB</generator>
	<id>http://forums.approximatrix.com/viewtopic.php?id=473</id>
		<entry>
			<title type="html"><![CDATA[Re: code.f do loop with real values warning]]></title>
			<link rel="alternate" href="http://forums.approximatrix.com/viewtopic.php?pid=2126#p2126" />
			<content type="html"><![CDATA[<p>Sorry, but in scientific computing, we usually prefer the Jeff&#039;s solution. For two reasons:<br />1) Today, floating-point multiplication and addition have very close latencies. See for example the discussion in:<br />&nbsp; &nbsp; <a href="http://stackoverflow.com/questions/1146455/whats-the-relative-speed-of-floating-point-add-vs-floating-point-multiply">http://stackoverflow.com/questions/1146 … t-multiply</a><br />&nbsp; &nbsp; In the past, the old FORTRAN programmers were used to write<br />&nbsp; &nbsp; </p><div class="codebox"><pre><code>x = a + a</code></pre></div><p>&nbsp; &nbsp; instead of<br />&nbsp; &nbsp; </p><div class="codebox"><pre><code>x = 2*a</code></pre></div><p>&nbsp; &nbsp; but the first layout is less clear than the second one. The reason was only performance. It makes no sense today...<br />2) The Jeff&#039;s solution, which compute RMU directly will not lead to roundoff errors!<br />&nbsp; &nbsp; Generally speaking, avoid a long summation of floating-point numbers, otherwise there is a great risk to obtain the last value<br />&nbsp; &nbsp; greater than that expected. In some situation (a function defined only on a given interval), this may be critical.</p>]]></content>
			<author>
				<name><![CDATA[ecanot]]></name>
				<uri>http://forums.approximatrix.com/profile.php?id=3380</uri>
			</author>
			<updated>2015-06-12T07:30:38Z</updated>
			<id>http://forums.approximatrix.com/viewtopic.php?pid=2126#p2126</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: code.f do loop with real values warning]]></title>
			<link rel="alternate" href="http://forums.approximatrix.com/viewtopic.php?pid=2125#p2125" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>davidb wrote:</cite><blockquote><p>Though Jeff&#039;s code will work, I prefer the following alternative, which gives RMU the correct value after the loop and eliminates the multiplication.</p></blockquote></div><p>Ah yes, David&#039;s code would definitely be preferable.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>http://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2015-06-11T12:22:15Z</updated>
			<id>http://forums.approximatrix.com/viewtopic.php?pid=2125#p2125</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: code.f do loop with real values warning]]></title>
			<link rel="alternate" href="http://forums.approximatrix.com/viewtopic.php?pid=2124#p2124" />
			<content type="html"><![CDATA[<p>Some history:</p><p>Real valued indices for DO loops were allowed in Fortran 77. However, this feature was removed in Fortran 90.</p><p>If you want to remove the warning completely then you can use the option</p><p>-std=legacy or enforce the legacy standard in Project Options in Simply Fortran&#039;s GUI.</p><p>Though Jeff&#039;s code will work, I prefer the following alternative, which gives RMU the correct value after the loop and eliminates the multiplication.</p><div class="codebox"><pre><code>RMU = 0.0
DO IRMU=1, 101

    ! Original loop body

    ! Increase RMU at end
    RMU = RMU + 0.01

END DO</code></pre></div>]]></content>
			<author>
				<name><![CDATA[davidb]]></name>
				<uri>http://forums.approximatrix.com/profile.php?id=3463</uri>
			</author>
			<updated>2015-06-11T06:13:59Z</updated>
			<id>http://forums.approximatrix.com/viewtopic.php?pid=2124#p2124</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: code.f do loop with real values warning]]></title>
			<link rel="alternate" href="http://forums.approximatrix.com/viewtopic.php?pid=2123#p2123" />
			<content type="html"><![CDATA[<p>The message is only a warning, so you can leave it as is.&nbsp; I have plenty of code that causes this warning to appear myself.&nbsp; However, to get around it, you&#039;d probably do something like:</p><div class="codebox"><pre><code>       DO 50  IRMU = 0, 100
           RMU = REAL(IRMU)*0.01 
           ...</code></pre></div><p>The above would be technically correct.&nbsp; However, I tend to just ignore that warning myself.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>http://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2015-06-10T22:37:27Z</updated>
			<id>http://forums.approximatrix.com/viewtopic.php?pid=2123#p2123</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[code.f do loop with real values warning]]></title>
			<link rel="alternate" href="http://forums.approximatrix.com/viewtopic.php?pid=2122#p2122" />
			<content type="html"><![CDATA[<p>I have code that has a do loop that gives this warning.</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DO 50&nbsp; RMU = 0.0, 1.0, 0.01&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<br />Warning: Deleted feature: Loop variable at (1) must be integer</p><p>What should I do?<br />Thanks</p>]]></content>
			<author>
				<name><![CDATA[kmutiny]]></name>
				<uri>http://forums.approximatrix.com/profile.php?id=3620</uri>
			</author>
			<updated>2015-06-10T21:15:51Z</updated>
			<id>http://forums.approximatrix.com/viewtopic.php?pid=2122#p2122</id>
		</entry>
</feed>
