SUBMODULE statement

Standard: F77 F90 F95 F2003 F2008 F2018 Example program


SUBMODULE ( ancestor-module-name [ : parent-submodule-name ] ) submodule-name

The SUBMODULE statement is the first statement of a SUBMODULE program unit, which has the syntax:
      [ contains-stmt
            [ module-subprogram ]... ]
      END [ SUBMODULE [ submodule-name ] ]

The ancestor-module-name is the name of a module with one or more separate module procedures, parent-submodule-name (if present) is the name of another submodule of that module, and submodule-name is the name of the submodule being defined.


The submodules of a module form a tree structure, with successive submodules being able to extend others; however, the name of a submodule is unique within that module. This structure is to facilitate creation of internal infrastructure (types, constants, and procedures) that can be used by multiple submodules, without having to put all the infrastructure inside the module itself.

The submodule being defined accesses its parent module or submodule by host association; for entities from the module, this includes access to PRIVATE entities. Any local entity it declares in the specification-part will therefore block access to an entity in the host that has the same name.

The entities (variables, types, procedures) declared by the submodule are local to that submodule, with the sole exception of separate module procedures that are declared in the ancestor module and defined in the submodule. No procedure is allowed to have a binding name, again, except in the case of a separate module procedure, where the binding name must be the same as in the interface.

Submodule information for use by other submodules is stored by the NAG Fortran Compiler in files named module.submodule.sub, in a format similar to that of .mod files. The -nomod option, which suppresses creation of .mod files, also suppresses creation of .sub files.


CONTAINS statement, END SUBMODULE statement, MODULE statement, Separate module procedures