Advertisement
Guest User

asdqawr

a guest
Oct 9th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program main
  2.     implicit none
  3.     integer, parameter :: n = 1000 !размерность
  4.     real, dimension(n, n) :: matr1, matr2
  5.     integer i, j
  6.     real :: starttime, finishtime
  7.     call cpu_time(starttime)
  8.     do j = 1, n
  9.         do i = 1, n
  10.             matr1(i, j) = sin(1.*i*j)
  11.             matr2(i, j) = 1. / ((1.*i)**j)
  12.         end do
  13.     end do
  14.     call mult(matr1, matr2, n)
  15.  
  16.     call cpu_time(finishtime)
  17.     print *, 'Calculation time: ', finishtime - starttime
  18. end program main
  19.  
  20. subroutine mult(a, b, n)
  21.     integer, intent(in) :: n
  22.     real, dimension(n, n) :: a, b, c
  23.     integer i, j, k
  24.     real temp
  25.     open(2, file='asd.txt')
  26.     do j = 1, n
  27.         do i = 1, n
  28.             temp = 0.
  29.             do k = 1, n
  30.                 temp = temp + a(i,k)*b(k,j)
  31.             end do
  32.             c(i, j) = temp
  33.             write(2, *) c(i, j)
  34.         end do
  35.         write(2, *) "====================================="
  36.     end do
  37.     close(2)
  38. end subroutine mult
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement