!
! Matmul sample program
! written by Carlo Cavazzoni - CINECA - Feb 2003
! send any comments to
! c.cavazzoni@cineca.it
!

      PROGRAM test_dgemm

      IMPLICIT NONE

      INTEGER, PARAMETER :: dim = 1000
      REAL*8, ALLOCATABLE :: x(:,:), y(:,:), z(:,:)
      INTEGER :: i,j,k
      REAL*8 :: t1, t2, y_val, z_val
      REAL*8 :: cclock
      EXTERNAL :: cclock

      ALLOCATE( x( dim, dim ), y( dim, dim ), z( dim, dim ) )

      read(5,*) y_val, z_val

      y = y_val
      z = z_val / DBLE( dim )
      x = 0.0d0


      do j = 1, dim
        do i = 1, dim
          do k = 1, dim
            x(i,j) = x(i,j) + y(i,k) * z(k,j)
          end do
        end do
      end do


      write(*,*) ' Matrix sum = ', sum(x)
      DEALLOCATE( x, y, z )

      END PROGRAM
