FORTRAN 90+: COMPLEX NUMBER DEMONSTRATION
The short code below shows how to initialize, compute and analyze a complex number. Notice that the complex number has two independent parts: a real and an imaginary part. The fact that the number is complex means that the complex version of the intrinsic function for the square root must be used.
PROGRAM complex1 IMPLICIT NONE COMPLEX :: x COMPLEX, PARAMETER :: m1=(-1.0, 0.0) x = CSQRT(m1) WRITE(*,*) REAL(x), AIMAG(x) END PROGRAM complex1