Fortran/OOP in Fortran

Overview
Data can be gathered in s. The general form is given by

Data access
There are three possible access properties:.


 * : Outside code has read and write access.
 * : Outside code has no access.
 * : Outside code has read access.

Using module in other code
One can include the module's public data in outside code. There are three ways.


 * : includes all public data and methods
 * : includes all public data and methods, but renames some public data or methods
 * : includes only some public data and methods

Submodule
Modules can be extended using submodules. Multiple advantages arise
 * splitting of large modules
 * splitting of interface definitions and implementations such that dependent modules do not need to be recompiled if the implementations change
 * two modules need data from each other.

Derived data types
In Fortran one can derive structures off of other structures, so called derived data types. The derived types will have the features of the parent type as well as the newly added ones and the general syntax is given by:

The following example shows different types of people within a company.

Destructors
One can define procedures which will be invoked before the object is automatically deleted (out of scope). This is done with the statement. The following example illustrates it

Abstract base type and deferred procedure
One can set the base type as  such that one cannot initialize objects of that type but one can derive sub-types of it (via  ). Specific procedures which should be defined in the sub-type need the property  as well as an explicit interface.

The following example illustrates their use.

Polymorphic Pointer
One can create pointers to child classes by using type definitions in  statements and the   environment. The following example highlights its use.