next up previous contents
Next: Mixed KIND Expressions Up: Parametrised Intrinsic Types Previous: Parametrized Reals   Contents

Kind Functions

The function KIND(var) returns the kind of the variable var. For example, the code

integer(kind=4) :: i4
k = kind(i4)
returns the value k = 4.

Intrinsic types have a predetermined kind value. With the KIND function we can inquire about the default kinds,

integer :: i 
real :: x 
double precision :: y
ki = kind(i); kx = kind(x); ky = kind(y) 
On Alpha 21264 the results are {\tt ki} = 4, {\tt kx = 4} and
{\tt ky = 8}.

All type conversion functions have an optional {\tt KIND} argument
for specifying the kind of the result (recall that the type of the result
is given by the function itself).
For example,
real :: x
integer(kind=huge) :: i8
i8 = int(x,kind=huge) ! or i8 = int(x,kind=kind(i8))

Adrian Sandu 2001-08-26