Procedures
Subroutines
Call With Side Effects
A subroutine updates its arguments through intent. call name(args) invokes it.
Program
Play the program to add a bonus into total through a subroutine.
subroutines.f90
program subroutines_demo
implicit none
integer :: total
total = 10
call add_bonus(total, 5)
print '(I0)', total
contains
subroutine add_bonus(value, bonus)
integer, intent(inout) :: value
integer, intent(in) :: bonus
value = value + bonus
end subroutine add_bonus
end program subroutines_demo
subroutine
`subroutine add_bonus(...)` declares a callable with no return value.
call
`call add_bonus(...)` invokes the subroutine.
contains
`contains` introduces internal procedures inside a program.