MAPL_GetLatLonCoord.F90 Source File


This file depends on

sourcefile~~mapl_getlatloncoord.f90~~EfferentGraph sourcefile~mapl_getlatloncoord.f90 MAPL_GetLatLonCoord.F90 sourcefile~base_base.f90 Base_Base.F90 sourcefile~mapl_getlatloncoord.f90->sourcefile~base_base.f90 sourcefile~mapl_comms.f90 MAPL_Comms.F90 sourcefile~mapl_getlatloncoord.f90->sourcefile~mapl_comms.f90 sourcefile~mapl_errorhandling.f90 MAPL_ErrorHandling.F90 sourcefile~mapl_getlatloncoord.f90->sourcefile~mapl_errorhandling.f90 sourcefile~constants.f90 Constants.F90 sourcefile~base_base.f90->sourcefile~constants.f90 sourcefile~mapl_keywordenforcer.f90 MAPL_KeywordEnforcer.F90 sourcefile~base_base.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~mapl_range.f90 MAPL_Range.F90 sourcefile~base_base.f90->sourcefile~mapl_range.f90 sourcefile~maplgrid.f90 MaplGrid.F90 sourcefile~base_base.f90->sourcefile~maplgrid.f90 sourcefile~mapl_comms.f90->sourcefile~base_base.f90 sourcefile~mapl_comms.f90->sourcefile~constants.f90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~mapl_comms.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~shmem.f90 Shmem.F90 sourcefile~mapl_comms.f90->sourcefile~shmem.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~mapl_errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~internalconstants.f90 InternalConstants.F90 sourcefile~constants.f90->sourcefile~internalconstants.f90 sourcefile~mathconstants.f90 MathConstants.F90 sourcefile~constants.f90->sourcefile~mathconstants.f90 sourcefile~physicalconstants.f90 PhysicalConstants.F90 sourcefile~constants.f90->sourcefile~physicalconstants.f90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_errorhandling.f90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_throw.f90 sourcefile~mapl_range.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~maplgrid.f90->sourcefile~mapl_errorhandling.f90 sourcefile~maplgrid.f90->sourcefile~constants.f90 sourcefile~maplgrid.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~mapl_sort.f90 MAPL_Sort.F90 sourcefile~maplgrid.f90->sourcefile~mapl_sort.f90 sourcefile~pflogger_stub.f90 pflogger_stub.F90 sourcefile~maplgrid.f90->sourcefile~pflogger_stub.f90 sourcefile~shmem.f90->sourcefile~constants.f90 sourcefile~mapl_sort.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~pfl_keywordenforcer.f90 PFL_KeywordEnforcer.F90 sourcefile~pflogger_stub.f90->sourcefile~pfl_keywordenforcer.f90 sourcefile~wraparray.f90 WrapArray.F90 sourcefile~pflogger_stub.f90->sourcefile~wraparray.f90 sourcefile~physicalconstants.f90->sourcefile~mathconstants.f90

Files dependent on this one

sourcefile~~mapl_getlatloncoord.f90~~AfferentGraph sourcefile~mapl_getlatloncoord.f90 MAPL_GetLatLonCoord.F90 sourcefile~mapl_cfio.f90 MAPL_CFIO.F90 sourcefile~mapl_cfio.f90->sourcefile~mapl_getlatloncoord.f90 sourcefile~mapl_regriddermanager.f90 MAPL_RegridderManager.F90 sourcefile~mapl_cfio.f90->sourcefile~mapl_regriddermanager.f90 sourcefile~mapl_latlontolatlonregridder.f90 MAPL_LatLonToLatLonRegridder.F90 sourcefile~mapl_latlontolatlonregridder.f90->sourcefile~mapl_getlatloncoord.f90 sourcefile~base.f90 Base.F90 sourcefile~base.f90->sourcefile~mapl_cfio.f90 sourcefile~base.f90->sourcefile~mapl_regriddermanager.f90 sourcefile~mapl_simplebundlemod.f90 MAPL_SimpleBundleMod.F90 sourcefile~base.f90->sourcefile~mapl_simplebundlemod.f90 sourcefile~extdatadrivermod.f90 ExtDataDriverMod.F90 sourcefile~extdatadrivermod.f90->sourcefile~mapl_cfio.f90 sourcefile~extdatadrivergridcomp.f90 ExtDataDriverGridComp.F90 sourcefile~extdatadrivermod.f90->sourcefile~extdatadrivergridcomp.f90 sourcefile~mapl.f90 MAPL.F90 sourcefile~extdatadrivermod.f90->sourcefile~mapl.f90 sourcefile~extdatagridcompmod.f90 ExtDataGridCompMod.F90 sourcefile~extdatagridcompmod.f90->sourcefile~mapl_cfio.f90 sourcefile~extdatagridcompng.f90 ExtDataGridCompNG.F90 sourcefile~extdatagridcompng.f90->sourcefile~mapl_cfio.f90 sourcefile~mapl_cap.f90 MAPL_Cap.F90 sourcefile~mapl_cap.f90->sourcefile~mapl_cfio.f90 sourcefile~mapl_capgridcomp.f90 MAPL_CapGridComp.F90 sourcefile~mapl_cap.f90->sourcefile~mapl_capgridcomp.f90 sourcefile~mapl_historycollection.f90 MAPL_HistoryCollection.F90 sourcefile~mapl_historycollection.f90->sourcefile~mapl_cfio.f90 sourcefile~mapl_historygridcomp.f90 MAPL_HistoryGridComp.F90 sourcefile~mapl_historygridcomp.f90->sourcefile~mapl_cfio.f90 sourcefile~mapl_historygridcomp.f90->sourcefile~mapl_historycollection.f90 sourcefile~mapl_regriddermanager.f90->sourcefile~mapl_latlontolatlonregridder.f90 sourcefile~mapl_simplebundlemod.f90->sourcefile~mapl_cfio.f90 sourcefile~regrid_util.f90 Regrid_Util.F90 sourcefile~regrid_util.f90->sourcefile~mapl_cfio.f90 sourcefile~regrid_util.f90->sourcefile~mapl.f90 sourcefile~utcfio_array.f90 utCFIO_Array.F90 sourcefile~utcfio_array.f90->sourcefile~mapl_cfio.f90 sourcefile~utcfio_nbits.f90 utCFIO_Nbits.F90 sourcefile~utcfio_nbits.f90->sourcefile~mapl_cfio.f90 sourcefile~extdatadriver.f90 ExtDataDriver.F90 sourcefile~extdatadriver.f90->sourcefile~extdatadrivermod.f90 sourcefile~extdatadriver.f90->sourcefile~extdatadrivergridcomp.f90 sourcefile~extdatadriver.f90->sourcefile~mapl.f90 sourcefile~extdatadrivergridcomp.f90->sourcefile~extdatagridcompmod.f90 sourcefile~extdatadrivergridcomp.f90->sourcefile~extdatagridcompng.f90 sourcefile~extdatadrivergridcomp.f90->sourcefile~mapl_historygridcomp.f90 sourcefile~extdatadrivergridcomp.f90->sourcefile~mapl.f90 sourcefile~mapl.f90->sourcefile~base.f90 sourcefile~mapl_gridcomps.f90 MAPL_GridComps.F90 sourcefile~mapl.f90->sourcefile~mapl_gridcomps.f90 sourcefile~mapl_capgridcomp.f90->sourcefile~extdatagridcompmod.f90 sourcefile~mapl_capgridcomp.f90->sourcefile~extdatagridcompng.f90 sourcefile~mapl_capgridcomp.f90->sourcefile~mapl_historygridcomp.f90 sourcefile~mapl_gridcomps.f90->sourcefile~mapl_cap.f90 sourcefile~mapl_nuopcwrappermod.f90 MAPL_NUOPCWrapperMod.F90 sourcefile~mapl_nuopcwrappermod.f90->sourcefile~base.f90 sourcefile~mapl_nuopcwrappermod.f90->sourcefile~mapl_cap.f90 sourcefile~test_cfio_bundle.pf Test_CFIO_Bundle.pf sourcefile~test_cfio_bundle.pf->sourcefile~base.f90 sourcefile~tstqsat.f90 tstqsat.F90 sourcefile~tstqsat.f90->sourcefile~base.f90 sourcefile~ut_extdata.f90 ut_ExtData.F90 sourcefile~ut_extdata.f90->sourcefile~base.f90 sourcefile~ut_extdata.f90->sourcefile~extdatagridcompmod.f90 sourcefile~utcfio_bundle.f90 utCFIO_Bundle.F90 sourcefile~utcfio_bundle.f90->sourcefile~base.f90 sourcefile~capdriver.f90 CapDriver.F90 sourcefile~capdriver.f90->sourcefile~mapl.f90 sourcefile~comp_testing_driver.f90 Comp_Testing_Driver.F90 sourcefile~comp_testing_driver.f90->sourcefile~mapl.f90 sourcefile~comp_testing_driver.f90->sourcefile~mapl_capgridcomp.f90 sourcefile~extdataroot_gridcomp.f90 ExtDataRoot_GridComp.F90 sourcefile~extdataroot_gridcomp.f90->sourcefile~mapl.f90 sourcefile~mapl_demo_fargparse.f90 MAPL_demo_fargparse.F90 sourcefile~mapl_demo_fargparse.f90->sourcefile~mapl.f90 sourcefile~pfio_mapl_demo.f90 pfio_MAPL_demo.F90 sourcefile~pfio_mapl_demo.f90->sourcefile~mapl.f90 sourcefile~time_ave_util.f90 time_ave_util.F90 sourcefile~time_ave_util.f90->sourcefile~mapl.f90 sourcefile~varspecdescription.f90 VarspecDescription.F90 sourcefile~varspecdescription.f90->sourcefile~mapl.f90

Source Code

#include "MAPL_Generic.h"

module MAPL_GetLatLonCoordMod
  use, intrinsic :: iso_fortran_env, only: REAL32
  use, intrinsic :: iso_fortran_env, only: REAL64
  use mapl_ErrorHandlingMod
  use MAPL_BaseMod, only: MAPL_GridGet
  use MAPL_CommsMod
  use esmf
  implicit none
  private

  public :: MAPL_GetLatLonCoord

  interface MAPL_GetLatLonCoord
    module procedure MAPL_GetLatLonCoord_REAL64
    module procedure MAPL_GetLatLonCoord_REAL32
  end interface

contains


   subroutine MAPL_GetLatLonCoord_REAL64(grid,dim,x,rc)
      real(kind=REAL64), intent(out)  :: x(:)
      type(ESMF_Grid), intent(inout) :: grid
      integer,           intent(in) :: dim
      integer, optional, intent(out) :: rc

      real(kind=REAL64), pointer :: x_2d(:,:) => null()
      real(kind=REAL64), allocatable :: xg(:,:)
      integer :: counts(3),mypet
      type(ESMF_DistGrid) :: distgrid
      type(ESMF_DeLayout) :: layout
      type(ESMF_VM) :: vm
      integer :: status

      call ESMF_GridGetCoord (grid, coordDim=dim, localDE=0, &
               staggerloc=ESMF_STAGGERLOC_CENTER, &
               farrayPtr=x_2d, rc=status)
      _VERIFY(status)
      call MAPL_GridGet(grid,globalCellCountPerDim=counts,rc=status)
      _VERIFY(status)

      allocate(xg(counts(1),counts(2)),stat=status)
      _VERIFY(status)

      call ArrayGather(x_2d,xg,grid,rc=status)
      _VERIFY(status)
      call ESMF_GridGet(GRID, DistGrid=distgrid, rc=status)
      _VERIFY(STATUS)
      call ESMF_DistGridGet(distgrid, DELayout=layout, rc=status)
      _VERIFY(STATUS)
      call ESMF_DELayoutGet(layout,vm=vm,rc=status)
      _VERIFY(status)
      call ESMF_VMGet(vm,localPet=myPet,rc=status)
      _VERIFY(status)
      if (dim==1) then
         if(myPet==0) x = xg(:,1)
      else if (dim==2) then
         if (myPet==0) x = xg(1,:)
      else
         _FAIL('unsupported rank > 2')
      end if
      call MAPL_CommsBcast(layout,x,size(x), 0, rc=status)
      _VERIFY(status)
      deallocate(xg)

   end subroutine MAPL_GetLatLonCoord_Real64

   subroutine MAPL_GetLatLonCoord_REAL32(grid,dim,x,rc)
      real(kind=REAL32), intent(out)  :: x(:)
      type(ESMF_Grid), intent(inout) :: grid
      integer,           intent(in) :: dim
      integer, optional, intent(out) :: rc

      real(kind=REAL64), pointer :: x_2d(:,:) => null()
      real(kind=REAL32), allocatable :: xg(:,:),xl(:,:)
      integer :: counts(3),mypet
      type(ESMF_DistGrid) :: distgrid
      type(ESMF_DeLayout) :: layout
      type(ESMF_VM) :: vm
      integer :: status

      call ESMF_GridGetCoord (grid, coordDim=dim, localDE=0, &
               staggerloc=ESMF_STAGGERLOC_CENTER, &
               farrayPtr=x_2d, rc=status)
      _VERIFY(status)
      call MAPL_GridGet(grid,globalCellCountPerDim=counts,rc=status)
      _VERIFY(status)

      allocate(xg(counts(1),counts(2)),stat=status)
      _VERIFY(status)
      allocate(xl(size(x_2d,1),size(x_2d,2)),stat=status)
      _VERIFY(status)
      xl=x_2d

      call ArrayGather(xl,xg,grid,rc=status)
      _VERIFY(status)
      deallocate(xl)
      call ESMF_GridGet(GRID, DistGrid=distgrid, rc=status)
      _VERIFY(STATUS)
      call ESMF_DistGridGet(distgrid, DELayout=layout, rc=status)
      _VERIFY(STATUS)
      call ESMF_DELayoutGet(layout,vm=vm,rc=status)
      _VERIFY(status)
      call ESMF_VMGet(vm,localPet=myPet,rc=status)
      _VERIFY(status)
      if (dim==1) then
         if(myPet==0) x = xg(:,1)
      else if (dim==2) then
         if (myPet==0) x = xg(1,:)
      else
         _FAIL('unsupported rank > 2')
      end if
      call MAPL_CommsBcast(layout,x,size(x), 0, rc=status)
      _VERIFY(status)
      deallocate(xg)

   end subroutine MAPL_GetLatLonCoord_Real32

end module MAPL_GetLatLonCoordMod