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_intandaverage_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
averagethat overrides specificaverage_intandaverage_realfunctions that operate on integers and reals, respectively, then you’ll be able to invokeaveragewith 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