cmplx(x [, y [, kind]]) returns a complex number where x is converted to the real component. If y is present it is converted to the imaginary component. If y is not present then the imaginary component is set to 0.0. If x is complex then y must not be present.

y - (Optional; only allowed if x is not complex.) May be integer or real.

kind - (Optional) An integer initialization expression indicating the kind parameter of the result.

Return value

The return value is of complex type, with a kind equal to kind if it is specified. If kind is not specified, the result is of the default complex kind, regardless of the kinds of x and y.

Example

program test_cmplxinteger::i=42real::x=3.14complex::zz=cmplx(i,x)print*,z,cmplx(x)endprogram test_cmplx