Destroys objects/pointers and clears data.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
impure subroutine hypre_obj_Final(this) !> Destroys objects/pointers and clears data. use leapCuda implicit none class(hypre_obj), intent(inout) :: this !! Hypre machinery ! Work variables integer :: ierr #ifdef USE_GPU integer :: stat #endif ! Nullify pointers this%parallel => null() this%block => null() if (allocated(this%solver_name)) then select case (this%interface) case (HYPRE_INT_Struct) call HYPRE_StructVectorDestroy (this%rhs, ierr) call HYPRE_StructVectorDestroy (this%sol, ierr) call HYPRE_StructMatrixDestroy (this%matrix, ierr) call HYPRE_StructStencilDestroy(this%stencil,ierr) call HYPRE_StructGridDestroy (this%grid, ierr) select case (this%solver_name) case (HYPRE_SOL_S_PCG_NONE) call HYPRE_StructPCGDestroy (this%solver, ierr) case (HYPRE_SOL_S_SMG_NONE) call HYPRE_StructSMGDestroy (this%solver, ierr) case (HYPRE_SOL_S_PFMG_NONE) call HYPRE_StructPFMGDestroy (this%solver, ierr) case default call this%parallel%Stop("HYPRE: Unknown solver") end select case (HYPRE_INT_SStruct) ! Not yet implemented case (HYPRE_INT_IJ) call this%irow%Finalize call HYPRE_IJVectorDestroy (this%rhs, ierr) call HYPRE_IJVectorDestroy (this%sol, ierr) call HYPRE_IJMatrixDestroy (this%matrix, ierr) select case (this%solver_name) case (HYPRE_SOL_IJ_AMG_NONE) call HYPRE_BoomerAMGDestroy (this%solver, ierr) case (HYPRE_SOL_IJ_PCG_DS) call HYPRE_ParCSRPCGDestroy (this%solver, ierr) case (HYPRE_SOL_IJ_PCG_AMG) call HYPRE_BoomerAMGDestroy (this%precond,ierr) call HYPRE_ParCSRPCGDestroy (this%solver, ierr) case default call this%parallel%Stop("HYPRE: Unknown solver") end select #ifdef USE_GPU ! Clean up -- GPU variables stat = device_free(this%p_rhs_values) stat = device_free(this%p_sol_values) stat = device_free(this%p_rows) stat = device_free(this%p_cols) stat = device_free(this%p_tmpi) stat = device_free(this%p_values) #else deallocate(this%rhs_values) deallocate(this%sol_values) deallocate(this%values) deallocate(this%rows) deallocate(this%cols) deallocate(this%tmpi) #endif case default call this%parallel%Stop("Unknown or uninitialized HYPRE interface") end select deallocate(this%solver_name) end if return end subroutine hypre_obj_Final