Fortran

Guide To Learn

Fortran Wiki article on submodules: http://fortranwiki.org/fortran/show/Submodules

Summary

  • Modules are special program units that allow you to define functions, subroutines, and variables in one place.
  • Fortran comes with a few built-in modules, such as iso_fortran_env and iso_c_binding.
  • The built-in module iso_fortran_env provides, among other things, functions that return information about the compiler and the options used to compile the program, as well as type kind parameters that allow you to declare variables in a portable way.
  • Compiling modules produces special .mod files, which must be included in the compiler path when building other Fortran code that accesses the modules.
  • Accessing a module with just the use statement imports all public entities from the module into the current scope. You can use an expanded variant, use ..., only: ..., to import only specific entities.
  • Entities defined in a module can be public or private. Public entities are available for use to any program or procedure that uses that module. Private entities can only be accessed within the module itself.
  • You can set public and private properties of module entities using the public and private attributes, respectively.
  • Variables and procedures with conflicting names can be imported from modules but can’t be referenced. To work around the name conflict, use the => operator to rename a variable or procedure on import.
Further reading

Leave a Reply

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

Scroll to top