next up previous

3.2 Precision Selection

This paves the way for discussion of that numerically useful feature of Fortran 90, the SELECTED_REAL_KIND intrinsic function, which allows the programmer to specify minimum decimal precision and/or exponent range properties. The SELECTED_REAL_KIND function has two optional integer arguments, at least one of which must be supplied, one for the desired decimal precision and the other for the desired (decimal) exponent range; SELECTED_REAL_KIND then returns the kind value for the ``smallest" kind of real data type the implementation supports that meets or exceeds these specified conditions. An error condition exists if there is no such data type. Thus, for example,

declares the integer constant P9 to have the real kind value appropriate to real objects with at least 9 decimal digits of precision. Variables meeting this requirement may be declared with the statement
 REAL(P9)      ...9 digit (at least) precision real variable...