Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

SELECTED_REAL_KIND

Transformational Intrinsic Function (Generic): Returns the value of the kind parameter of a real data type.

result = SELECTED_REAL_KIND ([p] [,r] [,radix])

p

(Input; optional) Must be scalar and of type integer.

r

(Input; optional) Must be scalar and of type integer.

radix

(Input; optional) Must be scalar and of type integer.

At least argument p or r must be present.

Results

If p or r is absent, the result is as if the argument was present with the value zero. If radix is absent, there is no requirement on the radix of the selected kind.

The result is a scalar of type default integer. If both arguments are absent, the result is zero. Otherwise, the result has a value equal to a value of the kind parameter of a real data type with decimal precision, as returned by the function PRECISION, of at least p digits, a decimal exponent range, as returned by the function RANGE, of at least r, and a radix, as returned by the function RADIX, of radix.

If no such kind type parameter is available on the processor, the result is as follows:

-1 if the precision is not available but the range is available
-2 if the exponent range is not available but the precision is available
-3 if neither is available 
-4 if real types for the precision and the range are available separately but not together
-5 if no real type of the specified radix is available

If more than one kind type parameter value meets the criteria, the value returned is the one with the smallest decimal precision. Intel® Fortran currently does not return -4 for any combination of p and r, and supports only a radix of 2. For more information, see Model for Real Data.

Example

SELECTED_REAL_KIND (6, 70) = 8

The following shows another example:

 i = SELECTED_REAL_KIND(r=200, radix=2)  ! returns 8
 i = SELECTED_REAL_KIND(13)     ! returns 8
 i = SELECTED_REAL_KIND (100, 200)  ! returns -1
 i = SELECTED_REAL_KIND (13, 5000)  ! returns -2
 i = SELECTED_REAL_KIND (100, 5000) ! returns -3
 i = SELECTED_REAL_KIND (13, radix=42)  ! returns -5

The following example gives a compile-time error:

 i = SELECTED_REAL_KIND ()