Subroutines / Subprograms

In simulation, a subroutine (also known as a subprogram or procedure) refers to a section of code that performs a specific task and can be called by the main program or other subroutines.

Subroutines are commonly used in simulation to simplify complex simulations by breaking them down into smaller, more manageable tasks. By encapsulating specific functionality into a subroutine, the main program can call that subroutine whenever that specific functionality is required, rather than duplicating the same code throughout the main program. This can make the code easier to read, maintain, and debug.