Next: COS, Previous: CHAR, Up: Intrinsic Procedures
CMPLX — Complex conversion functionCMPLX(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.
C = CMPLX(X)
C = CMPLX(X,Y)
C = CMPLX(X,Y,KIND)
| X | The type may be INTEGER(*) or REAL(*) or COMPLEX(*).
|
| Y | Optional, allowed if X is not COMPLEX(*). May be INTEGER(*) or REAL(*).
|
| KIND | Optional scaler integer initialization expression.
|
COMPLEX(*)
program test_cmplx
integer :: i = 42
real :: x = 3.14
complex :: z
z = cmplx(i, x)
print *, z, cmplx(x)
end program test_cmplx