Type declaration statement

Standard: (F77) F90 F95 F2003 F2008


<Syntax>

type [ [ , attr-spec ]... :: ] entity-decl-list

type ::= intrinsic-type-spec
| CLASS ( * )
| CLASS ( derived-type-spec )
| TYPE ( derived-type-spec )
| TYPE ( intrinsic-type-spec )

intrinsic-type-spec ::= CHARACTER [ char-spec ]
| COMPLEX [ ( [ KIND = ] expr ) ]
| DOUBLE PRECISION
| INTEGER [ ( [ KIND = ] expr ) ]
| LOGICAL [ ( [ KIND = ] expr ) ]
| REAL [ ( [ KIND = ] expr ) ]

derived-type-spec ::= derived-type-name derived-type-param-list )
derived-type-param-list ::= derived-type-param [ , derived-type-param ]...
derived-type-param ::= [ derived-type-param-name = ] type-param-value
type-param ::= expression | : | *

attr-spec ::= ALLOCATABLE
| ASYNCHRONOUS
| BIND ( C [ , NAME = expression ] )
| CODIMENSION [ coarray-spec ]
| CONTIGUOUS
| DIMENSION ( array-spec )
| EXTERNAL
| INTENT ( intent )
| INTRINSIC
| OPTIONAL
| PARAMETER
| POINTER
| PRIVATE
| PROTECTED
| PUBLIC
| SAVE
| TARGET
| VALUE
| VOLATILE

intent ::= IN | INOUT | OUT

If ALLOCATABLE or POINTER is specified, any array-spec must be deferred-shape. If ALLOCATABLE is specified, any coarray-spec must be a deferred-coshape-spec.

The PUBLIC and PRIVATE attributes are only permitted in the specification part of a module.

<Semantics>

This statement declares one or more procedures or local variables. If the type specified is a derived-type-spec with type parameters, each expr in a type-param-value must be a constant expression if the entities have the SAVE or PARAMETER attributes, or the type parameter is a KIND type parameter, and a specification expression otherwise. A type-param-value can be a colon (:) only if the type parameter is a LEN type parameter and the entities declared have the POINTER or ALLOCATABLE attribute. A type-param-value can be an asterisk (*) only if the type parameter if a LEN type parameter and the entities declared are dummy arguments.

If an entity-decl contains an initialisation (“= expression” or “=> NULL()”), the entity is a named constant or a variable: if the PARAMETER attribute appears it is a named constant with the specified value (possibly converted to the type), otherwise it is a variable and its initial value is that of the expression; this implies the SAVE attribute.

<Related>

ALLOCATABLE attribute, ASYNCHRONOUS attribute, Attributes, BIND attribute, CODIMENSION attribute, CONTIGUOUS attribute, Derived Type Definition, DIMENSION attribute, Entity declaration list, EXTERNAL attribute, INTENT attribute, INTRINSIC attribute, OPTIONAL attribute, PARAMETER attribute, POINTER attribute, PRIVATE attribute, PROTECTED attribute, PUBLIC attribute, SAVE attribute, SELECTED_INT_KIND intrinsic function, SELECTED_REAL_KIND intrinsic function, TARGET attribute, VALUE attribute, VOLATILE attribute