Multiple Return Values in Fortran
Fortran has built-in support for multiple return values through the use of derived types or arrays. This feature can be used to return both result and error values from a function.
To run the program, save it as multiple_return_values.f90
and compile it using a Fortran compiler:
In Fortran, we don’t have a direct equivalent to the blank identifier _
used in some other languages. However, we can simply ignore unwanted values by not assigning them to variables.
Fortran doesn’t have built-in support for multiple return values in the same way as some modern languages, but we can achieve similar functionality using derived types or arrays. This example demonstrates how to use a derived type to return multiple values from a function.
The next example might cover more advanced features of Fortran subroutines and functions.