How to define a function in Fortran?
A function is a type of procedure that returns only a single quantity. The quantity which is returned is known as a function value, and the function value is denoted by the function name.
function name(arg1, arg2, ....)
[declarations, including those for the arguments]
end function [name]