Book contents
- Frontmatter
- Contents
- Source Code Listings
- Preface
- 1 Introduction
- 2 General Principles
- 3 Formatting Conventions
- 4 Naming Conventions
- 5 Documentation Conventions
- 6 Programming Principles
- 7 Programming Conventions
- 8 Input and Output
- 9 Packaging Conventions
- 10 Generic Programming
- 11 Object Orientation
- 12 Parallel Processing
- 13 Numerical Types, Kinds, and Operations
- 14 C Interoperability
- 15 Updating Old Programs
- A Source Code
- B Rule List
- Bibliography
- Index
9 - Packaging Conventions
Published online by Cambridge University Press: 05 December 2011
- Frontmatter
- Contents
- Source Code Listings
- Preface
- 1 Introduction
- 2 General Principles
- 3 Formatting Conventions
- 4 Naming Conventions
- 5 Documentation Conventions
- 6 Programming Principles
- 7 Programming Conventions
- 8 Input and Output
- 9 Packaging Conventions
- 10 Generic Programming
- 11 Object Orientation
- 12 Parallel Processing
- 13 Numerical Types, Kinds, and Operations
- 14 C Interoperability
- 15 Updating Old Programs
- A Source Code
- B Rule List
- Bibliography
- Index
Summary
Files
Place each program unit in a separate file.
Program units in Fortran are the main program, external subroutines, modules, and submodules. Placing each unit in a separate file makes the program easier to maintain. Shorter files tend to compile faster. You can locate different program components in files more easily. When a team of programmers is collaborating on a project, smaller files make it less likely that the work of one programmer will conflict with that of others.
It is crucial that you place submodules in files separate from their parent modules. Doing so prevents “compilation cascade,” a phenomena where a change in the implementation of a subprogram needlessly causes the recompilation of other program units (see Rule 124).
Whenever possible, use the module name, the type name, the subprogram name, or the program name as the file name.
This rule makes it easier to maintain programs. This is especially true if you code in conformance to Rule 133 and place each derived type in its own module, and you also choose to use either a prefix or suffix attached to a common base name when naming derived types and the modules that contain them. In that case, name the file according to the base name. For instance, you might have a type called pixel_t defined in module pixel_mod, and you can name the file pixel.f03 (see Section 4.2).
- Type
- Chapter
- Information
- Modern FortranStyle and Usage, pp. 165 - 170Publisher: Cambridge University PressPrint publication year: 2011