Ticket #48381: mul.f90

File mul.f90, 717 bytes (added by anowacki (Andy Nowacki), 9 years ago)

Test matrix multiplication program, designed to test BLAS performance.

Line 
1! If using gfortran, force a call to a linked BLAS library from the matmaul()
2! intrinsic by using the following flags:
3!     -fexternal-blas -fblas-matmul-limit=1
4! (See gfortran man page for details.)
5!
6! Otherwise replace matmul with a BLAS equivalent (e.g., dgemm).
7
8implicit none
9
10character(len=50) :: arg
11integer :: n, iostat, i, j
12real(8), dimension(:,:), allocatable :: a, b
13
14n = 1000
15if (command_argument_count() > 0) then
16   call get_command_argument(1, arg)
17   read(arg,*,iostat=iostat) n
18   if (iostat /= 0) error stop 'First argument must be an integer n'
19   if (n <= 0) error stop 'n must be > 0'
20endif
21
22allocate(a(n,n), b(n,n))
23
24a = reshape([((i+j, j=1,n), i=1,n)], [n,n])
25b = a
26
27a = matmul(a, b)
28
29end