ESMF_XGridGeomBaseMatch Function

public function ESMF_XGridGeomBaseMatch(xgb1, xgb2, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_XGridGeomBase), intent(in) :: xgb1
type(ESMF_XGridGeomBase), intent(in) :: xgb2
integer, intent(out), optional :: rc

Return Value logical


Source Code

      function ESMF_XGridGeomBaseMatch(xgb1, xgb2, rc)

      logical :: ESMF_XGridGeomBaseMatch
!
! !ARGUMENTS:
      type(ESMF_XGridGeomBase),   intent(in)       :: xgb1
      type(ESMF_XGridGeomBase),   intent(in)       :: xgb2
      integer,               intent(out), optional :: rc

!
! !DESCRIPTION:
!    Match geometric object
!
!The arguments are:
!\begin{description}
!\item[{xgb1}]
!   first xgrid geombase object
!\item[{xgb2}]
!   second xgrid geombase object
!\item[{[rc]}]
!          Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!\end{description}
!
!EOPI
    type(ESMF_XGridGeomBaseClass),pointer :: gbcp1, gbcp2
    integer                          :: localrc

    ! Initialize return code; assume failure until success is certain
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! Check init status of arguments
    ESMF_INIT_CHECK_DEEP_SHORT(ESMF_XGridGeomBaseGetInit, xgb1, rc)
    ESMF_INIT_CHECK_DEEP_SHORT(ESMF_XGridGeomBaseGetInit, xgb2, rc)

    ! Get GeomBaseClass
    gbcp1=>xgb1%gbcp
    gbcp2=>xgb2%gbcp

    ESMF_XGridGeomBaseMatch = .false.

    if(gbcp1%type%type /= gbcp2%type%type) then
      call ESMF_LogSetError(rcToCheck=ESMF_RC_OBJ_BAD, &
         msg="xgrid geombase object type does not match", &
          ESMF_CONTEXT, rcToReturn=rc)
      return
    endif

    ! Get info depending on type
    select case(gbcp1%type%type)
       case (ESMF_XGRIDGEOMTYPE_GRID%type) ! Grid

         if(ESMF_GridMatch(gbcp1%grid, gbcp2%grid, rc=localrc) >= ESMF_GRIDMATCH_EXACT) &
          ESMF_XGridGeomBaseMatch = .true.
         if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
     msg=" Bad type value", &
     ESMF_CONTEXT, rcToReturn=rc)) return

       case (ESMF_XGRIDGEOMTYPE_MESH%type) ! Mesh
         ESMF_XGridGeomBaseMatch = ESMF_MeshMatch(gbcp1%mesh, gbcp2%mesh, rc=localrc)
         if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
     msg=" Bad type value", &
     ESMF_CONTEXT, rcToReturn=rc)) return

       case default
         if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
     msg=" Bad type value", &
     ESMF_CONTEXT, rcToReturn=rc)) return
    end select


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

end function ESMF_XGridGeomBaseMatch