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