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

proc~~mapl_gridget~~CalledByGraph proc~mapl_gridget MAPL_GridGet none~check_chunking~2 MAPL_GriddedIO%check_chunking none~check_chunking~2->proc~mapl_gridget none~evaluate_box_mask ExtDataMask%evaluate_box_mask none~evaluate_box_mask->proc~mapl_gridget none~get_basis AbstractGridFactory%get_basis none~get_basis->proc~mapl_gridget none~request_data_from_file~2 MAPL_GriddedIO%request_data_from_file none~request_data_from_file~2->proc~mapl_gridget none~set_default_chunking~2 MAPL_GriddedIO%set_default_chunking none~set_default_chunking~2->proc~mapl_gridget none~setup_eta_to_pressure verticalData%setup_eta_to_pressure none~setup_eta_to_pressure->proc~mapl_gridget none~set~92 MaplGrid%set none~set~92->proc~mapl_gridget proc~esmfl_field_is_undefined ESMFL_field_is_undefined proc~esmfl_field_is_undefined->proc~mapl_gridget proc~esmfl_fieldgetdims ESMFL_FieldGetDims proc~esmfl_fieldgetdims->proc~mapl_gridget proc~esmfl_gridcoordget ESMFL_GridCoordGet proc~esmfl_gridcoordget->proc~mapl_gridget proc~has_level has_level proc~has_level->proc~mapl_gridget proc~has_level~2 regrid_support%has_level proc~has_level~2->proc~mapl_gridget proc~latlon_zmean latlon_zmean proc~latlon_zmean->proc~mapl_gridget proc~latlon_zstar latlon_zstar proc~latlon_zstar->proc~mapl_gridget proc~mapl_cfiocreatefromfile MAPL_CFIOCreateFromFile proc~mapl_cfiocreatefromfile->proc~mapl_gridget proc~mapl_cfioreadbundleread MAPL_CFIOReadBundleRead proc~mapl_cfioreadbundleread->proc~mapl_gridget proc~mapl_cfiowritebundlepost MAPL_CFIOWriteBundlePost proc~mapl_cfiowritebundlepost->proc~mapl_gridget proc~mapl_cfiowritebundlewait MAPL_CFIOWriteBundleWait proc~mapl_cfiowritebundlewait->proc~mapl_gridget proc~mapl_cfiowritebundlewrite MAPL_CFIOWriteBundleWrite proc~mapl_cfiowritebundlewrite->proc~mapl_gridget proc~mapl_collectivegather3d MAPL_CollectiveGather3D proc~mapl_collectivegather3d->proc~mapl_gridget proc~mapl_create_bundle_from_metdata_id MAPL_create_bundle_from_metdata_id proc~mapl_create_bundle_from_metdata_id->proc~mapl_gridget proc~mapl_esmfstatereadfromfile MAPL_ESMFStateReadFromFile proc~mapl_esmfstatereadfromfile->proc~mapl_gridget proc~mapl_genericfinalize MAPL_GenericFinalize proc~mapl_genericfinalize->proc~mapl_gridget proc~mapl_genericinitialize MAPL_GenericInitialize proc~mapl_genericinitialize->proc~mapl_gridget proc~mapl_genericrecord MAPL_GenericRecord proc~mapl_genericrecord->proc~mapl_gridget proc~mapl_genericstatesave MAPL_GenericStateSave proc~mapl_genericstatesave->proc~mapl_gridget proc~mapl_gridcoordadjust MAPL_GridCoordAdjust proc~mapl_gridcoordadjust->proc~mapl_gridget proc~mapl_tilemaskget MAPL_TileMaskGet proc~mapl_tilemaskget->proc~mapl_gridget proc~test_main test_main proc~test_main->proc~mapl_gridget proc~vertinterpolation_presskappa vertInterpolation_pressKappa proc~vertinterpolation_presskappa->proc~mapl_gridget program~time_ave time_ave program~time_ave->proc~mapl_gridget

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(:)

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

      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