Fortran

Guide To Learn

Type systems and generic procedures

Before jumping into writing our first generic procedure, let’s briefly introduce a few new concepts that will get us there:

  • Strong typing –As I mentioned earlier, Fortran is a strongly typed language, which means that the variables and expressions you pass as input arguments to procedures must match the data type of arguments declared in the function or subroutine definition.
  • Specific procedure –A specific procedure is the implementation of a function or subroutine that’s specific to the input data type. For example, if you’re writing a function to average integer or real numbers, you’d write specific functions–for example, average_int and average_real.
  • Generic procedure –A generic procedure is the interface that can refer to a number of different specific procedures. If you define a generic interface average that overrides specific average_int and average_real functions that operate on integers and reals, respectively, then you’ll be able to invoke average with either data type.

Although Fortran is both statically and strongly typed, don’t confuse the two. I’ll explain the difference in the following subsection.

Type systems and generic procedures

Leave a Reply

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

Scroll to top