Factorize multiple sparse matrices stored in multi-dimensional Fortran arrays
The PaStiX 5 fortran API allowed for the access to matrices stored as columns of a multidimensional array.
As an example, an application could have to choose a given matrix among a predefined set, accordingly to some run-time condition.
The matrices could be stored with an extra index self%il_ia(:,:), self%ila_ja(:,:), self%rla_L(:,:)
where the first dimension is the usual storage and the second is the linear system identfier.
In such a case, PaStiX 5 is called for the linear system il_gsys
by
CALL pastix_fortran(self%sla_px(il_gsys)%pastix_data, &
self%sla_px(il_gsys)%pastix_comm, &
self%sla_px(il_gsys)%n, &
self%ila_ia(:,il_gsys),self%ila_ja(:,il_gsys), &
self%rla_L(:,il_gsys), &
self%sla_px(il_gsys)%perm,self%sla_px(il_gsys)%invp, &
self%rla_L(:,il_gsys),self%sla_px(il_gsys)%nrhs, &
self%sla_px(il_gsys)%iparm,self%sla_px(il_gsys)%dparm)
It turns out that neither this syntax
self%sla_spm%rowptr = c_loc(self%ila_ia(:,il_gsys))
nor
self%sla_spm%rowptr = c_loc(self%ila_ia(1,il_gsys))
lead to correct results.
As a workaround, we plan to rewrite our routines using arrays of derived datatypes
type sys_lin
type(pastix_data_t), pointer :: pastix_data
type(pastix_spm_t), pointer :: spm
type(pastix_spm_t), pointer :: spm2
integer(kind=pastix_int_t), dimension(:), pointer :: ila_ia
integer(kind=pastix_int_t), dimension(:), pointer :: ila_ja
complex(kind=c_double_complex), dimension(:), pointer :: rla_L
end type sys_lin
type(sys_lin), dimension(:), allocatable, target :: sla_lap
...
self%sla_lap(ib)%spm%rowptr = c_loc(sla_lap(ib)%ila_ia)
self%sla_lap(ib)%spm%colptr = c_loc(sla_lap(ib)%ila_ja)
self%sla_lap(ib)%spm%values = c_loc(sla_lap(ib)%rla_L)