      program replicate

      double precision a(10,10), ra(5,5), x
      integer i, j, n

cmf$  layout ra(:serial,:serial)

      forall (i=1:10,j=1:10) a(i,j) = i + j

      ra = 0
      ra = a(4:8,2:6)

      n = 0
      do i = 4, 8
        do j = 2, 6
           n = n + i + j
           print *, 'a(',i,',',j,') = ', a(i,j)
        end do
      end do

      do i = 1, 5
        do j = 1, 5
           print *, 'ra(',i,',',j,') = ', ra(i,j)
        end do
      end do

      x = sum (ra)

      print *, x

      print *, 'Result is ', x, ' should be ', n

      end
