Actual source code: ex120f.F90
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
9: PetscErrorCode ierr
10: Mat A
11: Vec x,y
12: PetscInt tw
14: tw = 12
15: PetscCallA(VecCreateSeq(PETSC_COMM_SELF,tw,x,ierr))
16: PetscCallA(VecCreateSeq(PETSC_COMM_SELF,tw,y,ierr))
17: end
19: program main
20: #include <petsc/finclude/petscmat.h>
21: use petscmat
22: implicit none
24: PetscErrorCode ierr
25: Vec x,y
26: Mat m
27: PetscInt tw
28: external mymatgetvecs
30: PetscCallA(PetscInitialize(ierr))
32: tw = 12
33: PetscCallA(MatCreateShell(PETSC_COMM_SELF,tw,tw,tw,tw,0,m,ierr))
34: PetscCallA(MatAssemblyBegin(m,MAT_FINAL_ASSEMBLY,ierr))
35: PetscCallA(MatAssemblyEnd(m,MAT_FINAL_ASSEMBLY,ierr))
36: PetscCallA(MatShellSetOperation(m,MATOP_CREATE_VECS,mymatgetvecs,ierr))
37: PetscCallA(MatCreateVecs(m,x,y,ierr))
38: PetscCallA(MatDestroy(m,ierr))
39: PetscCallA(VecDestroy(x,ierr))
40: PetscCallA(VecDestroy(y,ierr))
41: PetscCallA(PetscFinalize(ierr))
42: end
44: !/*TEST
45: !
46: ! test:
47: ! nsize: 2
48: !
49: !TEST*/