Next: , Previous: RANGE, Up: Intrinsic Procedures


8.87 REAL — Convert to real type

Description:
REAL(X [, KIND]) converts its argument X to a real type. The REALPART(X) function is provided for compatibility with g77, and its use is strongly discouraged.
Option:
f95, gnu
Class:
transformational function
Syntax:

X = REAL(X)
X = REAL(X, KIND)
X = REALPART(Z)

Arguments:

X shall be INTEGER(*), REAL(*), or COMPLEX(*).
KIND (Optional) KIND shall be a scalar integer.

Return value:
These functions return the a REAL(*) variable or array under the following rules:
(A)
REAL(X) is converted to a default real type if X is an integer or real variable.
(B)
REAL(X) is converted to a real type with the kind type parameter of X if X is a complex variable.
(C)
REAL(X, KIND) is converted to a real type with kind type parameter KIND if X is a complex, integer, or real variable.

Example:
          program test_real
            complex :: x = (1.0, 2.0)
            print *, real(x), real(x,8), realpart(x)
          end program test_real