<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Approximatrix Forums — Use Double Precision for All Reals checkbox]]></title>
		<link>http://forums.approximatrix.com/viewtopic.php?id=831</link>
		<atom:link href="http://forums.approximatrix.com/extern.php?action=feed&amp;tid=831&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Use Double Precision for All Reals checkbox.]]></description>
		<lastBuildDate>Tue, 21 Dec 2021 19:07:43 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Use Double Precision for All Reals checkbox]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=3827#p3827</link>
			<description><![CDATA[<p>Addendum to my previous post by replacing x.d0 with x._qp</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Compare precision of sp, dp, and qp:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; x=1.234_sp, 1.234_dp, 1.234_qp<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23399997<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23399997<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23399997</p><p>&nbsp; &nbsp; &nbsp; &nbsp; y=1.234_sp, 1.234_dp, 1.234_qp<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.2339999675750732<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.2340000000000000<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.2340000000000000</p><p>&nbsp; &nbsp; &nbsp; &nbsp; z=1.234_sp, 1.234_dp, 1.234_qp<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23399996757507324218750000000000000<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23399999999999998578914528479799628<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23399999999999999999999999999999991</p><p>&nbsp; &nbsp; &nbsp; &nbsp; x=1.2345_sp, 1.2345_dp, 1.2345_qp<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23450005<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23450005<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23450005</p><p>&nbsp; &nbsp; &nbsp; &nbsp; y=1.2345_sp, 1.2345_dp, 1.2345_qp<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.2345000505447388<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.2344999999999999<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.2344999999999999</p><p>&nbsp; &nbsp; &nbsp; &nbsp; z=1.2345_sp, 1.2345_dp, 1.2345_qp<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23450005054473876953125000000000000<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23449999999999993072208326339023188<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23450000000000000000000000000000009</p><p>&nbsp; &nbsp; &nbsp; &nbsp; x=1.23456_sp, 1.23456_dp, 1.23456_qp<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23456001<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23456001<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23456001</p><p>&nbsp; &nbsp; &nbsp; &nbsp; y=1.23456_sp, 1.23456_dp, 1.23456_qp<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.2345600128173828<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.2345600000000001<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.2345600000000001</p><p>&nbsp; &nbsp; &nbsp; &nbsp; z=1.23456_sp, 1.23456_dp, 1.23456_qp<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23456001281738281250000000000000000<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23456000000000010174971976084634662<br />&nbsp; &nbsp; &nbsp; &nbsp; 1.23456000000000000000000000000000005</p>]]></description>
			<author><![CDATA[null@example.com (drfrank)]]></author>
			<pubDate>Tue, 21 Dec 2021 19:07:43 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=3827#p3827</guid>
		</item>
		<item>
			<title><![CDATA[Re: Use Double Precision for All Reals checkbox]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=3826#p3826</link>
			<description><![CDATA[<p>Regarding Jeff&#039;s example, compare precision of_sp, _dp, and _qp. <br />Results are &#039;odd&#039;, go figure?</p><p>&nbsp; &nbsp; !&nbsp; &nbsp; Compare precision of sp, dp, and d0:<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; !&nbsp; &nbsp; x=1.234_sp, 1.234_dp, 1.234d0<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23399997<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23399997<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23399997<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; !&nbsp; &nbsp; y=1.234_sp, 1.234_dp, 1.234d0<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.2339999675750732<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.2340000000000000<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.2340000000000000<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; !&nbsp; &nbsp; z=1.234_sp, 1.234_dp, 1.234d0<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23399996757507324218750000000000000<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23399999999999998578914528479799628<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23399999999999998578914528479799628<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; !&nbsp; &nbsp; x=1.2345_sp, 1.2345_dp, 1.2345d0<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23450005<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23450005<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23450005<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; !&nbsp; &nbsp; y=1.2345_sp, 1.2345_dp, 1.2345d0<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.2345000505447388<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.2344999999999999<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.2344999999999999<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; !&nbsp; &nbsp; z=1.2345_sp, 1.2345_dp, 1.2345d0<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23450005054473876953125000000000000<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23449999999999993072208326339023188<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23449999999999993072208326339023188<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; !&nbsp; &nbsp; x=1.23456_sp, 1.23456_dp, 1.23456d0<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23456001<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23456001<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23456001<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; !&nbsp; &nbsp; y=1.23456_sp, 1.23456_dp, 1.23456d0<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.2345600128173828<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.2345600000000001<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.2345600000000001<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; !&nbsp; &nbsp; z=1.23456_sp, 1.23456_dp, 1.23456d0<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23456001281738281250000000000000000<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23456000000000010174971976084634662<br />&nbsp; &nbsp; !&nbsp; &nbsp; 1.23456000000000010174971976084634662</p><p>program helloworld<br />&nbsp; &nbsp; implicit none</p><p>&nbsp; &nbsp; integer, parameter :: p6&nbsp; = selected_real_kind(6)&nbsp; &nbsp;!---&nbsp; 4 bytes<br />&nbsp; &nbsp; integer, parameter :: p15 = selected_real_kind(15)&nbsp; !---&nbsp; 8 bytes<br />&nbsp; &nbsp; integer, parameter :: p20 = selected_real_kind(20)&nbsp; !--- 16 bytes</p><p>&nbsp; &nbsp; !--- Symbolic names for kind types of reals:<br />&nbsp; &nbsp; INTEGER, PARAMETER :: SP = KIND(1.0_p6)&nbsp; &nbsp; &nbsp; !---&nbsp; 4 bytes<br />&nbsp; &nbsp; INTEGER, PARAMETER :: DP = KIND(1.0_p15)&nbsp; &nbsp; &nbsp;!---&nbsp; 8 bytes<br />&nbsp; &nbsp; INTEGER, PARAMETER :: QP = KIND(1.0_p20)&nbsp; &nbsp; &nbsp;!--- 16 bytes</p><p>&nbsp; &nbsp; real(kind=SP):: x<br />&nbsp; &nbsp; real(kind=DP):: y<br />&nbsp; &nbsp; real(kind=QP):: z</p><p>&nbsp; &nbsp; !---<br />&nbsp; &nbsp; !--- Compare x_sp, x_dp, and xd0<br />&nbsp; &nbsp; !---<br />&nbsp; &nbsp; Print *, &#039;Compare precision of sp, dp, and d0:&#039;<br />&nbsp; &nbsp; !---<br />&nbsp; &nbsp; !--- x=1.234<br />&nbsp; &nbsp; !---<br />&nbsp; &nbsp; Print *<br />&nbsp; &nbsp; Print *, &#039;x=1.234_sp, 1.234_dp, 1.234d0&#039;<br />&nbsp; &nbsp; x = 1.234_sp<br />&nbsp; &nbsp; Print *, x<br />&nbsp; &nbsp; x = 1.234_dp<br />&nbsp; &nbsp; Print *, x<br />&nbsp; &nbsp; x = 1.234d0<br />&nbsp; &nbsp; Print *, x<br />&nbsp; &nbsp; Print *<br />&nbsp; &nbsp; Print *, &#039;y=1.234_sp, 1.234_dp, 1.234d0&#039;<br />&nbsp; &nbsp; y = 1.234_sp<br />&nbsp; &nbsp; Print *, y<br />&nbsp; &nbsp; y = 1.234_dp<br />&nbsp; &nbsp; Print *, y<br />&nbsp; &nbsp; y = 1.234d0<br />&nbsp; &nbsp; Print *, y<br />&nbsp; &nbsp; Print *<br />&nbsp; &nbsp; Print *, &#039;z=1.234_sp, 1.234_dp, 1.234d0&#039;<br />&nbsp; &nbsp; z = 1.234_sp<br />&nbsp; &nbsp; Print *, z<br />&nbsp; &nbsp; z = 1.234_dp<br />&nbsp; &nbsp; Print *, z<br />&nbsp; &nbsp; z = 1.234d0<br />&nbsp; &nbsp; Print *, z<br />&nbsp; &nbsp; !---<br />&nbsp; &nbsp; !--- x=1.2345<br />&nbsp; &nbsp; !---<br />&nbsp; &nbsp; Print *<br />&nbsp; &nbsp; Print *, &#039;x=1.2345_sp, 1.2345_dp, 1.2345d0&#039;<br />&nbsp; &nbsp; x = 1.2345_sp<br />&nbsp; &nbsp; Print *, x<br />&nbsp; &nbsp; x = 1.2345_dp<br />&nbsp; &nbsp; Print *, x<br />&nbsp; &nbsp; x = 1.2345d0<br />&nbsp; &nbsp; Print *, x<br />&nbsp; &nbsp; Print *<br />&nbsp; &nbsp; Print *, &#039;y=1.2345_sp, 1.2345_dp, 1.2345d0&#039;<br />&nbsp; &nbsp; y = 1.2345_sp<br />&nbsp; &nbsp; Print *, y<br />&nbsp; &nbsp; y = 1.2345_dp<br />&nbsp; &nbsp; Print *, y<br />&nbsp; &nbsp; y = 1.2345d0<br />&nbsp; &nbsp; Print *, y<br />&nbsp; &nbsp; Print *<br />&nbsp; &nbsp; Print *, &#039;z=1.2345_sp, 1.2345_dp, 1.2345d0&#039;<br />&nbsp; &nbsp; z = 1.2345_sp<br />&nbsp; &nbsp; Print *, z<br />&nbsp; &nbsp; z = 1.2345_dp<br />&nbsp; &nbsp; Print *, z<br />&nbsp; &nbsp; z = 1.2345d0<br />&nbsp; &nbsp; Print *, z</p><p>&nbsp; &nbsp; !---<br />&nbsp; &nbsp; !--- x=1.23456<br />&nbsp; &nbsp; !---<br />&nbsp; &nbsp; Print *<br />&nbsp; &nbsp; Print *, &#039;x=1.23456_sp, 1.23456_dp, 1.23456d0&#039;<br />&nbsp; &nbsp; x = 1.23456_sp<br />&nbsp; &nbsp; Print *, x<br />&nbsp; &nbsp; x = 1.23456_dp<br />&nbsp; &nbsp; Print *, x<br />&nbsp; &nbsp; x = 1.23456d0<br />&nbsp; &nbsp; Print *, x<br />&nbsp; &nbsp; Print *<br />&nbsp; &nbsp; Print *, &#039;y=1.23456_sp, 1.23456_dp, 1.23456d0&#039;<br />&nbsp; &nbsp; y = 1.23456_sp<br />&nbsp; &nbsp; Print *, y<br />&nbsp; &nbsp; y = 1.23456_dp<br />&nbsp; &nbsp; Print *, y<br />&nbsp; &nbsp; y = 1.23456d0<br />&nbsp; &nbsp; Print *, y<br />&nbsp; &nbsp; Print *<br />&nbsp; &nbsp; Print *, &#039;z=1.23456_sp, 1.23456_dp, 1.23456d0&#039;<br />&nbsp; &nbsp; z = 1.23456_sp<br />&nbsp; &nbsp; Print *, z<br />&nbsp; &nbsp; z = 1.23456_dp<br />&nbsp; &nbsp; Print *, z<br />&nbsp; &nbsp; z = 1.23456d0<br />&nbsp; &nbsp; Print *, z<br />end program helloworld</p>]]></description>
			<author><![CDATA[null@example.com (drfrank)]]></author>
			<pubDate>Tue, 21 Dec 2021 15:42:02 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=3826#p3826</guid>
		</item>
		<item>
			<title><![CDATA[Re: Use Double Precision for All Reals checkbox]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=3825#p3825</link>
			<description><![CDATA[<p>While you&#039;re right, the readability suffers somewhat, your simple example even shows issues.&nbsp; If my program is:</p><div class="codebox"><pre><code>program helloworld
implicit none

    real(kind=8)::x
    
    x = 1.234
    Print *, x
    
    x = 1.234d0
    Print *, x
    
end program helloworld</code></pre></div><p>I get the following results:</p><div class="codebox"><pre><code>   1.2339999675750732     
   1.2340000000000000  </code></pre></div><p>So there is an advantage to using the <em>1.234d0</em> syntax if you&#039;re counting on accuracy in double precision.&nbsp; </p><p>You&#039;re right, though, that using the <em>-fdefault-real-8</em> does fix the issue illustrated above.&nbsp; However, counting on a specific compiler&#039;s flag is not the best way to write portable code.&nbsp; I would normally use that flag to handle older code that I (or someone else) had neglected to assign <em>kind</em> specifications where I wanted to try running in double precision.&nbsp; There was also a time in the not-so-distant past that running in single precision was considerably faster, so you could work in single precision when developing and switch to double precision when you were confident that the long-running simulation was ready to go.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Mon, 20 Dec 2021 12:43:38 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=3825#p3825</guid>
		</item>
		<item>
			<title><![CDATA[Re: Use Double Precision for All Reals checkbox]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=3824#p3824</link>
			<description><![CDATA[<p>Jeff,<br />I asked this question inspired by the discussion on fortram-lang forum. In Modern Fortran it is recommended to write<br />x=1.234d0 or x=1.234_dp,&nbsp; if x is declared as double. This is indeed annoying and hurts readability. If I understand correctly,<br />with -fdefault-real-8 switch we can use x=1.234, however, it is still dangerous since then, 1.234d0 and other doubles are promoted to quad precision.</p>]]></description>
			<author><![CDATA[null@example.com (Carlos Herrera)]]></author>
			<pubDate>Sun, 19 Dec 2021 22:06:44 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=3824#p3824</guid>
		</item>
		<item>
			<title><![CDATA[Re: Use Double Precision for All Reals checkbox]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=3823#p3823</link>
			<description><![CDATA[<p>Carlos,</p><p>Yes, that checkbox just implements a compiler switch, <em>-fdefault-real-8</em> to be exact.&nbsp; It will promote all <em>REAL</em> declarations that are not explicitly defined with a kind to be <em>REAL(KIND=8)</em>.&nbsp; You can read more about it at <a href="http://simplyfortran.com/docs/compiler/Fortran-Dialect-Options.html">http://simplyfortran.com/docs/compiler/ … tions.html</a>.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Sun, 19 Dec 2021 18:34:58 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=3823#p3823</guid>
		</item>
		<item>
			<title><![CDATA[Use Double Precision for All Reals checkbox]]></title>
			<link>http://forums.approximatrix.com/viewtopic.php?pid=3822#p3822</link>
			<description><![CDATA[<p>Jeff,<br />How it works exactly? Is it simply a compiler switch? Does it apply also for function arguments declared as real?<br />Thank you,<br />Carlos</p>]]></description>
			<author><![CDATA[null@example.com (Carlos Herrera)]]></author>
			<pubDate>Sat, 18 Dec 2021 11:22:38 +0000</pubDate>
			<guid>http://forums.approximatrix.com/viewtopic.php?pid=3822#p3822</guid>
		</item>
	</channel>
</rss>
