ESMF_SciCompDestroy Subroutine

public subroutine ESMF_SciCompDestroy(scicomp, keywordEnforcer, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_SciComp), intent(inout) :: scicomp
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_SciCompDestroy(scicomp, keywordEnforcer, rc)
!
! !ARGUMENTS:
    type(ESMF_SciComp), intent(inout)           :: scicomp
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    integer,             intent(out),  optional :: rc
!
! !DESCRIPTION:
! Destroys an {\tt ESMF\_SciComp}, releasing the resources associated
! with the object.
!
! The arguments are:
! \begin{description}
! \item[scicomp]
!   Release all resources associated with this {\tt ESMF\_SciComp}
!   and mark the object as invalid.  It is an error to pass this
!   object into any other routines after being destroyed.
! \item[{[rc]}]
!   Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
!------------------------------------------------------------------------------
    integer :: localrc                       ! local error status

    ! initialize return code; assume routine not implemented
    if (present(rc)) rc = ESMF_RC_NOT_IMPL
    localrc = ESMF_RC_NOT_IMPL

    ESMF_INIT_CHECK_DEEP(ESMF_SciCompGetInit,scicomp,rc)

    ! Check to see if already destroyed
    if (.not.associated(scicomp%compp)) then
      if (ESMF_LogFoundError(ESMF_RC_OBJ_BAD, &
        msg="SciComp not initialized or already destroyed", &
        ESMF_CONTEXT, rcTOReturn=rc)) return
    endif

    ! call Comp method
    call ESMF_CompDestruct(scicomp%compp, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcTOReturn=rc)) return

    ! mark object invalid
    call ESMF_BaseSetStatus(scicomp%compp%base, ESMF_STATUS_INVALID, &
      rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcTOReturn=rc)) return

    ESMF_INIT_SET_DELETED(scicomp)

    ! return successfully
    if (present(rc)) rc = ESMF_SUCCESS

  end subroutine ESMF_SciCompDestroy