Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program main
- integer*4, parameter :: n=600, l=600, m=600
- real*8 :: A(l,m), B(m,n), C(l,n)
- write (*,*) size(A,1)
- call init(A)
- call init(B)
- call mtx_mul(A,B,C)
- ! call prt(C)
- contains
- subroutine init(mtx)
- real*8, intent(out) :: mtx(:,:)
- integer*4 :: i,j
- do i = 1,ubound(mtx, 1)
- do j = 1,ubound(mtx, 2)
- mtx(i,j) = (i-1)*(j-1) + 0.6 * (j-1) + 3.4;
- enddo
- enddo
- end subroutine init
- subroutine prt(mtx)
- real*8, intent(in) :: mtx(:,:)
- integer*4 :: i,j
- do i = 1,ubound(mtx, 1)
- do j = 1,(ubound(mtx, 2) -1)
- write (*,"(F10.1)",advance="no") mtx(i,j)
- enddo
- write (*,"(F10.1)") mtx(i,ubound(mtx, 2))
- enddo
- end subroutine prt
- subroutine mtx_mul(A, B, C)
- real*8, intent(in) :: A(:,:), B(:,:)
- real*8, intent(out) :: C(:,:)
- integer*4 :: i, j, k
- C = 0d0;
- do k = 1,ubound(C,2)
- do i = 1,ubound(C,1)
- do j = 1,ubound(A,2)
- C(i,k) = C(i,k) + A(i,j) * B(j,k)
- enddo
- enddo
- enddo
- end subroutine mtx_mul
- end program main
Add Comment
Please, Sign In to add comment