Fortran

Guide To Learn

Modifying program state with subroutines

I mentioned earlier that Fortran has two kinds of procedures: functions and subroutines. Many rules that we covered for functions apply to subroutines as well. They’re both designed to be reused many times, and both may have input and output arguments. Unlike functions, subroutines can’t be used in expressions and can only be invoked in a dedicated call statement. They’re more suitable for operations with side effects, such as modifying variables in-place and I/O. In this section, I’ll show you how subroutines are different from functions and when you should use them instead.

Modifying program state with subroutines

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top