aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-04-24 16:56:04 +0200
committerWojtek Kosior <kwojtus@protonmail.com>2019-04-24 16:56:04 +0200
commit755d7e5b94b0a978460523eef8b39ab3e5866e5f (patch)
treec98c4d40dc8de612519a039a8cce7a940c22cfde
parenta9245d4fa33ce7e0a681300540d4ec675a1e688a (diff)
downloadfortran-assignment1-755d7e5b94b0a978460523eef8b39ab3e5866e5f.tar.gz
fortran-assignment1-755d7e5b94b0a978460523eef8b39ab3e5866e5f.zip
add primitive main program
-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