<html><head></head><body><div class="ydp337a5c99yahoo-style-wrap" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 10px;"><span>Hello,<br><br>I am trying to compute the local row ranges allocated to the processes i.e. rstart and rend of each process, needed as a <span>prerequisite</span> for MatMPIAIJSetPreallocation using d_nnz and o_nnz.<br><br>I tried the following:<br><br>...<br><br> PetscInitialize(0,0,PETSC_NULL,PETSC_NULL);<br><br> MPI_Comm_size(PETSC_COMM_WORLD,&size);<br> MPI_Comm_rank(PETSC_COMM_WORLD,&rank);<br><br> MatCreate(PETSC_COMM_WORLD,&A);<br> MatSetType(A,MATMPIAIJ);<br> PetscInt local_size = PETSC_DECIDE;<br> PetscSplitOwnership(PETSC_COMM_WORLD, &local_size, &N);<br> MPI_Scan(&local_size, &rend, 1, MPIU_INT, MPI_SUM, PETSC_COMM_WORLD);<br> rstart = rend - local_size;<br> PetscInt d_nnz[local_size], o_nnz[local_size];<br>/*<br><br>compute d_nnz and o_nnz here<br><br> MatMPIAIJSetPreallocation(A,0,d_nnz,0,o_nnz);<br>*/<br><br> for (rank = 0; rank < size; rank++) {<br> PetscPrintf(PETSC_COMM_WORLD,"local_size = %d, on process %d\n", local_size, rank);<br> PetscPrintf(PETSC_COMM_WORLD,"rstart = %d, on process %d\n", rstart, rank);<br> PetscPrintf(PETSC_COMM_WORLD,"rend = %d, on process %d\n", rend, rank);<br> }<br><br> PetscFinalize();<br><br>The local size is 25 rows on each process but rstart and rend are 0 and 25 on all processes, I expected 0 and 25, 25 and 50, 50 and 75 and 75 and 101. N = 100<br><br>I can't spot the error. Any ideas, what's the problem?<br><br>Klaus</span></div></body></html>