program nested_loops

!-- example using named, nested, non-indexed do loops

  implicit none
  integer :: i, j

  i = 0; j = 0;
  outa: do
    i = i+1
    inna: do 
      j = j+1
      print*, "i is", i," j is", j
      if (i >= 5 .or. j >= 5) exit outa
      if (i == 2 .or. j == 4) cycle outa
      if (i == 3 .and. j == 3) exit inna
    enddo inna
  enddo outa
  print*, "Loop finished.  I now equals", i

end program nested_loops
