Print

Print


In the good-old-days,  DOUBLE PRECISION was often something like 128 bits (and definitely not IEEE!).

But that historic issue aside, using  DOUBLE PRECISION is a real pain if you want to change to a different precision.   The KIND mechanism will generally allow us to at least control the precision in a small number of “well chosen” spots in the code.



On Apr 5, 2017, at 9:21 AM, Vipul Parekh <[log in to unmask]<mailto:[log in to unmask]>> wrote:

Phillip,

You ask, "Why not just write DOUBLE PRECISION if that is what you mean?"  Note the standard only states the following about DOUBLE PRECISION:

1) "The decimal precision of the double precision real approximation method shall be greater than that of the default real method."
2) "The decimal precision of double precision real shall be at least 10, and its decimal exponent range shall be at 37. It is recommended that the decimal precision of default real be at least 6, and that its decimal exponent range be at least 37."

And I think DOUBLE PRECISION has the same underlying issues as referred to in the blog in the first note of this chain, it's probably viewed to be worse and its use seems widely deprecated (even if not officially so) since the introduction of Fortran 90 back in 1991.

Regards,
Vipul



On Wed, Apr 5, 2017 at 5:29 AM, Phillip Helbig <[log in to unmask]<mailto:[log in to unmask]>> wrote:
>   use, intrinsic:: ISO_FORTRAN_ENV, only: REAL32, REAL64
>
> implicit none
> private
>
>   interface goo
>     module procedure goo_s
>     module procedure goo_d
>   end interface
>   public :: goo
>
> contains
>
>   subroutine goo_s (x)
>     real(kind=REAL32), intent(..) :: x
>     include 'goo_source.inc'
>   end subroutine goo_s
>   subroutine goo_d (x)
>     real(kind=REAL64), intent(..) :: x
>     include 'goo_source.inc'
>   end subroutine goo_d

What is the essential  difference between this and using REAL and DOUBLE
PRECISION?

I understand the motivation for KIND.  However, many people use
SELECTED_REAL_KIND with 1.0D0 or whatever to find the "double-precision
KIND".  Why not just write DOUBLE PRECISION if that is what you mean?