1! 2! This program tests MatCreateVecs() for Shell Matrix 3! 4 subroutine mymatgetvecs(A,x,y,ierr) 5#include <petsc/finclude/petscmat.h> 6 use petscmat 7 implicit none 8 9 PetscErrorCode ierr 10 Mat A 11 Vec x,y 12 PetscInt tw 13 14 tw = 12 15 PetscCallA(VecCreateSeq(PETSC_COMM_SELF,tw,x,ierr)) 16 PetscCallA(VecCreateSeq(PETSC_COMM_SELF,tw,y,ierr)) 17 return 18 end 19 20 program main 21#include <petsc/finclude/petscmat.h> 22 use petscmat 23 implicit none 24 25 PetscErrorCode ierr 26 Vec x,y 27 Mat m 28 PetscInt tw 29 external mymatgetvecs 30 31 PetscCallA(PetscInitialize(ierr)) 32 33 tw = 12 34 PetscCallA(MatCreateShell(PETSC_COMM_SELF,tw,tw,tw,tw,0,m,ierr)) 35 PetscCallA(MatAssemblyBegin(m,MAT_FINAL_ASSEMBLY,ierr)) 36 PetscCallA(MatAssemblyEnd(m,MAT_FINAL_ASSEMBLY,ierr)) 37 PetscCallA(MatShellSetOperation(m,MATOP_CREATE_VECS,mymatgetvecs,ierr)) 38 PetscCallA(MatCreateVecs(m,x,y,ierr)) 39 PetscCallA(MatDestroy(m,ierr)) 40 PetscCallA(VecDestroy(x,ierr)) 41 PetscCallA(VecDestroy(y,ierr)) 42 PetscCallA(PetscFinalize(ierr)) 43 end 44 45!/*TEST 46! 47! test: 48! nsize: 2 49! 50!TEST*/ 51