aboutsummaryrefslogtreecommitdiff
path: root/src/main.F90
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.F90')
-rw-r--r--src/main.F9046
1 files changed, 46 insertions, 0 deletions
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