I am trying to build a block tridiagonal matrix in Fortran. Now I have this piece of code that would deal with just the matrices that are placed in the main diagonal of the A_matrix
, one new matrix for every step in i
.
do i = gs+1, total_mesh_points
start_line = (3*i)-2
start_colu = (3*i)-2
final_line = (3*i)
final_colu = (3*i)
do ii = 1, 3
do jj = 1, 3
A_matrix(start_line:final_line,start_colu:final_colu) = &
impflux(ii,jj)
end do
end do
end do
Here my A_matrix(i,j)
is a big matrix that will receive another three by three matrix (impflux
) in its main diagonal. Note that for each step in i
I will have a new impflux
matrix that needs to be positioned in the main diagonal of the A_matrix
.
I can't think in a more simple solution for this problem. How people usually build block diagonal matrices in Fortran ?
ii
andjj
it repeatedly updates the same elements ofa_matrix
, first withimpflux(1,1)
, then withimpflux(1,2)
, etc. I'd probably understand better if you showed us a small example of what you are trying to create. – High Performance Mark