ESMF_GridGetDefault Subroutine

private subroutine ESMF_GridGetDefault(grid, keywordEnforcer, coordTypeKind, dimCount, tileCount, staggerlocCount, localDECount, distgrid, distgridToGridMap, coordSys, coordDimCount, coordDimMap, arbDim, rank, arbDimCount, gridEdgeLWidth, gridEdgeUWidth, gridAlign, indexflag, status, name, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Grid), intent(in) :: grid
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
type(ESMF_TypeKind_Flag), intent(out), optional :: coordTypeKind
integer, intent(out), optional :: dimCount
integer, intent(out), optional :: tileCount
integer, intent(out), optional :: staggerlocCount
integer, intent(out), optional :: localDECount
type(ESMF_DistGrid), intent(out), optional :: distgrid
integer, intent(out), optional, target :: distgridToGridMap(:)
type(ESMF_CoordSys_Flag), intent(out), optional :: coordSys
integer, intent(out), optional, target :: coordDimCount(:)
integer, intent(out), optional, target :: coordDimMap(:,:)
integer, intent(out), optional :: arbDim
integer, intent(out), optional :: rank
integer, intent(out), optional :: arbDimCount
integer, intent(out), optional, target :: gridEdgeLWidth(:)
integer, intent(out), optional, target :: gridEdgeUWidth(:)
integer, intent(out), optional, target :: gridAlign(:)
type(ESMF_Index_Flag), intent(out), optional :: indexflag
type(ESMF_GridStatus_Flag), intent(out), optional :: status
character(len=*), intent(out), optional :: name
integer, intent(out), optional :: rc

Source Code

      subroutine ESMF_GridGetDefault(grid, keywordEnforcer, coordTypeKind, &
        dimCount, tileCount, staggerlocCount, localDECount, distgrid, &
        distgridToGridMap, coordSys, coordDimCount, coordDimMap, arbDim, &
        rank, arbDimCount, gridEdgeLWidth, gridEdgeUWidth, gridAlign,  &
        indexFlag, status, name, rc)
!
! !ARGUMENTS:
      type(ESMF_Grid),            intent(in)            :: grid
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
      type(ESMF_TypeKind_Flag),  intent(out), optional :: coordTypeKind
      integer,                   intent(out), optional :: dimCount
      integer,                   intent(out), optional :: tileCount
      integer,                   intent(out), optional :: staggerlocCount
      integer,                   intent(out), optional :: localDECount
      type(ESMF_DistGrid),       intent(out), optional :: distgrid
      integer,       target,     intent(out), optional :: distgridToGridMap(:)
      type(ESMF_CoordSys_Flag),  intent(out), optional :: coordSys
      integer,       target,     intent(out), optional :: coordDimCount(:)
      integer,       target,     intent(out), optional :: coordDimMap(:,:)
      integer,                   intent(out), optional :: arbDim
      integer,                   intent(out), optional :: rank
      integer,                   intent(out), optional :: arbDimCount
      integer,       target,     intent(out), optional :: gridEdgeLWidth(:)
      integer,       target,     intent(out), optional :: gridEdgeUWidth(:)
      integer,       target,     intent(out), optional :: gridAlign(:)
      type(ESMF_Index_Flag),     intent(out), optional :: indexflag
      type(ESMF_GridStatus_Flag),intent(out), optional :: status
      character (len=*),         intent(out), optional :: name
      integer,                   intent(out), optional :: rc
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION:
!    Gets various types of information about a grid.
!
!The arguments are:
!\begin{description}
!\item[grid]
!   Grid to get the information from.
!\item[{[coordTypeKind]}]
!   The type/kind of the grid coordinate data. All {\em numerical} types
!   listed under section~\ref{const:typekind} are supported.
!\item[{[dimCount]}]
!   DimCount of the Grid object.
!\item[{[tileCount]}]
!   The number of logically rectangular tiles in the grid.
!\item[{[staggerlocCount]}]
!   The number of stagger locations.
!\item[{[localDECount]}]
!   The number of DEs in this grid on this PET.
!\item[{[distgrid]}]
!   The structure describing the distribution of the grid.
!\item[{[distgridToGridMap]}]
!   List that has as many elements as the distgrid dimCount. This array describes
!   mapping between the grids dimensions and the distgrid.
! \item[{[coordSys]}]
!     The coordinate system of the grid coordinate data.
! \item[{[coordDimCount]}]
!   This argument needs to be of size equal to the Grid's dimCount.
!   Each entry in the argument will be filled with the dimCount of the corresponding coordinate component (e.g. the
!   dimCount of coordDim=1 will be put into entry 1).
!   This is useful because it describes the factorization of the coordinate components in the Grid.
!\item[{[coordDimMap]}]
!   2D list of size grid dimCount x grid dimCount. This array describes the
!   map of each component array's dimensions onto the grids
!   dimensions.
! \item[{[arbDim]}]
!   The distgrid dimension that is mapped by the arbitrarily distributed grid dimensions.
! \item[{[rank]}]
!   The count of the memory dimensions, it is the same as dimCount for a non-arbitrarily distributed grid,
!   and equal or less for a arbitrarily distributed grid.
! \item[{[arbDimCount]}]
!   The number of dimensions distributed arbitrarily for an arbitrary grid, 0 if the grid is non-arbitrary.
! \item[{[gridEdgeLWidth]}]
!   The padding around the lower edges of the grid. The array should
!   be of size greater or equal to the Grid dimCount.
! \item[{[gridEdgeUWidth]}]
!      The padding around the upper edges of the grid. The array should
!   be of size greater or equal to the Grid dimCount.
! \item[{[gridAlign]}]
!     Specification of how the stagger locations should align with the cell
!     index space. The array should be of size greater or equal to the Grid dimCount.
! \item[{[indexflag]}]
!    Flag indicating the indexing scheme being used in the Grid. Please
!    see Section~\ref{const:indexflag} for the list of options.
! \item[{[status]}]
!    Flag indicating the status of the Grid. Please
!    see Section~\ref{const:gridstatus} for the list of options.
!\item[{[name]}]
!   {\tt ESMF\_Grid} name.
!\item[{[rc]}]
!          Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!\end{description}
!
!EOP
    integer :: localrc ! local error status
    type(ESMF_GridDecompType) :: decompType  ! check if arbitrary
    type(ESMF_InterArray) :: distgridToGridMapArg  ! Language Interface Helper Var
    type(ESMF_InterArray) :: coordDimCountArg  ! Language Interface Helper Var
    type(ESMF_InterArray) :: coordDimMapArg ! Language Interface Helper Var
    type(ESMF_InterArray) :: gridEdgeLWidthArg  ! Language Interface Helper Var
    type(ESMF_InterArray) :: gridEdgeUWidthArg  ! Language Interface Helper Var
    type(ESMF_InterArray) :: gridAlignArg  ! Language Interface Helper Var


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

    ! Check init status of arguments
     ESMF_INIT_CHECK_DEEP_SHORT(ESMF_GridGetInit, grid, rc)

    ! Get Grid decomposition type
    call ESMF_GridGetDecompType(grid, decompType, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
        
    if (decompType == ESMF_Grid_NONARBITRARY) then
        if (present(arbDim)) then
         call ESMF_LogSetError(rcToCheck=ESMF_RC_NOT_IMPL, &
                 msg="- arbDim does not exist for a non-arbitrarily distributed grid", &
                 ESMF_CONTEXT, rcToReturn=rc)
         return
        endif
    endif

    ! get name
    if (present(name)) then
       call c_ESMC_GetName(grid, name, localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
    endif

    if (present(coordTypeKind)   .or.  &
         present(dimCount)        .or.  &
         present(tileCount)       .or.  &
         present(staggerlocCount) .or. &
         present(localDECount)    .or. &
         present(distgrid)        .or. &
         present(distgridToGridMap) .or. &
         present(coordDimCount)     .or. &
         present(coordDimMap)       .or. &
         present(coordSys)          .or. &
         present(arbDim)            .or. &
         present(rank)              .or. &
         present(arbDimCount)       .or. &
         present(gridEdgeLWidth)    .or. &
         present(gridEdgeUWidth)    .or. &
         present(gridAlign)         .or. &
         present(indexFlag)) then

       !! coordTypeKind
       ! It doesn't look like it needs to be translated, but test to make sure

       !! distgridToGridMap
       distgridToGridMapArg = ESMF_InterArrayCreate(distgridToGridMap, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

       !! Description of array factorization
       coordDimCountArg = ESMF_InterArrayCreate(coordDimCount, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
       coordDimMapArg = ESMF_InterArrayCreate(farray2D=coordDimMap, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

       !! Grid Boundary Info
       gridEdgeLWidthArg = ESMF_InterArrayCreate(gridEdgeLWidth, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
       gridEdgeUWidthArg = ESMF_InterArrayCreate(gridEdgeUWidth, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
       gridAlignArg = ESMF_InterArrayCreate(gridAlign, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return


       ! Call C++ Subroutine to do the get
       call c_ESMC_gridget(grid%this, &
            coordTypeKind, dimCount, tileCount, distgrid,  staggerlocCount, &
            distgridToGridMapArg, coordSys, coordDimCountArg, arbDim, &
            rank, arbDimCount, coordDimMapArg, &
            gridEdgeLWidthArg, gridEdgeUWidthArg, gridAlignArg, &
            indexflag, localDECount, localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

       ! Deallocate helper variables
       call ESMF_InterArrayDestroy(distgridToGridMapArg, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
       call ESMF_InterArrayDestroy(coordDimCountArg, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
       call ESMF_InterArrayDestroy(coordDimMapArg, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
       call ESMF_InterArrayDestroy(gridEdgeLWidthArg, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
       call ESMF_InterArrayDestroy(gridEdgeUWidthArg, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
       call ESMF_InterArrayDestroy(gridAlignArg, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

       ! Set Deep Classes as created
       if (present(distgrid)) then
          call ESMF_DistGridSetInitCreated(distgrid, rc=localrc)
          if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
               ESMF_CONTEXT, rcToReturn=rc)) return
       endif
    endif


    ! Call C++ Subroutine to get the status
    if (present(status)) then
       call c_ESMC_gridgetstatus(grid%this, status)
    endif

    ! Return successfully
    if (present(rc)) rc = ESMF_SUCCESS

end subroutine ESMF_GridGetDefault