Procedures
Intent
In, Out, Inout
intent declares how an argument is used. in reads only, out writes only, inout both.
Program
Play the program to compute sum and difference through one subroutine.
intents.f90
program intents_demo
implicit none
integer :: a, b, sum_, diff
a = 10
b = 3
call summarize(a, b, sum_, diff)
print '(I0, A, I0)', sum_, " ", diff
contains
subroutine summarize(x, y, s, d)
integer, intent(in) :: x, y
integer, intent(out) :: s, d
s = x + y
d = x - y
end subroutine summarize
end program intents_demo
intent(in)
Read-only argument; the caller's value is unchanged.
intent(out)
Output-only argument; the callee assigns it.
multiple outputs
Use `intent(out)` arguments to return more than one value from a subroutine.