From 4e0a8dcdb4e925a42734735cdc27fb8b30ca9557 Mon Sep 17 00:00:00 2001 From: mjr-deltares Date: Tue, 26 Sep 2023 12:41:13 +0200 Subject: [PATCH] fix deallocation of PC context --- src/Solution/PETSc/PetscImsPreconditioner.F90 | 6 ------ src/Solution/PETSc/PetscSolver.F90 | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Solution/PETSc/PetscImsPreconditioner.F90 b/src/Solution/PETSc/PetscImsPreconditioner.F90 index ac032c3646f..c5f834ad440 100644 --- a/src/Solution/PETSc/PetscImsPreconditioner.F90 +++ b/src/Solution/PETSc/PetscImsPreconditioner.F90 @@ -74,12 +74,6 @@ subroutine pcshell_destroy(pc, ierr) PC :: pc !< the shell preconditioner PetscErrorCode :: ierr !< PETSc error code ! local - type(PcShellCtxType), pointer :: pc_ctx => null() - - call PCShellGetContext(pc, pc_ctx, ierr) - CHKERRQ(ierr) - call VecDestroy(pc_ctx%diag, ierr) - CHKERRQ(ierr) end subroutine pcshell_destroy diff --git a/src/Solution/PETSc/PetscSolver.F90 b/src/Solution/PETSc/PetscSolver.F90 index f01e94badef..c110af15282 100644 --- a/src/Solution/PETSc/PetscSolver.F90 +++ b/src/Solution/PETSc/PetscSolver.F90 @@ -423,7 +423,9 @@ subroutine petsc_destroy(this) CHKERRQ(ierr) deallocate (this%petsc_ctx) - allocate (this%pc_context) + call VecDestroy(this%pc_context%diag, ierr) + CHKERRQ(ierr) + deallocate (this%pc_context) end subroutine petsc_destroy