<div dir="ltr">Just to give a bit more of context I am doing like this:<div><br></div><div>        call MatCreate(PETSC_COMM_WORLD, this%A, ierr)<br><br>        call MatSetSizes(this%A, lm, lm, M, M, ierr) ! lm is the local size of the matrix , M the global one<br><br>        call MatSetType(this%A, myType, ierr) ! myType is MATMPIBAIJ<br> <br>        call MatSetBlockSize(this%A, 4-bdim, ierr) ! 4-bdim is equal to 3 in this case<br><br>        call MatMPIBAIJSetPreallocation(this%A, 4-bdim, flubioSolvers%d_nz, mesh%d_nnz, flubioSolvers%o_nz, mesh%o_nnz, ierr) ! d_nnz and o_nnz is the number of diagonal and off diagonal non zero blocks<br><br>        call MatSetUp(this%A, ierr)<br></div><div>        </div><div>       ... some non relevant code .....</div><div><br></div><div>         call MatSetValuesBlocked(this%A, 4-bdim, mesh%cellGlobalAddr(iElement)-1, 4-bdim, mesh%cellGlobalAddr(iElement)-1, blockValues, INSERT_VALUES, ierr)  mesh%cellGlobalAddr(iElement)-1 is an integer equal (not an array) to the block element number the block matrix <i>blockValues (3x3) </i>belongs to.<br></div><div><br></div><div>Any evident errors? </div><div><br></div><div><br></div><div><br></div><div><br></div></div>