In the example at Derived Types — Fortran Programming Language
type, public :: t_matrix(rows, cols, k)
integer, len :: rows, cols
integer, kind :: k = kind(0.0)
real(kind=k), dimension(rows, cols) :: values
end type
It seems to me “k” is defined as a real type, so what does the use of “integer” mean at:
integer, kind :: k = kind(0.0)
?
@someknowit ,
Note that in Fortran the type of the KIND
parameter itself is integer.
So place aside the parametrized derived type for now, say you wanted to declare a kind of REAL
type that has a precision of at least 18: the language then suggests you can do something along the following lines:
integer, parameter :: RK_18 = selected_real_kind( p=18 )
real(kind=RK_18) : : x
So just as the type of RK_18
is an integer here even though the type of interest is REAL, the same applies in your PDT case with type parameter k
.
2 Likes