ESMF_MeshFreeMemory Subroutine

public subroutine ESMF_MeshFreeMemory(mesh, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Mesh), intent(inout) :: mesh
integer, intent(out), optional :: rc

Source Code

      subroutine ESMF_MeshFreeMemory(mesh, rc)
!
! !RETURN VALUE:
!
! !ARGUMENTS:
    type(ESMF_Mesh), intent(inout)        :: mesh
    integer,        intent(out), optional :: rc
!
! !DESCRIPTION:
!    This call removes the portions of {\tt mesh} which contain connection and coordinate
!    information. After this call, Fields build on {\tt mesh} will no longer be usable
!    as part of an {\tt ESMF\_FieldRegridStore()} operation. However, after this call
!    Fields built on {\tt mesh} can still be used in an {\tt ESMF\_FieldRegrid()}
!    operation if the routehandle was generated beforehand. New Fields may also
!    be built on {\tt mesh} after this call.
!
! The arguments are:
! \begin{description}
! \item [mesh]
! Mesh object whose memory is to be freed.
! \item [{[rc]}]
!         Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
      integer  :: localrc
      type(ESMF_Logical) :: isfree
      
      ESMF_INIT_CHECK_DEEP(ESMF_MeshGetInit, mesh, rc)

      ! If already free, fine just return
      call C_ESMC_MeshGetIsFree(mesh, isfree)
      if (isfree == ESMF_TRUE) then
        if (present (rc)) rc = ESMF_SUCCESS
        return
      endif

      ! Free internal C++ mesh
      call C_ESMC_MeshFreeMemory(mesh,localrc)

      ! Set Freed status
      call C_ESMC_MeshSetIsFree(mesh)

      if (present (rc)) rc = localrc

    end subroutine ESMF_MeshFreeMemory