hypre_obj_Final Subroutine

private impure subroutine hypre_obj_Final(this)

Uses

  • proc~~hypre_obj_final~~UsesGraph proc~hypre_obj_final hypre_obj%hypre_obj_Final module~leapcuda leapCuda proc~hypre_obj_final->module~leapcuda iso_c_binding iso_c_binding module~leapcuda->iso_c_binding iso_fortran_env iso_fortran_env module~leapcuda->iso_fortran_env

Destroys objects/pointers and clears data.

Type Bound

hypre_obj

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery


Calls

proc~~hypre_obj_final~~CallsGraph proc~hypre_obj_final hypre_obj%hypre_obj_Final hypre_boomeramgdestroy hypre_boomeramgdestroy proc~hypre_obj_final->hypre_boomeramgdestroy hypre_ijmatrixdestroy hypre_ijmatrixdestroy proc~hypre_obj_final->hypre_ijmatrixdestroy hypre_ijvectordestroy hypre_ijvectordestroy proc~hypre_obj_final->hypre_ijvectordestroy hypre_parcsrpcgdestroy hypre_parcsrpcgdestroy proc~hypre_obj_final->hypre_parcsrpcgdestroy hypre_structgriddestroy hypre_structgriddestroy proc~hypre_obj_final->hypre_structgriddestroy hypre_structmatrixdestroy hypre_structmatrixdestroy proc~hypre_obj_final->hypre_structmatrixdestroy hypre_structpcgdestroy hypre_structpcgdestroy proc~hypre_obj_final->hypre_structpcgdestroy hypre_structpfmgdestroy hypre_structpfmgdestroy proc~hypre_obj_final->hypre_structpfmgdestroy hypre_structsmgdestroy hypre_structsmgdestroy proc~hypre_obj_final->hypre_structsmgdestroy hypre_structstencildestroy hypre_structstencildestroy proc~hypre_obj_final->hypre_structstencildestroy hypre_structvectordestroy hypre_structvectordestroy proc~hypre_obj_final->hypre_structvectordestroy proc~device_free device_free proc~hypre_obj_final->proc~device_free proc~eulerian_obj_final eulerian_obj_base%eulerian_obj_Final proc~hypre_obj_final->proc~eulerian_obj_final interface~cudafree cudaFree proc~device_free->interface~cudafree

Source Code

    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