ESMF_XGridGeomBaseGetArrayInfo Subroutine

public subroutine ESMF_XGridGeomBaseGetArrayInfo(gridbase, gridToFieldMap, ungriddedLBound, ungriddedUBound, distgrid, distgridToArrayMap, undistLBound, undistUBound, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_XGridGeomBase), intent(in) :: gridbase
integer, intent(in), optional :: gridToFieldMap(:)
integer, intent(in), optional :: ungriddedLBound(:)
integer, intent(in), optional :: ungriddedUBound(:)
type(ESMF_DistGrid), intent(out), optional :: distgrid
integer, intent(out) :: distgridToArrayMap(:)
integer, intent(out) :: undistLBound(:)
integer, intent(out) :: undistUBound(:)
integer, intent(out), optional :: rc

Source Code

      subroutine ESMF_XGridGeomBaseGetArrayInfo(gridbase, &
                           gridToFieldMap, ungriddedLBound, ungriddedUBound, &
                           distgrid, distgridToArrayMap, undistLBound, undistUBound,   &
                           rc)
!
! !ARGUMENTS:
       type(ESMF_XGridGeomBase),   intent(in)       :: gridbase
       integer,               intent(in),  optional :: gridToFieldMap(:)
       integer,               intent(in),  optional :: ungriddedLBound(:)
       integer,               intent(in),  optional :: ungriddedUBound(:)
       type(ESMF_DistGrid),   intent(out), optional :: distgrid
       integer,               intent(out)           :: distgridToArrayMap(:)
       integer,               intent(out)           :: undistLBound(:)
       integer,               intent(out)           :: undistUBound(:)
       integer,               intent(out), optional :: rc

!
! !DESCRIPTION:
!
! This subroutine gets information from a GeomBase which is useful in creating an
! Array. This subroutine takes as input {\tt gridToFieldMap} which gives for each
! gridbase object dimension which dimension in the eventual Array it should be
! mapped to. It also takes {\tt ungriddedLBound} and {\tt ungriddedUBound} which
! describes the dimensions of the Array not associated with the gridbase object.
! From these it produces a mapping from the distgrid to the Array, the undistributed
! bounds of the Array in the correct order. (For everything besides {\tt Grid}  the
! gridToFieldMap and distgridToArrayMap will be single element
! arrays describing which dimension in the Array the gridbase object (e.g. Mesh)
! is mapped to.
!
! The arguments are:
! \begin{description}
!\item[{gridbase}]
!     The gridbase to get the information from to create the Array.
!\item[{[distgrid]}]
!     The distgrid to create the Array on
!\item[{[gridToFieldMap]}]
!     Indicates where each grid dimension goes in the newly created Array.
!     {\tt The array gridToFieldMap} should be at least of size equal to the gridbase object's
!     Array dimension (e.g. Mesh = 1)
!     If not set defaults to (1,2,3,....,gridbase objects dim).
!\item[{[ungriddedLBound]}]
!     The lower bounds of the non-grid Array dimensions.
!\item[{[ungriddedUBound]}]
!     The upper bounds of the non-grid array dimensions.
!\item[{distgridToArrayMap}]
!     The distgrid to Array dimension map (must be allocated to at least
!     the number of dimensions of the distGrid).
!\item[{undistLBound}]
!     Undistributed lower bounds (must be of size grid undistDimCount+size(ungriddedUBound))
!\item[{undistUBound}]
!     Undistributed upper bounds (must be of size grid undistDimCount+size(ungriddedUBound))
! \item[{[rc]}]
!      Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOPI
    integer :: localrc
    type(ESMF_XGridGeomBaseClass),pointer :: gbcp

    ! 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, gridbase, rc)

    ! Get GeomBaseClass
    gbcp=>gridbase%gbcp

    ! Get info depending on type
    select case(gbcp%type%type)
     case (ESMF_XGRIDGEOMTYPE_GRID%type) ! Grid
       call ESMF_GridGetArrayInfo(gbcp%grid, gbcp%staggerloc, &
         gridToFieldMap, ungriddedLBound, ungriddedUBound,  &
         distgrid, distgridToArrayMap, undistLBound, undistUBound,       &
         rc=localrc)
       if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return

     case (ESMF_XGRIDGEOMTYPE_MESH%type) ! Mesh
        if (present(gridToFieldMap)) then
          distgridToArrayMap = gridToFieldMap
        else
          distgridToArrayMap = 1
        endif

        if (present(ungriddedLBound)) then
            if (size(ungriddedLBound) .gt. 0) undistLBound = ungriddedLBound
        endif
        if (present(ungriddedUBound)) then
            if (size(ungriddedUBound) .gt. 0) undistUBound = ungriddedUBound
        endif

         ! Distgrid
   if (present(distgrid)) then
    if (gbcp%meshloc == ESMF_MESHLOC_NODE) then
     call ESMF_MeshGet(mesh=gbcp%mesh, &
                       nodalDistgrid=distgrid, &
                        rc=localrc)
     if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return
    else if (gbcp%meshloc == ESMF_MESHLOC_ELEMENT) then
       call ESMF_MeshGet(mesh=gbcp%mesh, &
         elementDistgrid=distgrid, &
          rc=localrc)
       if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return
    else
      if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
         msg=" Bad Mesh Location value", &
         ESMF_CONTEXT, rcToReturn=rc)) return
    endif
   endif



     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  subroutine ESMF_XGridGeomBaseGetArrayInfo