After a few years of not using Fortran I'm having some troubles with matmul
. Suppose I have two matrix: A_{N,K} and B_{J,K} . I want to create a subroutine that takes a row of A and a row of B, multiplies that and creates the scalar C. This is what I wrote:
subroutine test_matmul(A, B, N, K, J, row_a, row_b, C)
integer, intent(in) :: N, K, J, row_a, row_b
double precision, dimension(N,K), intent(in) :: A
double precision, dimension(J,K), intent(in) :: B
double precision, intent(out) :: C
C = matmul(A(row_a,:), B(row_b,:))
end subroutine test_matmul
Alas, when I try to compile this I get the following error:
C = matmul(A(row_a,:), B(row_b,:))
1
Error: 'matrix_b' argument of 'matmul' intrinsic at (1) must be of rank 2
What am I doing wrong?