program main implicit none integer i, j, k, n, m real*8, allocatable :: a(:,:), b(:,:), x(:), y(:), z(:) integer*8 time0, time1, dtime real*8 time c write(*,*)"Matrix size Elapsed time [sec]" do m=1,15 c Matrix size n = m * 1000 c Allocation allocate(a(n,n), b(n,n), x(n), y(n), z(n)) c Initialization do i=1,n do j=1,n a(j,i) = 1d0 b(j,i) = 2d0 end do x(i) = 1d0 end do c Start time call system_clock(time0) c Main calculation 1: matrix-vector product do i=1,n z(i) = 0d0 do k=1,n z(i) = z(i) + b(k,i) * x(k) end do end do c Main calculation 2: matrix-vector product do i=1,n y(i) = 0d0 do k=1,n y(i) = y(i) + a(k,i) * z(k) 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, x, y, z) end do end program