On Wed, 2017-04-05 at 11:29 +0200, Phillip Helbig wrote:
> 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?
I use INCLUDE as a poor-man's substitute for generic programming.
I use a kind type parameter to specialize a function to default real or
double precision, to produce a generic interface, like this:
interface F
module procedure F_d, F_s
end interface
...
function F_d ( X )
integer, parameter :: RK = kind(1.0d0)
include "F_body.f9h"
end function F_d
function F_s ( X )
integer, parameter :: RK = kind(1.0e0)
include "F_body.f9h"
end function F_s
with F_body.f9h containing
! function F_* ( X )
real(rk) :: F
real(rk), intent(in) :: F
...
This doesn't work if I use DOUBLE PRECISION.
|