Manual Reference Pages  - real (3fortran)

NAME

REAL(3) - [TYPE:CONVERSION] Convert to real type

SYNOPSIS

result = real(x [,kind])

       elemental real(kind=KIND) function real(x,KIND)

TYPE(kind=**),intent(in) :: x integer(kind=**),intent(in),optional :: KIND

CHARACTERISTICS

o the type of X may be integer, real, or complex; or a BOZ-literal-constant.
o KIND is a integer initialization expression (a constant expression)
o If KIND is present it defines the kind of the real result
o if KIND is not present
o when X is complex the result is a real of the same kind as X.
o when X is real or integer the result is a real of default kind
o a kind designated as ** may be any supported kind for the type

DESCRIPTION

REAL(3) converts its argument X to a real type.

The real part of a complex value is returned. For complex values this is similar to the modern complex-part-designator %RE which also designates the real part of a complex value.

          z=(3.0,4.0)     ! if z is a complex value
          print *, z%re == real(z) ! these expressions are equivalent

OPTIONS

o X : An integer, real, or complex value to convert to real.
o KIND : When present the value of KIND defines the kind of the result.

RESULT

1. REAL(X) converts X to a default real type if X is an integer or real variable.
2. REAL(X) converts a complex value to a real type with the magnitude of the real component of the input with kind type parameter the same as X.
3. REAL(X, KIND) is converted to a real type with kind type parameter KIND if X is a complex, integer, or real variable.

EXAMPLES

Sample program:

    program demo_real
    use,intrinsic :: iso_fortran_env, only : dp=>real64
    implicit none
    complex              :: zr = (1.0, 2.0)
    doubleprecision      :: xd=huge(3.0d0)
    complex(kind=dp) :: zd=cmplx(4.0e0_dp,5.0e0_dp,kind=dp)

print *, real(zr), aimag(zr) print *, dble(zd), aimag(zd)

write(*,*)xd,real(xd,kind=kind(0.0d0)),dble(xd) end program demo_real

Results:

     > 1.00000000       2.00000000
     > 4.0000000000000000      5.0000000000000000
     > 1.7976931348623157E+308 1.7976931348623157E+308 1.7976931348623157E+30

STANDARD

FORTRAN 77

SEE ALSO

o AIMAG(3) - Imaginary part of complex number
o CMPLX(3) - Complex conversion function
o CONJG(3) - Complex conjugate function
Fortran has strong support for complex values, including many intrinsics that take or produce complex values in addition to algebraic and logical expressions:

ABS(3), ACOSH(3), ACOS(3), ASINH(3), ASIN(3), ATAN2(3), ATANH(3), ATAN(3), COSH(3), COS(3), CO_SUM(3), DBLE(3), DOT_PRODUCT(3), EXP(3), INT(3), IS_CONTIGUOUS(3), KIND(3), LOG(3), MATMUL(3), PRECISION(3), PRODUCT(3), RANGE(3), RANK(3), SINH(3), SIN(3), SQRT(3), STORAGE_SIZE(3), SUM(3), TANH(3), TAN(3), UNPACK(3),

Fortran intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 real (3fortran) November 02, 2024
Generated by manServer 1.08 from c830c0a0-c2e3-4b8a-b7c1-3b8ce984786c using man macros.