GeomAspect.F90 Source File


This file depends on

sourcefile~~geomaspect.f90~~EfferentGraph sourcefile~geomaspect.f90 GeomAspect.F90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~geomaspect.f90->sourcefile~errorhandling.f90 sourcefile~extensionaction.f90 ExtensionAction.F90 sourcefile~geomaspect.f90->sourcefile~extensionaction.f90 sourcefile~geom_mgr.f90 geom_mgr.F90 sourcefile~geomaspect.f90->sourcefile~geom_mgr.f90 sourcefile~horizontaldimsspec.f90 HorizontalDimsSpec.F90 sourcefile~geomaspect.f90->sourcefile~horizontaldimsspec.f90 sourcefile~nullaction.f90 NullAction.F90 sourcefile~geomaspect.f90->sourcefile~nullaction.f90 sourcefile~regridaction.f90 RegridAction.F90 sourcefile~geomaspect.f90->sourcefile~regridaction.f90 sourcefile~regridder_mgr.f90 regridder_mgr.F90 sourcefile~geomaspect.f90->sourcefile~regridder_mgr.f90 sourcefile~stateitemaspect.f90 StateItemAspect.F90 sourcefile~geomaspect.f90->sourcefile~stateitemaspect.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~extensionaction.f90->sourcefile~errorhandling.f90 sourcefile~geomspec.f90 GeomSpec.F90 sourcefile~geom_mgr.f90->sourcefile~geomspec.f90 sourcefile~geomutilities.f90 GeomUtilities.F90 sourcefile~geom_mgr.f90->sourcefile~geomutilities.f90 sourcefile~nullaction.f90->sourcefile~errorhandling.f90 sourcefile~nullaction.f90->sourcefile~extensionaction.f90 sourcefile~regridaction.f90->sourcefile~errorhandling.f90 sourcefile~regridaction.f90->sourcefile~extensionaction.f90 sourcefile~regridaction.f90->sourcefile~regridder_mgr.f90 sourcefile~dynamicmask.f90 DynamicMask.F90 sourcefile~regridder_mgr.f90->sourcefile~dynamicmask.f90 sourcefile~regriddermanager.f90 RegridderManager.F90 sourcefile~regridder_mgr.f90->sourcefile~regriddermanager.f90 sourcefile~regridderspec.f90 RegridderSpec.F90 sourcefile~regridder_mgr.f90->sourcefile~regridderspec.f90 sourcefile~stateitemaspect.f90->sourcefile~errorhandling.f90 sourcefile~dynamicmask.f90->sourcefile~errorhandling.f90 sourcefile~base_base.f90 Base_Base.F90 sourcefile~dynamicmask.f90->sourcefile~base_base.f90 sourcefile~geomutilities.f90->sourcefile~errorhandling.f90 sourcefile~regriddermanager.f90->sourcefile~errorhandling.f90 sourcefile~regriddermanager.f90->sourcefile~regridderspec.f90 sourcefile~esmfregridderfactory.f90 EsmfRegridderFactory.F90 sourcefile~regriddermanager.f90->sourcefile~esmfregridderfactory.f90 sourcefile~nullregridder.f90 NullRegridder.F90 sourcefile~regriddermanager.f90->sourcefile~nullregridder.f90 sourcefile~regridderfactory.f90 RegridderFactory.F90 sourcefile~regriddermanager.f90->sourcefile~regridderfactory.f90 sourcefile~regridderfactoryvector.f90 RegridderFactoryVector.F90 sourcefile~regriddermanager.f90->sourcefile~regridderfactoryvector.f90 sourcefile~regridderspecvector.f90 RegridderSpecVector.F90 sourcefile~regriddermanager.f90->sourcefile~regridderspecvector.f90 sourcefile~regriddervector.f90 RegridderVector.F90 sourcefile~regriddermanager.f90->sourcefile~regriddervector.f90 sourcefile~regridderspec.f90->sourcefile~geom_mgr.f90 sourcefile~regridderparam.f90 RegridderParam.F90 sourcefile~regridderspec.f90->sourcefile~regridderparam.f90 sourcefile~constants.f90 Constants.F90 sourcefile~base_base.f90->sourcefile~constants.f90 sourcefile~keywordenforcer.f90 KeywordEnforcer.F90 sourcefile~base_base.f90->sourcefile~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~esmfregridderfactory.f90->sourcefile~errorhandling.f90 sourcefile~esmfregridderfactory.f90->sourcefile~regridderspec.f90 sourcefile~esmfregridderfactory.f90->sourcefile~nullregridder.f90 sourcefile~esmfregridderfactory.f90->sourcefile~regridderfactory.f90 sourcefile~esmfregridderfactory.f90->sourcefile~regridderparam.f90 sourcefile~routehandlemanager.f90 RoutehandleManager.F90 sourcefile~esmfregridderfactory.f90->sourcefile~routehandlemanager.f90 sourcefile~routehandleparam.f90 RoutehandleParam.F90 sourcefile~esmfregridderfactory.f90->sourcefile~routehandleparam.f90 sourcefile~nullregridder.f90->sourcefile~errorhandling.f90 sourcefile~regridderfactoryvector.f90->sourcefile~regridderfactory.f90 sourcefile~regridderspecvector.f90->sourcefile~regridderspec.f90

Files dependent on this one

sourcefile~~geomaspect.f90~~AfferentGraph sourcefile~geomaspect.f90 GeomAspect.F90 sourcefile~aspectcollection.f90 AspectCollection.F90 sourcefile~aspectcollection.f90->sourcefile~geomaspect.f90 sourcefile~fieldspec.f90 FieldSpec.F90 sourcefile~fieldspec.f90->sourcefile~geomaspect.f90 sourcefile~fieldspec.f90->sourcefile~aspectcollection.f90 sourcefile~variablespec.f90 VariableSpec.F90 sourcefile~fieldspec.f90->sourcefile~variablespec.f90 sourcefile~variablespec.f90->sourcefile~geomaspect.f90 sourcefile~variablespec.f90->sourcefile~aspectcollection.f90 sourcefile~bracketspec.f90 BracketSpec.F90 sourcefile~bracketspec.f90->sourcefile~fieldspec.f90 sourcefile~componentspec.f90 ComponentSpec.F90 sourcefile~componentspec.f90->sourcefile~variablespec.f90 sourcefile~componentspecparser.f90 ComponentSpecParser.F90 sourcefile~componentspecparser.f90->sourcefile~variablespec.f90 sourcefile~historycollectiongridcomp_private.f90 HistoryCollectionGridComp_private.F90 sourcefile~historycollectiongridcomp_private.f90->sourcefile~variablespec.f90 sourcefile~initialize_advertise.f90 initialize_advertise.F90 sourcefile~initialize_advertise.f90->sourcefile~variablespec.f90 sourcefile~make_itemspec.f90 make_itemSpec.F90 sourcefile~make_itemspec.f90->sourcefile~fieldspec.f90 sourcefile~make_itemspec.f90->sourcefile~variablespec.f90 sourcefile~mapl_generic.f90~2 MAPL_Generic.F90 sourcefile~mapl_generic.f90~2->sourcefile~variablespec.f90 sourcefile~mockitemspec.f90 MockItemSpec.F90 sourcefile~mockitemspec.f90->sourcefile~aspectcollection.f90 sourcefile~mockitemspec.f90->sourcefile~variablespec.f90 sourcefile~modelverticalgrid.f90 ModelVerticalGrid.F90 sourcefile~modelverticalgrid.f90->sourcefile~fieldspec.f90 sourcefile~servicespec.f90 ServiceSpec.F90 sourcefile~servicespec.f90->sourcefile~variablespec.f90 sourcefile~stateitemspec.f90 StateItemSpec.F90 sourcefile~stateitemspec.f90->sourcefile~aspectcollection.f90 sourcefile~statespec.f90 StateSpec.F90 sourcefile~statespec.f90->sourcefile~variablespec.f90 sourcefile~test_addfieldspec.pf Test_AddFieldSpec.pf sourcefile~test_addfieldspec.pf->sourcefile~fieldspec.f90 sourcefile~test_bracketspec.pf Test_BracketSpec.pf sourcefile~test_bracketspec.pf->sourcefile~fieldspec.f90 sourcefile~test_fieldspec.pf Test_FieldSpec.pf sourcefile~test_fieldspec.pf->sourcefile~aspectcollection.f90 sourcefile~test_fieldspec.pf->sourcefile~fieldspec.f90 sourcefile~test_modelverticalgrid.pf Test_ModelVerticalGrid.pf sourcefile~test_modelverticalgrid.pf->sourcefile~variablespec.f90 sourcefile~variablespecvector.f90 VariableSpecVector.F90 sourcefile~variablespecvector.f90->sourcefile~variablespec.f90 sourcefile~wildcardspec.f90 WildcardSpec.F90 sourcefile~wildcardspec.f90->sourcefile~aspectcollection.f90

Source Code

#include "MAPL_Generic.h"

module mapl3g_GeomAspect
   use mapl3g_HorizontalDimsSpec
   use mapl3g_StateItemAspect
   use mapl3g_geom_mgr, only: MAPL_SameGeom
   use mapl3g_regridder_mgr, only: EsmfRegridderParam
   use mapl3g_ExtensionAction
   use mapl3g_RegridAction
   use mapl3g_NullAction
   use mapl_ErrorHandling
   use ESMF, only: ESMF_Geom
   implicit none
   private

   public :: GeomAspect


   type, extends(StateItemAspect) :: GeomAspect
      type(ESMF_Geom), allocatable :: geom
      type(EsmfRegridderParam) :: regridder_param
      type(HorizontalDimsSpec) :: horizontal_dims_spec = HORIZONTAL_DIMS_GEOM ! none, geom
   contains
      procedure :: matches
      procedure :: make_action
      procedure :: supports_conversion_general
      procedure :: supports_conversion_specific
      procedure :: set_geom
      procedure :: get_geom
   end type GeomAspect

   interface GeomAspect
      procedure new_GeomAspect
   end interface

contains

   function new_GeomAspect(geom, regridder_param, horizontal_dims_spec, is_time_dependent) result(aspect)
      type(GeomAspect) :: aspect
      type(ESMF_Geom), optional, intent(in) :: geom
      type(EsmfRegridderParam), optional, intent(in) :: regridder_param
      type(HorizontalDimsSpec), optional, intent(in) :: horizontal_dims_spec
      logical, optional, intent(in) :: is_time_dependent

      call aspect%set_mirror(.true.)

      if (present(geom)) then
         aspect%geom = geom
         call aspect%set_mirror(.false.)
      end if

      aspect%regridder_param = EsmfRegridderParam() ! default
      if (present(regridder_param)) then
         aspect%regridder_param = regridder_param
      end if

      aspect%horizontal_dims_spec = HORIZONTAL_DIMS_GEOM ! default
      if (present(horizontal_dims_spec)) then
         aspect%horizontal_dims_spec = horizontal_dims_spec
      end if

      call aspect%set_time_dependent(is_time_dependent)

   end function new_GeomAspect

   ! Generally, geoms can be converted via RouteHandle, but there
   ! are definitely many exceptions.   A better implementation here could attempt to create
   ! the relevant regridder.
   logical function supports_conversion_general(src)
      class(GeomAspect), intent(in) :: src
      supports_conversion_general = .true.
   end function supports_conversion_general

   logical function supports_conversion_specific(src, dst)
      class(GeomAspect), intent(in) :: src
      class(StateItemAspect), intent(in) :: dst

      supports_conversion_specific = .false.
      select type(dst)
      class is (GeomAspect)
         supports_conversion_specific = (src%horizontal_dims_spec == dst%horizontal_dims_spec)
      end select

   end function supports_conversion_specific

   logical function matches(src, dst)
      class(GeomAspect), intent(in) :: src
      class(StateItemAspect), intent(in) :: dst

      select type(dst)
      class is (GeomAspect)
         matches = MAPL_SameGeom(src%geom, dst%geom) .and. (src%horizontal_dims_spec == dst%horizontal_dims_spec)
      class default
         matches = .false.
      end select

   end function matches

   function make_action(src, dst, rc) result(action)
      class(ExtensionAction), allocatable :: action
      class(GeomAspect), intent(in) :: src
      class(StateItemAspect), intent(in)  :: dst
      integer, optional, intent(out) :: rc

      select type(dst)
      class is (GeomAspect)
         allocate(action, source=RegridAction(src%geom, dst%geom, dst%regridder_param))
      class default
         allocate(action,source=NullAction())
         _FAIL('src is GeomAspect but dst is different subclass')
      end select

      _RETURN(_SUCCESS)
   end function make_action

   subroutine set_geom(this, geom)
      class(GeomAspect), intent(inout) :: this
      type(ESMF_Geom) :: geom

      this%geom = geom
      call this%set_mirror(.false.)
      
   end subroutine set_geom

   function get_geom(this, rc) result(geom)
      class(GeomAspect), intent(in) :: this
      type(ESMF_Geom) :: geom
      integer, optional, intent(out) :: rc

      _ASSERT(allocated(this%geom), 'geom not allocated')
      geom = this%geom

      _RETURN(_SUCCESS)
   end function get_geom

end module mapl3g_GeomAspect