Fortran

Guide To Learn

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, respectively.

Once we have a datetime class, we’ll need a way to load an instance from user-input command-line arguments, and another from local machine time. Fortran packs a few subroutines that we can use for these tasks. As noted, for the time difference, we’ll make the timedelta class. We’ll also need a way to take the difference between two datetimes. This item is twofold–one is a syntax to define the arithmetic (-) operator for the datetime class, and the other is the actual algorithm to do the calculation.

In section 10.2, we’ll tackle the date and time data structure (the datetime derived type) and how to create datetime instances from both user input and current machine time. Then, in section 10.3, we’ll implement the time difference or interval structure, the timedelta class, and we’ll get into the nitty-gritty of defining custom operators.

Implementation strategy

Leave a Reply

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

Scroll to top