! Program Example from "Essential Fortran 90 & 95" by Loren P. Meissner
! Copyright 1996. Copying for sale requires permission from the author.
! Otherwise, distribution is permitted if these three lines are included.

! Example 5.29. The where construct.
  program F29
    implicit none
    real, dimension(5, 7) :: A, B, C, D
    integer :: I, J
! start program F29
    do I = 1, 5
      do J = 1, 7
        B(I, J) = I * J
        C(I, J) = modulo( I + J, I )
      end do
    end do
    where (C > 0.0)
      A = B / C
      D = sqrt( C )
    elsewhere
      A = 0.0
      C = 0.0
      D = -1.0
    end where
    write (unit = *, fmt = *) "A: ", A
    write (unit = *, fmt = *) "B: ", B
    write (unit = *, fmt = *) "C: ", C
    write (unit = *, fmt = *) "D: ", D
    stop
  end program F29
