The COMPLEX statement declares entities having the COMPLEX data type.
SyntaxCOMPLEX [kind-selector] [[, attribute-list] ::] entity [, entity] ...Where:
kind-selector is ( [KIND=] scalar-int-initialization-expr )
scalar-int-initialization-expr is a scalar INTEGER expression that can be evaluated at compile time. To maintain portability, the value of this descriptor should be the result of a KIND Function or a SELECTED_REAL_KIND Function.
attribute-list is a comma-separated list from the following attributes: PARAMETER, ALLOCATABLE, DIMENSION(array-spec), EXTERNAL, INTENT(IN) or INTENT(OUT) or INTENT(IN OUT), PUBLIC or PRIVATE, INTRINSIC, OPTIONAL, POINTER, SAVE, TARGET, VOLATILE, DLL_EXPORT or DLL_IMPORT or ML_EXTERNAL.
entity-name [(array-spec)] [=initialization-expr]
or function-name [(array-spec)]
array-spec is an array specification
initialization-expr is a CHARACTER-valued expression that can be evaluated at compile time
entity-name is the name of the entity being declared
function-name is the name of a function being declared
function-name must be the name of an external, intrinsic, or statement function, or a function dummy procedure.
The =initialization-expr must appear if the statement contains a PARAMETER attribute.
If =initialization-expr appears, a double colon must appear before the list of entities. Each entity has the SAVE attribute, unless it is in a named common block.
The =initialization-expr must not appear if entity-name is a dummy argument, a function result, an object in a named common block unless the type declaration is in a block data program unit, an object in blank common, an allocatable array, a pointer, an external name, an intrinsic name, or an automatic object.
If an array or function with an array result is declared with the POINTER attribute, it must have a deferred shape.
If an array is declared with the ALLOCATABLE attribute, it must have a deferred shape.
If an array or function with an array result does not have the POINTER or the ALLOCATABLE attribute, it must be specified with an explicit shape.
If the POINTER attribute is specified, the TARGET, INTENT, EXTERNAL, or INTRINSIC attributes must not be specified.
If the TARGET attribute is specified, the POINTER, EXTERNAL, INTRINSIC, or PARAMETER attributes must not be specified.
The PARAMETER attribute cannot be specified for dummy arguments, pointers, allocatable arrays, functions, or objects in a common block.
The INTENT(IN), INTENT(OUT), INTENT(IN OUT), and OPTIONAL attributes can be specified only for dummy arguments.
An entity may not have the PUBLIC attribute if its type has the PRIVATE attribute.
The SAVE attribute must not be specified for an object that is in a common block, a dummy argument, a procedure, a function result, or an automatic data object.
An entity must not have the EXTERNAL or INTRINSIC attribute specified unless it is a function.
A subprogram must not have the EXTERNAL attribute if it has the INTRINSIC attribute.
An entity having the ALLOCATABLE attribute cannot be a dummy argument or a function result.
An array must not have both the ALLOCATABLE attribute and the POINTER attribute.
If an entity has the VOLATILE attribute, it cannot have the PARAMETER, INTRINSIC, EXTERNAL, or INTENT(IN) attributes.
An entity may not be given the same attribute more than once in a scoping unit.
Examplecomplex :: a, b complex,parameter :: c=(2.0,3.14159)! c must be initialized complex :: d(2)=(/(1.,0.),(0.,0.)/) ! array initialization complex,pointer :: e(:,:,:) ! deferred shape rank 3