NewRegridderManager.F90 Source File


This file depends on

sourcefile~~newregriddermanager.f90~~EfferentGraph sourcefile~newregriddermanager.f90 NewRegridderManager.F90 sourcefile~horizontalfluxregridder.f90 HorizontalFluxRegridder.F90 sourcefile~newregriddermanager.f90->sourcefile~horizontalfluxregridder.f90 sourcefile~mapl_abstractregridder.f90 MAPL_AbstractRegridder.F90 sourcefile~newregriddermanager.f90->sourcefile~mapl_abstractregridder.f90 sourcefile~mapl_errorhandling.f90 MAPL_ErrorHandling.F90 sourcefile~newregriddermanager.f90->sourcefile~mapl_errorhandling.f90 sourcefile~mapl_esmfregridder.f90 MAPL_EsmfRegridder.F90 sourcefile~newregriddermanager.f90->sourcefile~mapl_esmfregridder.f90 sourcefile~mapl_gridmanager.f90 MAPL_GridManager.F90 sourcefile~newregriddermanager.f90->sourcefile~mapl_gridmanager.f90 sourcefile~mapl_identityregridder.f90 MAPL_IdentityRegridder.F90 sourcefile~newregriddermanager.f90->sourcefile~mapl_identityregridder.f90 sourcefile~mapl_keywordenforcer.f90 MAPL_KeywordEnforcer.F90 sourcefile~newregriddermanager.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~mapl_regriddervector.f90 MAPL_RegridderVector.F90 sourcefile~newregriddermanager.f90->sourcefile~mapl_regriddervector.f90 sourcefile~regridderspec.f90 RegridderSpec.F90 sourcefile~newregriddermanager.f90->sourcefile~regridderspec.f90 sourcefile~regridmethods.f90 RegridMethods.F90 sourcefile~newregriddermanager.f90->sourcefile~regridmethods.f90 sourcefile~horizontalfluxregridder.f90->sourcefile~mapl_abstractregridder.f90 sourcefile~horizontalfluxregridder.f90->sourcefile~mapl_errorhandling.f90 sourcefile~horizontalfluxregridder.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~horizontalfluxregridder.f90->sourcefile~regridderspec.f90 sourcefile~horizontalfluxregridder.f90->sourcefile~regridmethods.f90 sourcefile~base_base.f90 Base_Base.F90 sourcefile~horizontalfluxregridder.f90->sourcefile~base_base.f90 sourcefile~mapl_abstractregridder.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~mapl_abstractregridder.f90->sourcefile~regridderspec.f90 sourcefile~mapl_abstractregridder.f90->sourcefile~base_base.f90 sourcefile~constants.f90 Constants.F90 sourcefile~mapl_abstractregridder.f90->sourcefile~constants.f90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~mapl_abstractregridder.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~mapl_memutils.f90 MAPL_MemUtils.F90 sourcefile~mapl_abstractregridder.f90->sourcefile~mapl_memutils.f90 sourcefile~regridderspecroutehandlemap.f90 RegridderSpecRouteHandleMap.F90 sourcefile~mapl_abstractregridder.f90->sourcefile~regridderspecroutehandlemap.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~mapl_errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~mapl_esmfregridder.f90->sourcefile~mapl_abstractregridder.f90 sourcefile~mapl_esmfregridder.f90->sourcefile~mapl_errorhandling.f90 sourcefile~mapl_esmfregridder.f90->sourcefile~mapl_gridmanager.f90 sourcefile~mapl_esmfregridder.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~mapl_esmfregridder.f90->sourcefile~regridderspec.f90 sourcefile~mapl_esmfregridder.f90->sourcefile~regridmethods.f90 sourcefile~mapl_esmfregridder.f90->sourcefile~base_base.f90 sourcefile~mapl_esmfregridder.f90->sourcefile~constants.f90 sourcefile~mapl_abstractgridfactory.f90 MAPL_AbstractGridFactory.F90 sourcefile~mapl_esmfregridder.f90->sourcefile~mapl_abstractgridfactory.f90 sourcefile~maplgrid.f90 MaplGrid.F90 sourcefile~mapl_esmfregridder.f90->sourcefile~maplgrid.f90 sourcefile~mapl_esmfregridder.f90->sourcefile~regridderspecroutehandlemap.f90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_errorhandling.f90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_abstractgridfactory.f90 sourcefile~mapl_cubedspheregridfactory.f90 MAPL_CubedSphereGridFactory.F90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_cubedspheregridfactory.f90 sourcefile~mapl_externalgridfactory.f90 MAPL_ExternalGridFactory.F90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_externalgridfactory.f90 sourcefile~mapl_integer64gridfactorymap.f90 MAPL_Integer64GridFactoryMap.F90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_integer64gridfactorymap.f90 sourcefile~mapl_latlongridfactory.f90 MAPL_LatLonGridFactory.F90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_latlongridfactory.f90 sourcefile~mapl_stringgridfactorymap.f90 MAPL_StringGridFactoryMap.F90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_stringgridfactorymap.f90 sourcefile~mapl_swathgridfactory.f90 MAPL_SwathGridFactory.F90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_swathgridfactory.f90 sourcefile~mapl_tripolargridfactory.f90 MAPL_TripolarGridFactory.F90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_tripolargridfactory.f90 sourcefile~mapl_xygridfactory.f90 MAPL_XYGridFactory.F90 sourcefile~mapl_gridmanager.f90->sourcefile~mapl_xygridfactory.f90 sourcefile~pfio.f90 pFIO.F90 sourcefile~mapl_gridmanager.f90->sourcefile~pfio.f90 sourcefile~mapl_identityregridder.f90->sourcefile~mapl_abstractregridder.f90 sourcefile~mapl_identityregridder.f90->sourcefile~mapl_errorhandling.f90 sourcefile~mapl_identityregridder.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~mapl_identityregridder.f90->sourcefile~regridderspec.f90 sourcefile~mapl_identityregridder.f90->sourcefile~regridmethods.f90 sourcefile~mapl_identityregridder.f90->sourcefile~base_base.f90 sourcefile~mapl_comms.f90 MAPL_Comms.F90 sourcefile~mapl_identityregridder.f90->sourcefile~mapl_comms.f90 sourcefile~mapl_gridspec.f90 MAPL_GridSpec.F90 sourcefile~mapl_identityregridder.f90->sourcefile~mapl_gridspec.f90 sourcefile~mapl_regriddervector.f90->sourcefile~mapl_abstractregridder.f90 sourcefile~regridderspec.f90->sourcefile~mapl_errorhandling.f90 sourcefile~regridderspec.f90->sourcefile~mapl_gridmanager.f90 sourcefile~regridderspec.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~regridderspec.f90->sourcefile~regridmethods.f90

Files dependent on this one

sourcefile~~newregriddermanager.f90~~AfferentGraph sourcefile~newregriddermanager.f90 NewRegridderManager.F90 sourcefile~base.f90 Base.F90 sourcefile~base.f90->sourcefile~newregriddermanager.f90 sourcefile~mapl_cfio.f90 MAPL_CFIO.F90 sourcefile~base.f90->sourcefile~mapl_cfio.f90 sourcefile~griddedio.f90 GriddedIO.F90 sourcefile~griddedio.f90->sourcefile~newregriddermanager.f90 sourcefile~mapl_cfio.f90->sourcefile~newregriddermanager.f90 sourcefile~mapl_epochswathmod.f90 MAPL_EpochSwathMod.F90 sourcefile~mapl_epochswathmod.f90->sourcefile~newregriddermanager.f90 sourcefile~regrid_util.f90 Regrid_Util.F90 sourcefile~regrid_util.f90->sourcefile~newregriddermanager.f90 sourcefile~regrid_util.f90->sourcefile~mapl_cfio.f90 sourcefile~extdata_iobundlemod.f90 ExtData_IOBundleMod.F90 sourcefile~extdata_iobundlemod.f90->sourcefile~griddedio.f90 sourcefile~extdata_iobundlemod.f90~2 ExtData_IOBundleMod.F90 sourcefile~extdata_iobundlemod.f90~2->sourcefile~griddedio.f90 sourcefile~extdatadrivermod.f90 ExtDataDriverMod.F90 sourcefile~extdatadrivermod.f90->sourcefile~mapl_cfio.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~fieldbundleread.f90 FieldBundleRead.F90 sourcefile~fieldbundleread.f90->sourcefile~griddedio.f90 sourcefile~fieldbundlewrite.f90 FieldBundleWrite.F90 sourcefile~fieldbundlewrite.f90->sourcefile~griddedio.f90 sourcefile~mapl.f90 MAPL.F90 sourcefile~mapl.f90->sourcefile~base.f90 sourcefile~mapl_cap.f90 MAPL_Cap.F90 sourcefile~mapl_cap.f90->sourcefile~mapl_cfio.f90 sourcefile~mapl_historycollection.f90 MAPL_HistoryCollection.F90 sourcefile~mapl_historycollection.f90->sourcefile~griddedio.f90 sourcefile~mapl_historycollection.f90->sourcefile~mapl_cfio.f90 sourcefile~mapl_historycollection.f90->sourcefile~mapl_epochswathmod.f90 sourcefile~mapl_historygridcomp.f90 MAPL_HistoryGridComp.F90 sourcefile~mapl_historygridcomp.f90->sourcefile~mapl_cfio.f90 sourcefile~mapl_historygridcomp.f90->sourcefile~mapl_epochswathmod.f90 sourcefile~mapl_nuopcwrappermod.f90 MAPL_NUOPCWrapperMod.F90 sourcefile~mapl_nuopcwrappermod.f90->sourcefile~base.f90 sourcefile~mapl_simplebundlemod.f90 MAPL_SimpleBundleMod.F90 sourcefile~mapl_simplebundlemod.f90->sourcefile~mapl_cfio.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~utcfio_array.f90 utCFIO_Array.F90 sourcefile~utcfio_array.f90->sourcefile~mapl_cfio.f90 sourcefile~utcfio_bundle.f90 utCFIO_Bundle.F90 sourcefile~utcfio_bundle.f90->sourcefile~base.f90 sourcefile~utcfio_nbits.f90 utCFIO_Nbits.F90 sourcefile~utcfio_nbits.f90->sourcefile~mapl_cfio.f90

Source Code

#include "MAPL_Generic.h"

module mapl_NewRegridderManager_private
   use MAPL_GridManagerMod
   use MAPL_RegridderSpec
   use MAPL_RegridderVectorMod
   use MAPL_KeywordEnforcerMod
   use mapl_ErrorHandlingMod
   use MAPL_AbstractRegridderMod
   use MAPL_IdentityRegridderMod
   use ESMF
   use mapl_HorizontalFluxRegridder
   use MAPL_EsmfRegridderMod
   use mapl_RegridMethods
   implicit none
   private

   public :: NewRegridderManager

   ! Private set of pre-computed route-handles.
   ! Convervative, Tiling, and Voting can all use the same route-handle.
   ! Despite being treated as "different" grids.

   type :: NewRegridderManager
      private
      logical :: initialized = .false.
      type(RegridderVector) :: prototypes
      type(RegridderVector) :: regridders
   contains
      procedure :: add_prototype
      procedure :: find_prototype
      procedure :: make_regridder_
      generic :: make_regridder => make_regridder_
      procedure :: is_initialized
      procedure :: initialize
   end type NewRegridderManager

   character(len=*), parameter :: MOD_NAME = 'mapl_NewRegridderManager_private::'

contains

   subroutine add_prototype(this, prototype)
      class(NewRegridderManager), intent(inout) :: this
      class(AbstractRegridder), intent(in) :: prototype

      call this%prototypes%push_back(prototype)

   end subroutine add_prototype


   function make_regridder_(this, grid_in, grid_out, regrid_method, unusable, hints, rc) result(regridder)
      class (AbstractRegridder), pointer :: regridder
      class (NewRegridderManager), target, intent(inout) :: this
      type (ESMF_Grid), intent(in) :: grid_in
      type (ESMF_Grid), intent(in) :: grid_out
      integer, intent(in) :: regrid_method
      class (KeywordEnforcer), optional, intent(in) :: unusable
      integer, optional, intent(in) :: hints
      integer, optional,  intent(out) :: rc

      integer :: status
      character(len=*), parameter :: Iam= MOD_NAME // 'make_regridder_from_grids'
      type (RegridderSpec) :: spec
      integer(ESMF_KIND_I8) :: id_in, id_out

      class(AbstractRegridder), pointer :: prototype

      _UNUSED_DUMMY(unusable)

      if (.not. this%is_initialized()) call this%initialize()

      id_in = get_factory_id(grid_in,rc=status)
      _VERIFY(status)
      id_out = get_factory_id(grid_out,rc=status)
      _VERIFY(status)
      ! Special case if two grids are the same
      if (id_in == id_out) then
         regridder => identity_regridder()
         _RETURN(_SUCCESS)
      end if

      ! If manager already has suitable regridder, use it.
      spec = RegridderSpec(grid_in, grid_out, regrid_method, hints=hints)

      regridder => find(this%regridders, spec)
      if (associated(regridder)) then
         _RETURN(_SUCCESS)
      end if

      ! Else build from prototype
      prototype => this%find_prototype(spec, rc=status)
      _VERIFY(status)
      
      call this%regridders%push_back(prototype)
      regridder => this%regridders%back()
      call regridder%initialize(spec, rc=status)
      _VERIFY(status)

      _RETURN(_SUCCESS)

   contains

      function find(vector, spec) result(match)
         class (AbstractRegridder), pointer :: match
         type (RegridderVector), target :: vector
         type (RegridderSpec), intent(in) :: spec

         type (RegridderVectorIterator) :: iter

         iter = vector%begin()
         do while (iter /= vector%end())
            match => iter%get()
            if (match%get_spec() == spec) return
           call iter%next()
        end do

        match => null()

     end function find

   end function make_regridder_

   function find_prototype(this, spec, unusable, rc) result(prototype)
      class(AbstractRegridder), pointer :: prototype
      class(NewRegridderManager), target, intent(in) :: this
      type(RegridderSpec), intent(in) :: spec
      class(KeywordEnforcer), optional, intent(in) :: unusable
      integer, optional, intent(out) :: rc

      integer :: status
      logical :: supports
      type(RegridderVectorIterator) :: iter

      _UNUSED_DUMMY(unusable)

      iter = this%prototypes%begin()
      do while (iter /= this%prototypes%end())
         prototype => iter%get()
         supports = prototype%supports(spec,_RC)
         if (supports) then
            _RETURN(_SUCCESS)
         end if
         call iter%next()
      end do

      ! not found
      _RETURN(_FAILURE)
   end function find_prototype

   logical function is_initialized(this)
      class(NewRegridderManager), intent(in) :: this
      is_initialized = this%initialized
   end function is_initialized

   subroutine initialize(this)
      class(NewRegridderManager), intent(inout) :: this

      type(EsmfRegridder) :: esmf_regridder
      type(HorizontalFluxRegridder) :: horizontal_flux_regridder

      if (this%is_initialized()) return
      
      call this%add_prototype(esmf_regridder)
      call this%add_prototype(horizontal_flux_regridder)
      
      this%initialized = .true.
   end subroutine initialize

end module mapl_NewRegridderManager_private



module mapl_NewRegridderManager
   use mapl_NewRegridderManager_private
   implicit none
   private

   public :: new_regridder_manager

   type (NewRegridderManager), target, save :: new_regridder_manager

end module mapl_NewRegridderManager