<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Approximatrix Forums — code.f do loop with real values warning]]></title>
		<link>http://forums.approximatrix.com/viewtopic.php?id=473</link>
		<atom:link href="http://forums.approximatrix.com/extern.php?action=feed&amp;tid=473&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in code.f do loop with real values warning.]]></description>
		<lastBuildDate>Fri, 12 Jun 2015 07:30:38 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: code.f do loop with real values warning]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=2126#p2126</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (ecanot)]]></author>
			<pubDate>Fri, 12 Jun 2015 07:30:38 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=2126#p2126</guid>
		</item>
		<item>
			<title><![CDATA[Re: code.f do loop with real values warning]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=2125#p2125</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Thu, 11 Jun 2015 12:22:15 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=2125#p2125</guid>
		</item>
		<item>
			<title><![CDATA[Re: code.f do loop with real values warning]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=2124#p2124</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (davidb)]]></author>
			<pubDate>Thu, 11 Jun 2015 06:13:59 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=2124#p2124</guid>
		</item>
		<item>
			<title><![CDATA[Re: code.f do loop with real values warning]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=2123#p2123</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Wed, 10 Jun 2015 22:37:27 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=2123#p2123</guid>
		</item>
		<item>
			<title><![CDATA[code.f do loop with real values warning]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=2122#p2122</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (kmutiny)]]></author>
			<pubDate>Wed, 10 Jun 2015 21:15:51 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=2122#p2122</guid>
		</item>
	</channel>
</rss>
