1414---
1515```
1616
17- Module files hold information from a module that is necessary to compile
18- program units in other source files that depend on that module.
17+ Module files hold information from a module (or submodule) that is
18+ necessary to compile program units in other source files that depend on that module.
1919Program units in the same source file as the module do not read
2020module files, as this compiler parses entire source files and processes
2121the program units it contains in dependency order.
@@ -26,6 +26,13 @@ Module files are named according to the module's name, suffixed with `.mod`.
2626This is consistent with other compilers and expected by makefiles and
2727other build systems.
2828
29+ Module files for submodules are named with their ancestor module's name
30+ as a prefix, separated by a hyphen.
31+ E.g., ` module-submod.mod ` is generated for submodule `submod' of module
32+ ` module ` .
33+ Some other compilers use a distinct filename suffix for submodules,
34+ but this one doesn't.
35+
2936The disadvantage of using the same name as other compilers is that it is not
3037clear which compiler created a ` .mod ` file and files from multiple compilers
3138cannot be in the same directory. This can be solved by adding something
@@ -40,17 +47,6 @@ and obtain a matching `foo.mod` file.)
4047They include the declarations of all visible locally defined entities along
4148with the private entities on which thef depend.
4249
43- Declarations of objects, interfaces, types, and other entities are
44- regenerated from the compiler's symbol table.
45- So entity declarations that spanned multiple statements in the source
46- program are effectivel collapsed into a single * type-declaration-statement* .
47- Constant expressions that appear in initializers, bounds, and other sites
48- appear in the module file in as their folded values.
49- Any compiler directives (` !omp$ ` , ` !acc$ ` , &c.) relevant to the declarations
50- of names are also included in the module file.
51-
52- Executable statements are omitted.
53-
5450### Header
5551
5652Module files begin with a UTF-8 byte order mark and a few lines of
@@ -67,12 +63,26 @@ The header comments do not contain timestamps or original source file paths.
6763
6864### Body
6965
70- The body comprises minimal Fortran source for the required declarations.
71- The order generally matches the order they appeared in the original
66+ The body comprises minimal Fortran source for the required declarations.
67+ Their order generally matches the order they appeared in the original
7268source code for the module.
7369All types are explicit, and all non-character literal constants are
7470marked with explicit kind values.
7571
72+ Declarations of objects, interfaces, types, and other entities are
73+ regenerated from the compiler's symbol table.
74+ So entity declarations that spanned multiple statements in the source
75+ program are effectivel collapsed into a single * type-declaration-statement* .
76+ Constant expressions that appear in initializers, bounds, and other sites
77+ appear in the module file in as their folded values.
78+ Any compiler directives (` !omp$ ` , ` !acc$ ` , &c.) relevant to the declarations
79+ of names are also included in the module file.
80+
81+ Executable statements are omitted.
82+ If we ever want to do Fortran-level inline expansion of procedures
83+ in the future,
84+ we will have to "unparse" the executable parts of their definitions.
85+
7686#### Symbols included
7787
7888All public symbols from the module are included.
@@ -84,10 +94,11 @@ In addition, some private symbols are needed:
8494
8595#### USE association
8696
87- A module that contains ` USE ` statements needs them represented in the
88- ` .mod ` file.
89- Each use-associated symbol will be written as a separate * use-only* statement,
90- possibly with renaming.
97+ Entities that have been included in a module by means of USE association
98+ are represented in the module file with ` USE ` statements.
99+ Name aliases are sometimes necessary when an entity from another
100+ module is needed for a declaration and conflicts with another
101+ entity of the same name.
91102
92103## Reading and writing module files
93104
0 commit comments