Fortran has two standard ways to return a result from a function. The first of these is the assignment of the return value of the function to the name of the function.
function foo()
integer :: foo
foo = 10
end function foo
The second form, standardized in Fortran 90, is implemented through the variable "result".
function foo result(res)
integer :: res
res = 10
end function foo
Calling any form of function returns 10. My question is, what was the basis for the Fortran 90 committee to introduce result variables? Did they standardize common practice? Or they allowed programs to be more modular without associating a function name with a function result. For example, in the second version, foo()the function name foo()can be changed to bar(), and the function will work as expected when called.
. - , ?