Chapter 3. Organizing your Fortran code using modules

 

Chapter 4 from Modern Fortran by Milan Curcic

This chapter covers:

  • Accessing variables and procedures in modules
  • Writing your own custom module
  • Refactoring the tsunami simulator with modules

So far we’ve covered the essential building blocks of Fortran: Built-in types and declaration, arithmetic, control flow, and procedures. In theory, this is all you need to write correct and powerful Fortran programs. In practice, however, as your app or library grows in size, organization of your source code becomes ever more important. This is where modules come in to the rescue. Modules allow you to organize variable and procedure definitions in a meaningful way, and make them accessible for use in programs, procedures, or other modules. Modern Fortran libraries are typically organized in one or more modules. Large applications define most functionality in modules, with only the top-level code being defined in the main program. In this chapter, we’ll write a few modules to define variables and functions that will be accessed from the main program of our tsunami simulator.

4.1  Accessing a module

 
 
 
 

4.2  Creating your first module

 
 

4.3  Toward realistic wave simulations

 
 
 

4.4  Answer key

 
 

4.5  New Fortran elements, at a glance

 

4.6  Further reading

 

4.7  Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest