ESMF_MeshDestroy Subroutine

public subroutine ESMF_MeshDestroy(mesh, keywordEnforcer, noGarbage, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Mesh), intent(inout) :: mesh
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
logical, intent(in), optional :: noGarbage
integer, intent(out), optional :: rc

Calls

proc~~esmf_meshdestroy~~CallsGraph proc~esmf_meshdestroy ESMF_MeshDestroy c_esmc_basesetstatus c_esmc_basesetstatus proc~esmf_meshdestroy->c_esmc_basesetstatus c_esmc_meshdestroy c_esmc_meshdestroy proc~esmf_meshdestroy->c_esmc_meshdestroy c_esmc_meshgetisfree c_esmc_meshgetisfree proc~esmf_meshdestroy->c_esmc_meshgetisfree proc~esmf_imerr ESMF_IMErr proc~esmf_meshdestroy->proc~esmf_imerr proc~esmf_logfounderror ESMF_LogFoundError proc~esmf_meshdestroy->proc~esmf_logfounderror proc~esmf_meshgetinit ESMF_MeshGetInit proc~esmf_meshdestroy->proc~esmf_meshgetinit proc~esmf_imerr->proc~esmf_logfounderror proc~esmf_initcheckdeep ESMF_InitCheckDeep proc~esmf_imerr->proc~esmf_initcheckdeep esmf_breakpoint esmf_breakpoint proc~esmf_logfounderror->esmf_breakpoint proc~esmf_logrc2msg ESMF_LogRc2Msg proc~esmf_logfounderror->proc~esmf_logrc2msg proc~esmf_logwrite ESMF_LogWrite proc~esmf_logfounderror->proc~esmf_logwrite c_esmc_loggeterrormsg c_esmc_loggeterrormsg proc~esmf_logrc2msg->c_esmc_loggeterrormsg c_esmc_vmwtime c_esmc_vmwtime proc~esmf_logwrite->c_esmc_vmwtime proc~esmf_logclose ESMF_LogClose proc~esmf_logwrite->proc~esmf_logclose proc~esmf_logflush ESMF_LogFlush proc~esmf_logwrite->proc~esmf_logflush proc~esmf_logopenfile ESMF_LogOpenFile proc~esmf_logwrite->proc~esmf_logopenfile proc~esmf_utiliounitflush ESMF_UtilIOUnitFlush proc~esmf_logwrite->proc~esmf_utiliounitflush proc~esmf_utilstring2array ESMF_UtilString2Array proc~esmf_logwrite->proc~esmf_utilstring2array proc~esmf_logclose->proc~esmf_logflush proc~esmf_logflush->proc~esmf_utiliounitflush proc~esmf_utilarray2string ESMF_UtilArray2String proc~esmf_logflush->proc~esmf_utilarray2string proc~esmf_logopenfile->proc~esmf_utiliounitflush proc~esmf_utiliounitget ESMF_UtilIOUnitGet proc~esmf_logopenfile->proc~esmf_utiliounitget

Called by

b_or_p_GridToMeshwESMF_MeshDestroy
w
check_coordSys_convert_EM_filew
w
check_mesh_from_cart_3x3_EM_filew
w
check_mesh_from_sph_3D_EM_filew
w
check_mesh_from_sph_3D_UG_filew
w
check_mesh_from_sph_3x3_EM_filew
w
check_mesh_from_sph_3x3_SC_filew
w
check_mesh_from_sph_3x3_UG_filew
w
check_mesh_from_sph_pb_EM_filew
w
check_mesh_from_sph_pb_si_EM_filew
w
check_mesh_from_sph_pb_UG_filew
w
check_mesh_node_redist_from_filew
w
check_mesh_sph_1DeC_EM_filew
w
ESMF_FieldBundleCreateExw
w
ESMF_FieldCreateExw
w
ESMF_FieldDestructGeomw
w
ESMF_FieldRegridGetAreaw
w
ESMF_FieldRegridGetIwtsw
w
ESMF_FieldRegridStoreNXw
w
ESMF_FieldRegridStoreXw
w
ESMF_LocStreamCreateByBkgGridw
w
ESMF_LocStreamCreateUTestw
w
ESMF_MeshCreateFromFileOldw
w
ESMF_MeshExw
w
ESMF_MeshExw
w
ESMF_MeshUTestw
w
ESMF_XGridCreatew
w
ESMF_XGridDestroyw
w
exhaustiveMeshDualTestw
w
FieldRedistExw
w
finalw
w
InitializeIPDv05p5w
w
test3w
w
test8w
w
test_1_width_DE_GtoMw
w
test_bilinear_regrid_csmeshw
w
test_CartMeshToMesh_2ndw
w
test_conserve_regrid_csmeshw
w
test_create_dual_from_filew
w
test_DTOS_3DCartMeshToMeshw
w
test_ignoreDegeneratew
w
test_localglobalboundsmeshw
w
test_mesh_create_from_med_EM_filew
w
test_mesh_create_gt_1localdew
w
test_mesh_dual_w_bilinearw
w
test_mesh_extrap_creepw
w
test_mesh_get_create_infow
w
test_MeshEasyElemsw
w
test_meshindexw
w
test_meshset_with_gt4sidedw
w
test_MeshToMeshw
w
test_MeshToMesh_2ndw
w
test_MeshToMeshCartw
w
test_MeshToMeshWMasksw
w
test_MOAB_GtoMw
w
test_nearest_regrid_csmeshw
w
test_overlap_errorw
w
test_patch_regrid_csmeshw
w
test_PatchMeshToLocStreamMaskw
w
test_PerLocStatusw
w
test_pointlist_from_mesh_elems_nomaskw
w
test_pointlist_from_mesh_elems_wmaskw
w
test_pointlist_from_mesh_nodes_nomaskw
w
test_pointlist_from_mesh_nodes_nomask_empty_procw
w
test_pointlist_from_mesh_nodes_wmaskw
w
test_regrid2xg_onlinew
w
test_regrid2xgSphw
w
test_regrid3DCartMeshToMeshw
w
test_regrid_w_gtomw
w
test_RegridCart4ConcaveMeshw
w
test_RegridCart4ConcaveMeshw
w
test_regridCollapsedQuadsw
w
test_RegridCsrv3DCartMeshw
w
test_RegridCsrvCartMeshw
w
test_RegridCsrvCartMultiPolyw
w
test_RegridCsrvCartPHFracNormw
w
test_RegridCsrvCartPHMeshw
w
test_regridDisjointw
w
test_regridDisjointSDw
w
test_regridGridToGMLw
w
test_regridGridToMeshw
w
test_regridMeshSph3x3ToGridw
w
test_regridMeshToGridw
w
test_regridMeshToGrid3Dw
w
test_regridMeshToGridSph3Dw
w
test_regridMeshToLocStreamMaskw
w
test_regridMeshToMeshw
w
test_regridMeshToMeshCenterw
w
test_regridMeshToMeshMaskw
w
test_regridMeshToMeshPatchw
w
test_regridMeshToMeshPHw
w
test_regridNearestDTOSMeshToMeshw
w
test_regridNearestLocStream_wClusterToMeshw
w
test_regridNearestMeshToMeshw
w
test_regridPerLocStatusw
w
test_regridPerLocStatusw
w
test_regridPerLocStatusExtrapw
w
test_regridPerLocStatusNSToDw
w
test_regridPHMeshToGridw
w
test_RegridSph4ConcaveMeshw
w
test_RegridSph4ConcaveMeshw
w
test_regridTetMeshToGrid3Dw
w
test_SmallNumNbrsw
w
test_STOD_3DCartMeshToMeshw
w
test_xgrid_w_ngon_meshw
w
user_finalw
w
user_finalw
w

Source Code

      subroutine ESMF_MeshDestroy(mesh, keywordEnforcer, noGarbage, rc)
!
! !RETURN VALUE:
!
! !ARGUMENTS:
    type(ESMF_Mesh), intent(inout)          :: mesh
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    logical,         intent(in),   optional :: noGarbage
    integer,         intent(out),  optional :: rc
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \item\apiStatusModifiedSinceVersion{5.2.0r}
! \begin{description}
! \item[8.1.0] Added argument {\tt noGarbage}.
!   The argument provides a mechanism to override the default garbage collection
!   mechanism when destroying an ESMF object.
! \end{description}
! \end{itemize}
!
! !DESCRIPTION:
!  This call removes internal memory associated with {\tt mesh}.
!  After this call {\tt mesh} will no longer be usable.
 !
 ! The arguments are:
! \begin{description}
! \item [mesh]
! Mesh object to be destroyed.
! \item[{[noGarbage]}]
!      If set to {\tt .TRUE.} the object will be fully destroyed and removed
!      from the ESMF garbage collection system. Note however that under this 
!      condition ESMF cannot protect against accessing the destroyed object 
!      through dangling aliases -- a situation which may lead to hard to debug 
!      application crashes.
! 
!      It is generally recommended to leave the {\tt noGarbage} argument
!      set to {\tt .FALSE.} (the default), and to take advantage of the ESMF 
!      garbage collection system which will prevent problems with dangling
!      aliases or incorrect sequences of destroy calls. However this level of
!      support requires that a small remnant of the object is kept in memory
!      past the destroy call. This can lead to an unexpected increase in memory
!      consumption over the course of execution in applications that use 
!      temporary ESMF objects. For situations where the repeated creation and 
!      destruction of temporary objects leads to memory issues, it is 
!      recommended to call with {\tt noGarbage} set to {\tt .TRUE.}, fully 
!      removing the entire temporary object from memory.
! \item [{[rc]}]
!         Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
      integer :: localrc
      type(ESMF_Logical) :: isfree
      type(ESMF_MeshStatus_Flag) :: status
      type(ESMF_Logical) :: opt_noGarbage
      logical  :: isCreated

      ESMF_INIT_CHECK_DEEP(ESMF_MeshGetInit, mesh, rc)

      ! Set default flags
      opt_noGarbage = ESMF_FALSE
      if (present(noGarbage)) opt_noGarbage = noGarbage

#if 0
  block 
    character(80):: msg
    call C_ESMC_MeshGetIsFree(mesh, isfree)
    write(msg,*) "Entering ESMF_MeshDestroy with isfree=", isfree
    call ESMF_PointerLog(mesh%this, prefix=msg, logMsgFlag=ESMF_LOGMSG_DEBUG, rc=rc)
  end block
#endif

      call C_ESMC_MeshGetIsFree(mesh, isfree)
      if (isfree == ESMF_FALSE) then
        ! This will also set the Base Status to INVALID
        call C_ESMC_MeshDestroy(mesh%this, opt_noGarbage, localrc)
        if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
             ESMF_CONTEXT, rcToReturn=rc)) return
      else
        ! Even when there is no CMesh part, there is a Base, and it needs to
        ! be set to INVALID for correct garbage collection behavior
        call c_ESMC_BaseSetStatus(mesh, ESMF_STATUS_INVALID, localrc)
        if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return
      endif

      ! Mark as deleted
      ESMF_INIT_SET_DELETED(mesh)

      ! Set return code
      if (present(rc)) rc=ESMF_SUCCESS

    end subroutine ESMF_MeshDestroy