xref: /petsc/src/mat/tests/ex120f.F90 (revision d1a032db6cd7c39db5bfaa476c8e42d0c0ea531b)
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      end
18
19      program main
20#include <petsc/finclude/petscmat.h>
21        use petscmat
22        implicit none
23
24        PetscErrorCode ierr
25        Vec x, y
26        Mat m
27        PetscInt tw
28        external mymatgetvecs
29
30        PetscCallA(PetscInitialize(ierr))
31
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
43
44!/*TEST
45!
46!   test:
47!      nsize: 2
48!      output_file: output/empty.out
49!
50!TEST*/
51