# [petsc-users] MatCreateMPIAIJWithArrays

Smith, Barry F. bsmith at mcs.anl.gov
Mon Jul 23 10:18:15 CDT 2018

```MatCreateMPIAIJWithArrays(PETSC_COMM_WORLD, 2,    2, 10,10, i,j,a); for node1
^^^^^^^^     ^^^^

> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node1
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node2
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node3
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node4
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node5

> On Jul 23, 2018, at 4:26 AM, 金degang <328937290 at qq.com> wrote:
>
> Hello,
>       I am a beginner user.  I meet a problem.  I have a very big matrix.  In shaping the matrix, every nodes produce some rows of it. So it is very easy to store it with files at every node.  In the solve Ax=b, I hope every node to read the file and construct the big matrix in parallel. Every file's is a sub matrix which is row block. So I use MatCreateMPIAIJWithArrays to Create the matrix.
>
> For example:
>  -1	2	-1	0	0	0	0	0	0	0
> 0	-1	2	-1	0	0	0	0	0	0
> ---------------------------------------------------------------
> 0	0	-1	2	-1	0	0	0	0	0
> 0	0	0	-1	0	0	0	0	0	0
> ---------------------------------------------------------------
> 0	0	0	0	-1	2	-1	0	0	0
> 0	0	0	0	0	-1	2	-1	0	0
> ---------------------------------------------------------------
> 0	0	0	0	0	0	-1	2	-1	0
> 0	0	0	0	0	0	0	-1	2	-1
> ---------------------------------------------------------------
> 0	0	0	0	0	0	0	0	-1	2
> 0	0	0	0	0	0	0	0	0	-1
>
> Node 1    0-1 row block
>  Node 2   2-3 row block
> Node 3   4-5 row block
> Node 4   6-7 row block
> Node 5  8-9 row block
>
> use
>
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node1
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node2
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node3
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node4
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node5
>
> but there are error .   sum of cols of five nodes is not equal 10 (global column).
>
> How to solve this problem,  Hope to get your help!
>
> thanks
>
> Degang Jin

```