The data type double precision
stems from Fortran 77, and the only requirement for that type is that is has more precision than real
. You shouldn't use that any more.
In Fortran 90/95 and beyond, at least two sizes of real numbers are supported. The precision is determined by the kind
parameter, of which the value depends on the compiler.
real(kind=8) :: a, b
To have a portable way of defining precision, you can obtain a kind
value that allows a certain precision by using:
integer, parameter :: long_double = SELECTED_REAL_KIND(22)
then you can declare your variables as
real(kind=long_double) :: a, b
but it is not certain your compiler will support that precision, in which case the SELECTED_REAL_KIND
function will return a negative number.
see also this post
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…