From 755d7e5b94b0a978460523eef8b39ab3e5866e5f Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 24 Apr 2019 16:56:04 +0200 Subject: add primitive main program --- src/main.F90 | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main.F90 diff --git a/src/main.F90 b/src/main.F90 new file mode 100644 index 0000000..f898e1a --- /dev/null +++ b/src/main.F90 @@ -0,0 +1,46 @@ +PROGRAM mul + USE naivmat + USE bettmat + USE dotmat + IMPLICIT none + + real(kind=4), dimension(:,:), allocatable :: mat1, mat2, res1, res2 + + call init_random_seed() + + allocate(mat1(10,10)) + allocate(mat2(10,10)) + allocate(res1(10,10)) + allocate(res2(10,10)) + + call random_number(mat1) + call random_number(mat2) + + print *, "mat1:", char(10), mat1 + print *, "mat2:", char(10), mat2 + + res1 = naivmull(mat1, mat2) + res2 = matmul(mat1, mat2) + + print *, "res:", char(10), res1 + print *, "res_diff:", char(10), res1 - res2 + +CONTAINS + + SUBROUTINE init_random_seed() + integer :: i, n, clock + integer, dimension(:), allocatable :: seed + + call random_seed(size = n) + + allocate(seed(n)) + + call system_clock(count = clock) + + seed = clock + 37 * (/ (i - 1, i = 1, n) /) + + call random_seed(put = seed) + + END SUBROUTINE init_random_seed + +END PROGRAM mul -- cgit v1.2.3