Fortran

Guide To Learn

Before we venture into writing our own custom modules, let’s first get familiar by accessing a built-in module that comes with Fortran out of the box. Fortran has a few built-in modules. The most commonly used one is iso_fortran_env, which, among other things, provides constants and procedures that allow you to write more portable programs. Another commonly used module is iso_c_binding, which allows you to interface functions and data in C and other languages. We’ll dig into that further in chapter 12.

In this section, you’ll learn how to import from Fortran modules by tackling two tasks: getting the compiler version and options, and accessing type kind parameters for declaring variables in a portable way. Why would you care about these things in practice? They’ll both become important if you ever develop your code in multiple environments (computers, operating systems, or compiler vendors), if you need your code to produce exactly the same results no matter where you run it, or if you distribute your compiled code to your colleagues or customers. Once you understand how to work with a built-in module, you’ll be ready to learn how to write your own.

Accessing a module

Leave a Reply

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

Scroll to top