H.2.2 Finalize_Ortho_Diffusion Procedure

The main documentation of the Finalize_Ortho_Diffusion Procedure contains additional explanation of this code listing.

  subroutine Finalize_Ortho_Diffusion (Diff_Term, status)

    ! Use associations.

    use Caesar_Flags_Module, only: uninitialized_flag

    ! Input/Output variable.

    ! Diff_Term to be finalized.
    type(Ortho_Diffusion_type), intent(inout) :: Diff_Term  

    ! Output variables.

    type(Status_type), intent(out), optional :: status   ! Exit status.

    ! Internal variables.

    type(Status_type), dimension(9) :: deallocate_status ! Deallocation Status.
    type(Status_type) :: consolidated_status             ! Consolidated Status.

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ! Verify requirements.

    VERIFY(Valid_State(Diff_Term),7) ! Diff_Term is valid.

    ! Unset initialization flag.

    Diff_Term%Initialized = uninitialized_flag

    ! Deallocations and finalizations.

    ! Set deallocation status.

    call Initialize (deallocate_status)
    call Initialize (consolidated_status)

    ! Finalize internals.

    NULLIFY(Diff_Term%Mesh)
    NULLIFY(Diff_Term%Structure)
    call Finalize (Diff_Term%Boundary_Condition, deallocate_status(1))
    call Finalize (Diff_Term%Coefficient,        deallocate_status(2))
    call Finalize (Diff_Term%Locus,              deallocate_status(3))
    call Finalize (Diff_Term%Name,               deallocate_status(4))
    call Finalize (Diff_Term%Extrapolation,      deallocate_status(5))
    call Finalize (Diff_Term%Phi,                deallocate_status(6))
    call Finalize (Diff_Term%Phi_BC,             deallocate_status(7))
    call Finalize (Diff_Term%Equation,           deallocate_status(8))
    call Finalize (Diff_Term%NEquations,         deallocate_status(9))

    ! Process status variables.

    consolidated_status = deallocate_status
    if (PRESENT(status)) then
      WARN_IF(Error(consolidated_status), 5)
      status = consolidated_status
    else
      VERIFY(Normal(consolidated_status), 5)
    end if
    call Finalize (consolidated_status)
    call Finalize (deallocate_status)

    ! Verify guarantees.

    VERIFY(.not.Valid_State(Diff_Term),7) ! Diff_Term is not valid.

    return
  end subroutine Finalize_Ortho_Diffusion



Michael L. Hall