Fortran

Guide To Learn

Advanced Fortran use

Implementation strategy

From our specifications list, it looks like we’ll need some clever way to handle date and time data, as well as the time difference. In chapter 8, we learned how to define arbitrary data structures using derived types. We can thus model dates, times, and time difference structures as derived types (or classes)–let’s call these datetime and timedelta, […]

Writing user-defined operators for the Field type

In chapter 8, we implemented the tsunami solver using the Field derived type to model physical fields such as water height and velocity. This allowed us to initialize the fields and express the solver equation cleanly and concisely, as shown in the following listing. Listing 9.9 Main tsunami solver using the Field derived type ❶ Imports the type from the […]

Redefining built-in operators

To wrap up the chapter, in this section we’ll practice redefining Fortran’s built-in operators to do something more or other than originally intended. For example, this could involve either of the following: I leave this one as an exercise for you (“Exercise 2” sidebar). It’s a fairly new concept, but we’ve already covered all the […]

Writing custom operators

A custom operator is essentially a procedure under the hood, with an extended syntax that allows it to be used in expressions much like built-in operators: Once we have a function or a subroutine, it’s straightforward to implement it as a custom operator. Tip Don’t confuse the custom operator syntax, .op. with the logical literal constants .true. or .false.. The latter […]

Scroll to top