Fortran

Guide To Learn

The structure of a custom module

Before we begin, let’s see what a custom module may look like on the inside, and how its building blocks work (figure 4.3).

Figure 4.3 Structure of a custom Fortran module

Every Fortran module is defined with a pair of module/end module statements. Modules can’t have any executable code on their own. Instead, they’re used to declare data and define functions and subroutines. Like in the main program, the variable declaration and procedure definition sections are separated with a contains statement. Modules can also import variables and procedures from other modules. Finally, you can make any entities defined in a module be public or private, which determines whether they can be imported elsewhere or are meant to be hidden and for internal use only.

That’s it in a nutshell! In the rest of this section, we’ll work step-by-step toward building our first custom Fortran module.

The structure of a custom module

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top