Fortran

Guide To Learn

Advanced Fortran use

Static versus strong typing

Static and strong typing are often confused and used interchangeably. However, they describe two different properties of a programming language. A statically typed language assumes that all variables must have either a manifestly declared data type (like in Fortran or C) or a data type inferred from their use (like in Julia, Nim, or Rust) at compile time. […]

Strategy for this exercise

To find the city with the optimal climate, we’ll go through the following steps: Sounds easy, right? We covered most of the logistics around reading and processing time series data in chapters 5 and 7. Here, we’ll focus on implementing the generic average function that can operate on integer, real, or logical data.

Analyzing weather data of different types

Consider the following scenario: You’re fresh out of school, or perhaps ready to move on to the next step in your career. You’re looking into a number of cities around the world to live in: Seattle, New York City, Miami, London, Mexico City, and a few others. For many people, myself included, weather is an […]

Derived type implementation of the tsunami solver

Finally, we’re getting close to the home stretch. The following listing provides the (almost) complete code of the derived type implementation of the tsunami simulator. I’ve omitted the declaration section for brevity. Listing 8.13 Derived type implementation of the tsunami solver ❶ Initializes Fields ❷ Sets initial water height perturbation and sync ❸ Sets a constant mean water […]

Passing a class instance to diffx and diffy functions

To use finite difference functions directly with our new Field instances, we’ll make simple wrappers around those functions. First, we’ll import the functions and make them available in the mod_field module: ❶ Renames on import so we can use the original names We want to keep the original names diffx and diffy, so I’ve renamed them on import to avoid a name conflict. In […]

Finite differences in x and y

In addition to an extra equation and a finite difference term for each of the x and y axes, we need specific implementations of diff for each of them. diffx will return a difference along array rows, and diffy along array columns. The function in the following listing served us well in the one-dimensional solver. Listing 8.9 One-dimensional version of the finite difference function ❶ Input array […]

Scroll to top