MAPL_GridGet Subroutine

public subroutine MAPL_GridGet(GRID, globalCellCountPerDim, localCellCountPerDim, layout, RC)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Grid), intent(in) :: GRID
integer, intent(inout), optional :: globalCellCountPerDim(:)
integer, intent(inout), optional :: localCellCountPerDim(:)
integer, intent(inout), optional :: layout(2)
integer, intent(out), optional :: RC

Calls

proc~~mapl_gridget~~CallsGraph proc~mapl_gridget MAPL_GridGet ESMF_AttributeGet ESMF_AttributeGet proc~mapl_gridget->ESMF_AttributeGet ESMF_DistGridGet ESMF_DistGridGet proc~mapl_gridget->ESMF_DistGridGet ESMF_GridGet ESMF_GridGet proc~mapl_gridget->ESMF_GridGet proc~mapl_distgridget MAPL_DistGridGet proc~mapl_gridget->proc~mapl_distgridget proc~mapl_getimsjms MAPL_GetImsJms proc~mapl_gridget->proc~mapl_getimsjms proc~mapl_gridhasde MAPL_GridHasDE proc~mapl_gridget->proc~mapl_gridhasde proc~mapl_return MAPL_Return proc~mapl_gridget->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_gridget->proc~mapl_verify proc~mapl_distgridget->ESMF_DistGridGet proc~mapl_distgridget->proc~mapl_verify proc~mapl_getimsjms->proc~mapl_return proc~mapl_getimsjms->proc~mapl_verify interface~mapl_assert MAPL_Assert proc~mapl_getimsjms->interface~mapl_assert interface~mapl_sort MAPL_Sort proc~mapl_getimsjms->interface~mapl_sort proc~mapl_gridhasde->ESMF_DistGridGet proc~mapl_gridhasde->ESMF_GridGet proc~mapl_gridhasde->proc~mapl_return proc~mapl_gridhasde->proc~mapl_verify ESMF_DELayoutGet ESMF_DELayoutGet proc~mapl_gridhasde->ESMF_DELayoutGet at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception

Called by

AbstractGridFactory%get_basiswMAPL_GridGet
w
create_stretched_cs_gridw
w
ESMFL_field_is_undefinedw
w
ESMFL_FieldGetDimsw
w
ESMFL_GridCoordGetw
w
has_levelw
w
latlon_zmeanw
w
latlon_zstarw
w
MAPL_CFIOCreateFromFilew
w
MAPL_CFIOReadBundleReadw
w
MAPL_CFIOWriteBundlePostw
w
MAPL_CFIOWriteBundleWaitw
w
MAPL_CFIOWriteBundleWritew
w
MAPL_CollectiveGather3Dw
w
MAPL_create_bundle_from_metdata_idw
w
MAPL_ESMFStateReadFromFilew
w
MAPL_GenericFinalizew
w
MAPL_GenericInitializew
w
MAPL_GenericRecordw
w
MAPL_GenericStateSavew
w
MAPL_GridCoordAdjustw
w
MAPL_GriddedIO%check_chunkingw
w
MAPL_GriddedIO%request_data_from_filew
w
MAPL_GriddedIO%set_default_chunkingw
w
MAPL_TileMaskGetw
w
MaplGrid%setw
w
regrid_support%has_levelw
w
StateMask%evaluate_box_maskw
w
test_mainw
w
time_avew
w
verticalData%setup_eta_to_pressurew
w
vertInterpolation_pressKappaw
w

Source Code

  subroutine MAPL_GridGet(GRID, globalCellCountPerDim, localCellCountPerDim, layout, RC)
      type (ESMF_Grid), intent(IN) :: GRID
      integer, optional, intent(INout) :: globalCellCountPerDim(:)
      integer, optional, intent(INout) :: localCellCountPerDim(:)
      integer, optional, intent(inout) :: layout(2)
      integer, optional, intent(  OUT) :: RC

! local vars
      integer :: status

      integer :: mincounts(ESMF_MAXDIM)
      integer :: maxcounts(ESMF_MAXDIM)
      integer :: gridRank
      integer :: UNGRID
      integer :: sz, tileCount, dimCount, deCount
      logical :: plocal, pglobal, lxtradim
      logical :: isPresent,hasDE
      type(ESMF_DistGrid) :: distGrid
      integer, allocatable :: maxindex(:,:),minindex(:,:)
      integer, pointer :: ims(:),jms(:)
      integer, allocatable  :: global_grid_info(:)
      integer :: itemCount

      pglobal = present(globalCellCountPerDim)
      plocal  = present(localCellCountPerDim)

      call ESMF_AttributeGet(grid, name="GLOBAL_GRID_INFO", isPresent=isPresent, _RC)
      if (isPresent) then
        call ESMF_AttributeGet(grid, name="GLOBAL_GRID_INFO", itemCount=itemCount, _RC)
        allocate(global_grid_info(itemCount), _STAT)
        call ESMF_AttributeGet(grid, name="GLOBAL_GRID_INFO", valueList=global_grid_info, _RC)
        if (pglobal) globalCellCountPerDim = global_grid_info(1:3)
        if (plocal)  localCellCountPerDim = global_grid_info(4:6)
        deallocate(global_grid_info, _STAT)
        _RETURN(_SUCCESS)
      end if

      if (pglobal .or. plocal) then
         call ESMF_GridGet(grid, dimCount=gridRank, _RC)

!ALT kludge
         lxtradim = .false.
         if (gridRank == 1) then
            call ESMF_AttributeGet(grid, name='GRID_EXTRADIM', isPresent=isPresent, _RC)
            if (isPresent) then
               call ESMF_AttributeGet(grid, name='GRID_EXTRADIM', value=UNGRID, _RC)
               lxtradim = .true.
            end if
         else if (gridRank == 2) then
            call ESMF_AttributeGet(grid, name='GRID_LM', isPresent=isPresent, _RC)
            if (isPresent) then
               call ESMF_AttributeGet(grid, name='GRID_LM', value=UNGRID, _RC)
               lxtradim = .true.
            end if
         end if
      end if

      if (pglobal) then

         globalCellCountPerDim = 1
         call ESMF_GridGet(grid, tileCount=tileCount,_RC)

         call ESMF_GridGet(grid, tile=1, staggerLoc=ESMF_STAGGERLOC_CENTER, &
              minIndex=mincounts, &
              maxIndex=maxcounts, &
              _RC      )

         sz = min(gridRank, ESMF_MAXDIM, size(globalCellCountPerDim))
         globalCellCountPerDim(1:sz) = maxcounts(1:sz)-mincounts(1:sz)+1

         ! kludge for new cube sphere from ESMF
         if (tileCount == 6) then
            if (globalCellCountPerDim(1) /= 1) then ! kludge-on-the-kludge for Single-Column case
               globalCellCountPerDim(2)=globalCellCountPerDim(2)*6
            end if
         end if

         if (lxtradim ) then
            globalCellCountPerDim(gridRank+1) = UNGRID
         end if
      end if

      if (plocal) then
         localCellCountPerDim = 1

         HasDE = MAPL_GridHasDE(grid,_RC)
         if (HasDE) then
            call ESMF_GridGet(GRID, localDE=0, &
                 staggerloc=ESMF_STAGGERLOC_CENTER, &
                 exclusiveCount=localCellCountPerDim, _RC)
         end if

         if (lxtradim ) then
            localCellCountPerDim(gridRank+1) = UNGRID
         end if
      end if

      if (present(layout)) then
         call ESMF_GridGet(grid,distgrid=distgrid,dimCount=dimCount,_RC)
         call ESMF_DistGridGet(distgrid,deCount=deCount,_RC)
         allocate(minindex(dimCount,decount),maxindex(dimCount,decount))

         call MAPL_DistGridGet(distgrid, &
            minIndex=minindex, &
            maxIndex=maxindex, _RC)
         nullify(ims,jms)
         call MAPL_GetImsJms(Imins=minindex(1,:),Imaxs=maxindex(1,:),&
           Jmins=minindex(2,:),Jmaxs=maxindex(2,:),Ims=ims,Jms=jms,_RC)

         layout(1) = size(ims)
         layout(2) = size(jms)
         deallocate(ims,jms)
      end if

      _RETURN(ESMF_SUCCESS)

    end subroutine MAPL_GridGet