 |
» |
|
|
 |
Introduces a module. Syntax- module-name
is a unique module name.
DescriptionModules are nonexecutable program units that can contain type
definitions, object declarations, procedure definitions (module
procedures), external procedure interfaces, user-defined generic
names, and user-defined operators and assignments. Any such definitions
not specified to be private to the module containing them are available
to those program units that specify the module in a USE
statement. Modules provide a convenient sharing and encapsulation
mechanism for data, types, procedures, and procedure interfaces. Examples! Make data objects and a data type sharable via a module MODULE shared COMPLEX gtx (100, 6) REAL, ALLOCATABLE :: y(:), z(:,:) TYPE peak_item REAL peak_val, energy TYPE(peak_item), POINTER :: next END TYPE peak_item END MODULE shared ! Define a data abstraction for rational arithmetic via a module MODULE rational_arithmetic TYPE rational PRIVATE INTEGER numerator, denominator END TYPE rational ! Generic extension of = INTERFACE ASSIGNMENT (=) MODULE PROCEDURE eqrr, eqri, eqir END INTERFACE INTERFACE OPERATOR (+) ! Generic extension of + MODULE PROCEDURE addrr, addri, addir END INTERFACE ... CONTAINS FUNCTION eqrr (. . .) ! A specific definition of = ... FUNCTION addrr (. . .) ! A specific definition of + ... END MODULE rational_arithmetic |
Related statementsCONTAINS,
END, PRIVATE,
PUBLIC, and USE Related conceptsFor more information about modules, see “Modules”.
|