Fortran

Guide To Learn

Core elements of Fortran

Analyzing stock prices with Fortran arrays

We’ll learn how Fortran arrays work in a real-world application–analyzing stock price time series. This has been an increasingly popular topic since the early days of computer programming, and Fortran has been used in the bowels of many trading and banking systems, mainly thanks to its robustness, reliability, and efficiency. In this chapter, we’ll work […]

Exercise 2: Defining the set_gaussian subroutine in a module

The task is to define the set_gaussian subroutine, which sets the values of an input array to a specific shape, in its own module. The solution is analogous to defining the diff function in the mod_diff module. This time, we’re defining the set_gaussian procedure in the mod_initial module, as shown in the following listing. Listing 4.12 Defining the set_gaussian subroutine in a custom module ❶ Imports standard type kinds […]

Exercise 1: Using portable type kinds in the tsunami simulator

The task is to import the portable type kind parameters from the iso_fortran_env module and use them in the tsunami simulator. To do this, we’ll rewrite only the declaration section, as shown in the following listing. Listing 4.11 Using portable type kinds in the tsunami simulator ❶ Assigns a name to the program ❷ Accesses only these two constants from […]

The complete code

Finally, we get to the end! The complete code for the main application is shown in the following listing. Listing 4.10 Complete code of the main program of the tsunami simulator ❶ Imports type kind parameters for numeric data ❷ Imports the diff_centered function from the mod_diff module and renames it as diff ❸ Imports the set_gaussian procedure […]

Renaming imported entities to avoid name conflict

Based on what we’ve covered so far about importing entities from Fortran modules, you can imagine a situation where variables or procedures with the same name could be imported from different modules. What happens in that case? Fortran will let you import two entities with the same name; however, it won’t let you reference them. […]

Scroll to top