1! 2! This program tests MatCreateVecs() for Shell Matrix 3! 4#include <petsc/finclude/petscmat.h> 5 subroutine mymatgetvecs(A, x, y, ierr) 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 use petscmat 21 implicit none 22 23 PetscErrorCode ierr 24 Vec x, y 25 Mat m 26 PetscInt tw 27 external mymatgetvecs 28 29 PetscCallA(PetscInitialize(ierr)) 30 31 tw = 12 32 PetscCallA(MatCreateShell(PETSC_COMM_SELF, tw, tw, tw, tw, 0, m, ierr)) 33 PetscCallA(MatAssemblyBegin(m, MAT_FINAL_ASSEMBLY, ierr)) 34 PetscCallA(MatAssemblyEnd(m, MAT_FINAL_ASSEMBLY, ierr)) 35 PetscCallA(MatShellSetOperation(m, MATOP_CREATE_VECS, mymatgetvecs, ierr)) 36 PetscCallA(MatCreateVecs(m, x, y, ierr)) 37 PetscCallA(MatDestroy(m, ierr)) 38 PetscCallA(VecDestroy(x, ierr)) 39 PetscCallA(VecDestroy(y, ierr)) 40 PetscCallA(PetscFinalize(ierr)) 41 end 42 43!/*TEST 44! 45! test: 46! nsize: 2 47! output_file: output/empty.out 48! 49!TEST*/ 50