Go to the first, previous, next, last section, table of contents.


DCmplx Intrinsic

DCmplx(X, Y)

DCmplx: COMPLEX(KIND=2) function.

X: INTEGER, REAL, or COMPLEX; scalar; INTENT(IN).

Y: INTEGER or REAL; OPTIONAL (must be omitted if X is COMPLEX); scalar; INTENT(IN).

Intrinsic groups: f2c, vxt.

Description:

If X is not type COMPLEX, constructs a value of type COMPLEX(KIND=2) from the real and imaginary values specified by X and Y, respectively. If Y is omitted, `0D0' is assumed.

If X is type COMPLEX, converts it to type COMPLEX(KIND=2).

Although this intrinsic is not standard Fortran, it is a popular extension offered by many compilers that support DOUBLE COMPLEX, since it offers the easiest way to convert to DOUBLE COMPLEX without using Fortran 90 features (such as the `KIND=' argument to the CMPLX() intrinsic).

(`CMPLX(0D0, 0D0)' returns a single-precision COMPLEX result, as required by standard FORTRAN 77. That's why so many compilers provide DCMPLX(), since `DCMPLX(0D0, 0D0)' returns a DOUBLE COMPLEX result. Still, DCMPLX() converts even REAL*16 arguments to their REAL*8 equivalents in most dialects of Fortran, so neither it nor CMPLX() allow easy construction of arbitrary-precision values without potentially forcing a conversion involving extending or reducing precision. GNU Fortran provides such an intrinsic, called COMPLEX().)

See section Complex Intrinsic, for information on easily constructing a COMPLEX value of arbitrary precision from REAL arguments.


Go to the first, previous, next, last section, table of contents.