Intel® Fortran Compiler 16.0 User and Reference Guide

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])

p

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

r

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

At least one argument must be present.

Results

If p or r is absent, the result is as if the argument was present with the value zero.

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 and a decimal exponent range, as returned by the function RANGE, of at least r.

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

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. 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)  ! 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

The following example gives a compile-time error:

 i = SELECTED_REAL_KIND () 

The following example returns a 0 at run-time to indicate that there was an error:

 PROGRAM TEST
 CALL F ()
 CONTAINS
   SUBROUTINE F (P, R)
     INTEGER, OPTIONAL :: P, R
     PRINT *, SELECTED_REAL_KIND (P=P, R=R)  ! prints 0
   END SUBROUTINE F
 END PROGRAM TEST

See Also