AttributesAspect.F90 Source File


This file depends on

sourcefile~~attributesaspect.f90~~EfferentGraph sourcefile~attributesaspect.f90 AttributesAspect.F90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~attributesaspect.f90->sourcefile~errorhandling.f90 sourcefile~extensionaction.f90 ExtensionAction.F90 sourcefile~attributesaspect.f90->sourcefile~extensionaction.f90 sourcefile~nullaction.f90 NullAction.F90 sourcefile~attributesaspect.f90->sourcefile~nullaction.f90 sourcefile~stateitemaspect.f90 StateItemAspect.F90 sourcefile~attributesaspect.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~nullaction.f90->sourcefile~errorhandling.f90 sourcefile~nullaction.f90->sourcefile~extensionaction.f90 sourcefile~stateitemaspect.f90->sourcefile~errorhandling.f90

Files dependent on this one

sourcefile~~attributesaspect.f90~~AfferentGraph sourcefile~attributesaspect.f90 AttributesAspect.F90 sourcefile~aspectcollection.f90 AspectCollection.F90 sourcefile~aspectcollection.f90->sourcefile~attributesaspect.f90 sourcefile~fieldspec.f90 FieldSpec.F90 sourcefile~fieldspec.f90->sourcefile~attributesaspect.f90 sourcefile~fieldspec.f90->sourcefile~aspectcollection.f90 sourcefile~variablespec.f90 VariableSpec.F90 sourcefile~fieldspec.f90->sourcefile~variablespec.f90 sourcefile~variablespec.f90->sourcefile~attributesaspect.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"

! We require that an export provides all attributes that an import
! specifies as a shared attribute.  Some attributes of the export may
! be unused and/or correspond to attributes needed by other imports.

module mapl3g_AttributesAspect
   use mapl3g_StateItemAspect
   use mapl3g_ExtensionAction
   use mapl3g_NullAction
   use mapl_ErrorHandling
   use gftl2_StringVector
   implicit none
   private

   public :: AttributesAspect


   type, extends(StateItemAspect) :: AttributesAspect
!#      private
      type(StringVector) :: attribute_names
   contains
      procedure :: matches
      procedure :: supports_conversion_general
      procedure :: supports_conversion_specific
      procedure :: make_action
   end type AttributesAspect

   interface AttributesAspect
      procedure new_AttributesAspect
   end interface

contains

   ! Time dependent ungridded_dims is not supported.
   function new_AttributesAspect(attribute_names) result(aspect)
      type(AttributesAspect) :: aspect
      type(StringVector), optional, intent(in) :: attribute_names

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

   end function new_AttributesAspect

   logical function supports_conversion_general(src)
      class(AttributesAspect), intent(in) :: src
      supports_conversion_general = .false.
   end function supports_conversion_general

   logical function supports_conversion_specific(src, dst)
      class(AttributesAspect), intent(in) :: src
      class(StateItemAspect), intent(in) :: dst
      supports_conversion_specific = .false.
   end function supports_conversion_specific

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

      select type(dst)
      class is (AttributesAspect)
         matches = includes(src%attribute_names, dst%attribute_names)
      class default
         matches = .false.
      end select

   contains

      logical function includes(provided_names, mandatory_names)
         type(StringVector), target, intent(in) :: provided_names
         type(StringVector), target, intent(in) :: mandatory_names

         integer :: i, j
         character(:), pointer :: attr_name

         m: do i = 1, mandatory_names%size()
            attr_name => mandatory_names%of(i)
            p: do j = 1, provided_names%size()
               if (attr_name == provided_names%of(j)) cycle m ! good
            end do p
            ! ith not found
            includes = .false.
            return
         end do m
         
         includes = .true.

      end function includes

   end function matches

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

      action = NullAction()

      _RETURN(_SUCCESS)
   end function make_action

end module mapl3g_AttributesAspect