Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

CLASS

Statement: Declares a polymorphic object. It takes one of the following forms:

CLASS (name) att-list :: v-list

CLASS (*) att-list :: v-list

name

Is the name of the extensible derived data type.

att-list

Is one or more attribute specifiers. These are the same attribute specifiers allowed for a derived-type TYPE statement.

v-list

Is the name of one or more data objects or functions. The name can optionally be followed by any of the following:

  • An array specification, if the object is an array.

    In a function declaration, an array must be a deferred-shape array if it has the POINTER attribute; otherwise, it must be an explicit-shape array.

  • A character length, if the object is of type character.

  • A coarray specification, if the object is a coarray.

  • A constant expression preceded by an = or, for pointer objects, => NULL( ).

Description

A polymorphic object can have differing types during program execution.

The type of the object at a particular point during execution of a program is its dynamic type.

The declared type of a data entity is the type that it is declared to have, either explicitly or implicitly.

If CLASS (*) is specified, it denotes an unlimited polymorphic object. An unlimited polymorphic entity is not declared to have a type. It is not considered to have the same declared type as any other entity, including another unlimited polymorphic entity.

An entity declared with the CLASS keyword must be a dummy argument or have the ALLOCATABLE or POINTER attribute.

A polymorphic entity that is not an unlimited polymorphic entity is type compatible with entities of the same declared type or any of its extensions. Even though an unlimited polymorphic entity is not considered to have a declared type, it is type compatible with all entities. An entity is said to be type compatible with a type if it is type compatible with entities of that type.

A polymorphic allocatable object can be allocated to be of any type with which it is type compatible.

During program execution, a polymorphic pointer or dummy argument can be associated with objects with which it is type compatible.