Question: what is the difference between function and subroutine in fortran?
Answer: In Fortran, functions and subroutines are different: the former returns a value while the latter does not. Functions are simpler than subroutines. A function can only return one variable, and can be invoked from within expressions, like a write statement, inside an if declaration if (function) then , etc.