# Fortran Wiki selected_real_kind

## Description

selected_real_kind(p,r) return the kind value of a real data type with decimal precision greater of at least p digits and exponent range greater at least r.

## Standard

Fortran 95 and later

## Class

Transformational function

## Syntax

result = selected_real_kind(p, r)

## Arguments

• p - (Optional) shall be a scalar and of type integer.
• r - (Optional) shall be a scalar and of type integer.

At least one argument shall be present.

## Return value

selected_real_kind returns the value of the kind type parameter of a real data type with decimal precision of at least p digits and a decimal exponent range of at least r. If more than one real data type meet the criteria, the kind of the data type with the smallest decimal precision is returned. If no real data type matches the criteria, the result is

• -1 if the processor does not support a real data type with a precision greater than or equal to p
• -2 if the processor does not support a real type with an exponent range greater than or equal to r
• -3 if neither is supported.

## Example

program real_kinds
integer,parameter :: p6 = selected_real_kind(6)
integer,parameter :: p10r100 = selected_real_kind(10,100)
integer,parameter :: r400 = selected_real_kind(r=400)
real(kind=p6) :: x
real(kind=p10r100) :: y
real(kind=r400) :: z

print *, precision(x), range(x)
print *, precision(y), range(y)
print *, precision(z), range(z)
end program real_kinds

category: intrinsics