10 User-defined operators for derived types

This chapter covers

  • User-defined operators for derived types
  • Writing a minimal countdown app
  • Validating user input
  • Synchronization on assignment in the tsunami simulator

Almost any app working with real-world data, or any program more complex than a toy model, will use derived types (classes) to handle abstract data. Operators for arithmetic (+, -, *, /, **) and comparison (==, /=, >=, <=, >, <) are available out of the box for built-in numeric types (integer, real, complex), but not for derived types. For example, to keep track of the calendar date and time in an app, you’d need to compare, add, and subtract datetime instances (data structures that represent date and time). This is where derived ...

Get Modern Fortran now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.