diff options
author | Wojtek Kosior <kwojtus@protonmail.com> | 2019-04-24 16:56:04 +0200 |
---|---|---|
committer | Wojtek Kosior <kwojtus@protonmail.com> | 2019-04-24 16:56:04 +0200 |
commit | 755d7e5b94b0a978460523eef8b39ab3e5866e5f (patch) | |
tree | c98c4d40dc8de612519a039a8cce7a940c22cfde | |
parent | a9245d4fa33ce7e0a681300540d4ec675a1e688a (diff) | |
download | fortran-assignment1-755d7e5b94b0a978460523eef8b39ab3e5866e5f.tar.gz fortran-assignment1-755d7e5b94b0a978460523eef8b39ab3e5866e5f.zip |
add primitive main program
-rw-r--r-- | src/main.F90 | 46 |
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 |