c Program to measure time to carry out matrix-vector product. c c(i) = sum(a(j,i)*b(j),j=1,...,n) for i=1,...,n program main implicit none integer i, j, k, n integer, allocatable :: a(:,:), b(:), c(:) integer*8 time0, time1, dtime real*8 time c write(*,*)"Matrix size Elapsed time [sec]" do k=1,30 c Matrix size n = k * 1000 c Allocation allocate(a(n,n), b(n), c(n)) c Initialization do i=1,n do j=1,n a(j,i) = 1 end do b(i) = 1 end do c Start time call system_clock(time0) c Main calculation: matrix-vector product do i=1,n c(i) = 0 do j=1,n c(i) = c(i) + a(j,i) * b(j) end do end do c Finish time call system_clock(time1, dtime) c Output time time = 1d0*(time1-time0)/dtime write(*,"(i12,f16.7)")n, time c Deallocation deallocate(a, b, c) end do end program