The double precision
data type comes from Fortran 77, and the only requirement for this type is that it has higher precision than real
. You should no longer use this.
Fortran 90/95 and above support at least two sizes of real numbers. The accuracy is determined by the kind
parameter, the value of which depends on the compiler.
real(kind=8) :: a, b
To have a portable way of determining accuracy, you can get a kind
value that allows for a certain accuracy using:
integer, parameter :: long_double = SELECTED_REAL_KIND(22)
then you can declare your variables as
real(kind=long_double) :: a, b
but not sure if your compiler will maintain this precision, in which case the SELECTED_REAL_KIND
function will return a negative number.
see also this post
source share