MODULE statement

Standard: F77 F90 F95 F2003 F2008 F2018 Example program


<Syntax>

MODULE name

The MODULE statement is the first statement of a module program unit, whose syntax is as follows.

module-stmt
      specification-part
      [ CONTAINS
      [ module-subprogram ]... ]
end-module-stmt

module-subprogram ::= function-subprogram | subroutine-subprogram | separate-module-subprogram

Before Fortran 2008, if the CONTAINS statement appeared, at least one module-subprogram had to appear.

The MODULE keyword is also used in the MODULE PROCEDURE statement.

The MODULE keyword is also used in the declaration and definition of separate module procedures.

<Semantics>

A module program unit may contain named constants, type declarations, variables and procedures for use by other parts of the program. Access to entities in a module is gained by the USE statement.

A module may also contain entities for its own internal use that are not accessible to other program units; these entities have the PRIVATE attribute. The default access is PUBLIC unless the module contains a global PRIVATE statement.

<Related>

CONTAINS statement, END MODULE statement, ONLY clause, MODULE PROCEDURE statement, PRIVATE attribute, PROTECTED attribute, PUBLIC attribute, SUBMODULE statement, USE statement