[petsc-users] MatSetOption bug?

Anton Popov popov at uni-mainz.de
Tue Jun 19 11:06:52 CDT 2012


Hi petsc team!
I've recently upgraded to 3.3, and currently experience problems. One of 
them follows.
If I compile this simple code:

#include "petsc.h"
#undef __FUNCT__
#define __FUNCT__ "main"
int main( int argc,char **argv )
{
     Mat A;
     PetscErrorCode ierr;
     PetscInt n_rows_Local=100;
     PetscInt n_cols_Local=100;
     ierr = PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL); 
CHKERRQ(ierr);
     ierr = MatCreate(PETSC_COMM_WORLD, &A); CHKERRQ(ierr);
     ierr = MatSetSizes(A, n_rows_Local, n_cols_Local, PETSC_DETERMINE, 
PETSC_DETERMINE); CHKERRQ(ierr);
     ierr = MatSetType(A, MATAIJ); CHKERRQ(ierr);
     ierr = MatSetOption(A, MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE); 
CHKERRQ(ierr);
     ierr = PetscFinalize(); CHKERRQ(ierr);
     PetscFunctionReturn(0);
}

and run it in parallel (mpiexec -np 2 ./example) it gives me errors like 
this:

[0]PETSC ERROR: --------------------- Error Message 
------------------------------------
[0]PETSC ERROR: Null argument, when expecting valid pointer!
[0]PETSC ERROR: Null Object: Parameter # 1!
[0]PETSC ERROR: 
------------------------------------------------------------------------

Commenting the line with "MatSetOption" removes the error, but doesn't 
solve the problem, because I actually need to KEEP_NONZERO_PATTERN

Running the code sequentially, also vanishes the error.

Please check whether it's a bug in petsc-3.3, or I should set this 
option in a different way.

Thanks,

Anton Popov


More information about the petsc-users mailing list