c c c
      program test
c
c    Example of WHERE, ELSE WHERE, END WHERE
c
c    John Mahaffy 2/16/96
c
      parameter (nd=10,ndh=nd/2,nduh=nd-ndh-1)
c
      real, dimension(nd):: a=(/(2*j,j=1,nd)/), b, c
c
      integer iflag(nd)
      data b/ndh*1,0.0,nduh*2./,c/nd*-77.77/
      where (b.ne.0) c=a/b
      write (*,2000) c(1:nd)
 2000 format ('a/b = ',/,(10f7.2))
c
c   The above protects against divide by zero, but doesn't actually assign
c   values to elements in c when the corresponding element in b is zero
c   The following covers that, and sets a flag when a divide by zero is
c   present
c
c
      where (b(1:nd).ne.0.0)
c
         c=a/b
         iflag=0
c
      else where
c
         c=0.0
         iflag=1
c
      end where
c
      write (*,2000) c(1:nd)
      write (*,1000) iflag(1:nd)
 1000 format ('iflag= ',/,(10i7))
      stop
      end
c
c c