Skip to main content

10.2) Understanding Subroutines


Here is an example of a subroutine in a program.

       program example17
       implicit none
       real :: a, b
       ! Read in two values
       a=10.0; b=5.0
       call mysb(a,b)
       print *, a, b
       contains
       subroutine mysb(x, y)
       real :: x, y, z
       z=0.45
       x = z + y**2
       end subroutine mysb
       end program example17

To view a video that explains this example see the next page.