Lahey/Fujitsu Fortran

REAL Function

Description

The REAL function converts a number to a REAL data type.

Syntax

REAL (a [, kind] )

Required Arguments

a is an INTENT(IN) scalar or array of any numeric type.

Optional Arguments

kind is INTENT(IN) and determines the kind of the result. It must be a scalar INTEGER expression that can be evaluated at compile time. To maintain portability, this argument should be the result of a KIND Function or SELECTED_REAL_KIND Function.

Result

The result is of type REAL. Its value is a REAL representation of a

If kind is present, it determines the kind of the result.

If a is of type COMPLEX, the result's value is the real part of a.

Example

integer :: i=10. real :: a=2.5 complex :: c=(1.5,2.5) write(*,*) i,real(i) ! convert integer to real write(*,*) a,real(a,kind(1.d0)) ! convert between real kinds write(*,*) c,real(c) ! return real part

Also

KIND Function

SELECTED_REAL_KIND Function