program for_all

implicit none
integer :: i, j
integer, dimension (5,5):: a, b

do i=1, 5
   do j=1, 5
      a(i,j)=i+j
      end do
   end do

do i=1, 5
   do j=1, 5
      write(*,"(I10)", ADVANCE="NO") a(i,j)
      end do
   write(*,*)
   end do
write(*,*)

forall(i=1:5, j=1:5, i<=j) b(i,j)=i*j
do i=1, 5
   do j=1, 5
      write(*,"(I10)", ADVANCE="NO") b(i,j)
      end do
   write(*,*)
   end do
write(*,*)

read(*,*)
end program for_all