You can't do this
ierr = MatSetSizes(A,PETSC_DECIDE,N,N,N);CHKERRQ(ierr);
use PETSC_DECIDE for the third argument
Also this is wrong
for (i = Istart; i < Iend; ++i)
{
ierr = MatSetValue(A,i,i,2,INSERT_VALUES);CHKERRQ(ierr);
ierr = MatSetValue(A,i+1,i,-1,INSERT_VALUES);CHKERRQ(ierr);
ierr = MatSetValue(A,i,i+1,-1,INSERT_VALUES);CHKERRQ(ierr);
}
you will get
$ petscmpiexec -n 2 ./ex1
0: Istart = 0, Iend = 60
1: Istart = 60, Iend = 120
[1]PETSC ERROR: --------------------- Error Message
--------------------------------------------------------------
[1]PETSC ERROR: Argument out of range
[1]PETSC ERROR: Row too large: row 120 max 119
[1]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for
trouble shooting.
[1]PETSC ERROR: Petsc Development GIT revision: v3.7.6-4103-g93161b8192 GIT
Date: 2017-06-11 14:49:39 -0500
[1]PETSC ERROR: ./ex1 on a arch-basic named Barrys-MacBook-Pro.local by
barrysmith Wed Jun 14 18:26:52 2017
[1]PETSC ERROR: Configure options PETSC_ARCH=arch-basic
[1]PETSC ERROR: #1 MatSetValues_MPIAIJ() line 550 in
/Users/barrysmith/Src/petsc/src/mat/impls/aij/mpi/mpiaij.c
[1]PETSC ERROR: #2 MatSetValues() line 1270 in
/Users/barrysmith/Src/petsc/src/mat/interface/matrix.c
[1]PETSC ERROR: #3 main() line 30 in /Users/barrysmith/Src/petsc/test-dir/ex1.c
[1]PETSC ERROR: PETSc Option Table entries:
[1]PETSC ERROR: -malloc_test
You need to get the example working so it ends with the error you reported
previously not these other bugs.
> On Jun 12, 2017, at 10:19 AM, Hoang Giang Bui <[email protected]> wrote:
>
> Dear Barry
>
> I made a small example with 2 process with one empty split in proc 0. But it
> gives another strange error
>
> [1]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
> [1]PETSC ERROR: Arguments are incompatible
> [1]PETSC ERROR: Local size 31 not compatible with block size 2
>
> The local size is always 60, so this is confusing.
>
> Giang
>
> On Sun, Jun 11, 2017 at 8:11 PM, Barry Smith <[email protected]> wrote:
> Could be, send us a simple example that demonstrates the problem and we'll
> track it down.
>
>
> > On Jun 11, 2017, at 12:34 PM, Hoang Giang Bui <[email protected]> wrote:
> >
> > Hello
> >
> > I noticed that my code stopped very long, possibly hang, at
> > PCFieldSplitSetIS. There are two splits and one split is empty in one
> > process. May that be the possible reason that PCFieldSplitSetIS hang ?
> >
> > Giang
>
>
> <ex.c>