static char help[] = "Testing MatCreate\n"; #include int main(int argc,char **argv) { PetscInt nrowsLoc,ncolsLoc; Mat A; PetscMPIInt rank; PetscCall(PetscInitialize(&argc,&argv,NULL,help)); MPI_Comm_rank(PETSC_COMM_WORLD,&rank); nrowsLoc = 10+rank; ncolsLoc = 20+rank; PetscCall(MatCreate(PETSC_COMM_WORLD, &A)); PetscCall(MatSetSizes(A, nrowsLoc, ncolsLoc, PETSC_DETERMINE,PETSC_DETERMINE)); PetscCall(MatSetType(A, MATMPIAIJ)); PetscCall(MatSetUp(A)); PetscCall(MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY)); PetscCall(MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY)); PetscCall(MatView(A,PETSC_VIEWER_STDOUT_WORLD)); PetscCall(PetscFinalize()); return 0; }