static char help[] = "Tests MatConvert from AIJ to MATIS.\n"; #include int main(int argc,char **args) { Mat A,B; char file[PETSC_MAX_PATH_LEN]; PetscViewer fd; PetscBool flg; PetscCall(PetscInitialize(&argc,&args,(char*)0,help)); /* Load aij matrix A */ PetscCall(PetscOptionsGetString(NULL,NULL,"-f",file,sizeof(file),&flg)); PetscCheck(flg,PETSC_COMM_WORLD,PETSC_ERR_USER,"Must indicate binary file with the -f option"); PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&fd)); PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatLoad(A,fd)); MatConvert(A,MATIS,MAT_INITIAL_MATRIX,&B); PetscCall(MatDestroy(&A)); PetscCall(MatDestroy(&B)); PetscCall(PetscViewerDestroy(&fd)); PetscCall(PetscFinalize()); }