Standard: (F77) F90 F95 F2003 F2008 F2018 Example program


COMPLEX [ ( [ KIND= ] expression ) ]

The expression must be a scalar integer whose value identifies a valid kind of real.



COMPLEX declares entities (variables, functions, etc.) to be complex numbers; a complex value has a real part and an imaginary part. The KIND number is the same as for Real type, and determines the precision of each of the real and imaginary parts. The F90_KIND module contains named constants REAL16, REAL32, REAL64 and REAL128 which are convenient for specifying 16-bit, 32-bit, 64-bit and 128-bit floating point; these are also available in the standard intrinsic module ISO_FORTRAN_ENV. If no KIND is specified, the default is single precision.

COMPLEX*4 is a synonym for COMPLEX(REAL16), COMPLEX*8 is a synonym for COMPLEX(REAL32), COMPLEX*16 is a synonym for COMPLEX(REAL64), and COMPLEX*32 is a synonym for COMPLEX(REAL128). DOUBLE COMPLEX is a synonym for COMPLEX(KIND(0d0)). These synonyms are not standard Fortran; we recommend avoiding them.

The SELECTED_REAL_KIND intrinsic function can be used to select a real kind based on decimal precision and exponent range requirements. The IEEE_SELECTED_REAL_KIND function in the standard intrinsic module IEEE_ARITHMETIC can also be used to select an ISO/IEC/IEEE 60559 conformant real kind.


AIMAG intrinsic function, CHARACTER type, CMPLX intrinsic function, COMPLEX type, Component Definition statement, DIGITS intrinsic function, DOUBLE COMPLEX type specifier, IMPLICIT statement, KIND intrinsic function, LOGICAL type, REAL intrinsic function, REAL type, SELECTED_REAL_KIND intrinsic function, Type Declaration statement