A do i = first, last loop iterates a counter and updates accumulator state.

Program

Play the program to add the numbers 1 through 3.

do_loop.f90
program do_loop
    implicit none
    integer :: i, total
    total = 0
    do i = 1, 3
        total = total + i
    end do
    print '(I0)', total
end program do_loop
do loop `do i = 1, 3` iterates with an integer counter.
accumulator `total` keeps state across iterations.
end do `end do` marks the loop boundary.