ESMF_GeomMatch Function

public function ESMF_GeomMatch(geom1, geom2, keywordEnforcer, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Geom), intent(in) :: geom1
type(ESMF_Geom), intent(in) :: geom2
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(out), optional :: rc

Return Value type(ESMF_GeomMatch_Flag)


Calls

proc~~esmf_geommatch~~CallsGraph proc~esmf_geommatch ESMF_GeomMatch proc~esmf_geomgetinit ESMF_GeomGetInit proc~esmf_geommatch->proc~esmf_geomgetinit proc~esmf_imerr ESMF_IMErr proc~esmf_geommatch->proc~esmf_imerr proc~esmf_initcheckdeep ESMF_InitCheckDeep proc~esmf_imerr->proc~esmf_initcheckdeep proc~esmf_logfounderror ESMF_LogFoundError proc~esmf_imerr->proc~esmf_logfounderror 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

Called by

proc~~esmf_geommatch~~CalledByGraph proc~esmf_geommatch ESMF_GeomMatch program~esmf_geomutest ESMF_GeomUTest program~esmf_geomutest->proc~esmf_geommatch

Source Code

  function ESMF_GeomMatch(geom1, geom2, keywordEnforcer, rc)
!
! !RETURN VALUE:
    type(ESMF_GeomMatch_Flag) :: ESMF_GeomMatch

! !ARGUMENTS:
    type(ESMF_Geom),  intent(in)              :: geom1
    type(ESMF_Geom),  intent(in)              :: geom2
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    integer,          intent(out),  optional  :: rc
!
!
! !DESCRIPTION:
!  Check if {\tt geom1} and {\tt geom2} match. Returns a range of values of type
!  ESMF\_GeomMatch indicating how closely the Geoms match. For a description of
!  the possible return values, please see~\ref{const:geommatch}.
!  Please also note that by default this call is not collective and only
!  returns the match for the piece of the Geoms on the local PET. In this case,
!  it is possible for this call to return a different match on different PETs
!  for the same Geoms. 
!
!     The arguments are:
!     \begin{description}
!     \item[geom1]
!          {\tt ESMF\_Geom} object.
!     \item[geom2]
!          {\tt ESMF\_Geom} object.
!     \item[{[rc]}]
!          Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!
!EOP
!------------------------------------------------------------------------------
    integer      :: localrc      ! local return code
    integer      :: matchResult
    integer(ESMF_KIND_I4) :: localResult(1), globalResult(1)
    logical      :: l_global
    integer      :: npet
    type(ESMF_VM) ::  vm
    type(ESMF_GeomType_Flag) :: type
    
    ! initialize return code; assume routine not implemented
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! init to one setting in case of error
    ESMF_GeomMatch = ESMF_GEOMMATCH_INVALID

    ! Check init status of arguments
    ESMF_INIT_CHECK_DEEP(ESMF_GeomGetInit, geom1, rc)
    ESMF_INIT_CHECK_DEEP(ESMF_GeomGetInit, geom2, rc)

    ! Check for Alias
    if (geom1 == geom2) then
       ESMF_GeomMatch=ESMF_GEOMMATCH_ALIAS
    endif

    ! If not alias, check for geom alias
    if (ESMF_GeomMatch == ESMF_GEOMMATCH_INVALID) then

       ! If types not equal, not geom alias
       type = geom1%gbcp%type
       if (type == geom2%gbcp%type) then

          if (type == ESMF_GEOMTYPE_GRID) then
             if (geom1%gbcp%grid == geom2%gbcp%grid) ESMF_GeomMatch=ESMF_GEOMMATCH_GEOMALIAS
          else if (type == ESMF_GEOMTYPE_MESH) then
             if (geom1%gbcp%mesh == geom2%gbcp%mesh) ESMF_GeomMatch=ESMF_GEOMMATCH_GEOMALIAS
          else if (type == ESMF_GEOMTYPE_LOCSTREAM) then
             if (geom1%gbcp%locstream == geom2%gbcp%locstream) ESMF_GeomMatch=ESMF_GEOMMATCH_GEOMALIAS
          else if (type == ESMF_GEOMTYPE_XGRID) then
             if (geom1%gbcp%xgrid == geom2%gbcp%xgrid) ESMF_GeomMatch=ESMF_GEOMMATCH_GEOMALIAS
          endif
       endif          
    endif

    ! If we're still invalid, then nothing has matched, so set to none
   if (ESMF_GeomMatch == ESMF_GEOMMATCH_INVALID) ESMF_GeomMatch=ESMF_GEOMMATCH_NONE
        
    ! Take this out for now, because it's not clear how the handle different kinds
    ! of matching.
#if 0    
    ! Check global result
    l_global = .false.
    if(present(globalflag)) l_global = globalflag

    if(l_global) then
      call ESMF_VMGetCurrent(vm, rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
      call ESMF_VMGet(vm, petCount=npet, rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return

      localResult(1) = matchResult
      globalResult(1) = 0
      call ESMF_VMAllReduce(vm, localResult, globalResult, &
        1, ESMF_REDUCE_SUM, rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return

      if(globalResult(1) == npet) then
        ESMF_GridMatch = ESMF_GRIDMATCH_EXACT
      else
        ESMF_GridMatch = ESMF_GRIDMATCH_NONE
      endif
    endif
#endif
    
    ! return successfully
    if (present(rc)) rc = ESMF_SUCCESS

  end function ESMF_GeomMatch