I learn how to use blas and lapack libs in fortran for operationg with banded matricies. The code below i use to solve 2d heat equation by Peaceman‐Rachford schema, but i cut all not needed code. What i need? I need to multiply banded matrix coefficients on vector of function to get second deriv of function.
I create two arrays: test_array_col(2, N+1) and test_array_row(N+1, 2) and matrix band_matrix_y(3, N+1). I init array by 1.0. After calling dgbmv('N', N+1, N+1, 1, 1, 1.0_dp, band_matrix_y, 3, test_array_col(1, :), 1, 1.0_dp, test_array_col(1, :), 1)
or dgbmv('N', N+1, N+1, 1, 1, 1.0_dp, band_matrix_y, 3, test_array_row(:, 1), 1, 1.0_dp, test_array_row(:, 1), 1)
i expect get array where all elements are equal to 1.0, but i get this results only in first call.
The issue is that i need to store 2d array of my function and call dgbmv on each time step first for each row (work) and for each column (dont work). What can i do without transposing my 2d array of function on each time step. Of course i can implement this functionality myself, but i want to explain what happen below
The whole code here
program dgbmv_issue
implicit none
integer, parameter:: N=10, M=10, dp=(kind(0.d0))
double precision, dimension(:, :):: band_matrix_y(3, N+1), test_array_col(2, N+1), test_array_row(N+1, 2)
integer:: i
double precision:: DX, DY, L_X, L_Y, DT
external:: dgbmv
test_array_col = 1.0_dp
test_array_row = 1.0_dp
L_X = 1.0_dp
L_Y = 1.0_dp
DX = L_X / M
DY = L_Y / N
DT = 0.01_dp
band_matrix_y = 0.0_dp
band_matrix_y(1, 3:) = 0.5_dp * DT / DY / DY
band_matrix_y(2, 2:N) = -DT / DY / DY
band_matrix_y(3, :N-1) = 0.5_dp * DT / DY / DY
open(1, file='out.txt')
do i = 1, 3
write(1, *) band_matrix_y(i, :)
end do
call dgbmv('N', N+1, N+1, 1, 1, 1.0_dp, band_matrix_y, 3, test_array_col(1, :), 1, 1.0_dp, test_array_col(1, :), 1)
write(1, *) 'X'
write(1, *) test_array_col(1, :)
call dgbmv('N', N+1, N+1, 1, 1, 1.0_dp, band_matrix_y, 3, test_array_row(:, 1), 1, 1.0_dp, test_array_row(:, 1), 1)
write(1, *) 'X'
write(1, *) test_array_row(:, 1)
close(1)
end program dgbmv_issue
And here’s meson build file
project('dgbmv_issue', 'fortran')
lapack = dependency('lapack')
blas = dependency('blas')
executable('dgbmv_issue', 'dgbmv_issue.f90', dependencies: [lapack, blas])
Can anybody help me? Please🙏