UnitsAspect.F90 Source File


This file depends on

sourcefile~~unitsaspect.f90~~EfferentGraph sourcefile~unitsaspect.f90 UnitsAspect.F90 sourcefile~convertunitsaction.f90 ConvertUnitsAction.F90 sourcefile~unitsaspect.f90->sourcefile~convertunitsaction.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~unitsaspect.f90->sourcefile~errorhandling.f90 sourcefile~extensionaction.f90 ExtensionAction.F90 sourcefile~unitsaspect.f90->sourcefile~extensionaction.f90 sourcefile~nullaction.f90 NullAction.F90 sourcefile~unitsaspect.f90->sourcefile~nullaction.f90 sourcefile~stateitemaspect.f90 StateItemAspect.F90 sourcefile~unitsaspect.f90->sourcefile~stateitemaspect.f90 sourcefile~udunits2f.f90 udunits2f.F90 sourcefile~unitsaspect.f90->sourcefile~udunits2f.f90 sourcefile~convertunitsaction.f90->sourcefile~errorhandling.f90 sourcefile~convertunitsaction.f90->sourcefile~extensionaction.f90 sourcefile~convertunitsaction.f90->sourcefile~udunits2f.f90 sourcefile~fieldutils.f90 FieldUtils.F90 sourcefile~convertunitsaction.f90->sourcefile~fieldutils.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 sourcefile~interfaces.f90 interfaces.F90 sourcefile~udunits2f.f90->sourcefile~interfaces.f90 sourcefile~status_codes.f90 status_codes.F90 sourcefile~udunits2f.f90->sourcefile~status_codes.f90 sourcefile~udsystem.f90 UDSystem.F90 sourcefile~udunits2f.f90->sourcefile~udsystem.f90 sourcefile~fieldbinaryoperations.f90 FieldBinaryOperations.F90 sourcefile~fieldutils.f90->sourcefile~fieldbinaryoperations.f90 sourcefile~fieldblas.f90 FieldBLAS.F90 sourcefile~fieldutils.f90->sourcefile~fieldblas.f90 sourcefile~fieldpointerutilities.f90 FieldPointerUtilities.F90 sourcefile~fieldutils.f90->sourcefile~fieldpointerutilities.f90 sourcefile~fieldunaryfunctions.f90 FieldUnaryFunctions.F90 sourcefile~fieldutils.f90->sourcefile~fieldunaryfunctions.f90 sourcefile~fieldutilities.f90 FieldUtilities.F90 sourcefile~fieldutils.f90->sourcefile~fieldutilities.f90 sourcefile~interfaces.f90->sourcefile~status_codes.f90 sourcefile~udsystem.f90->sourcefile~interfaces.f90 sourcefile~udsystem.f90->sourcefile~status_codes.f90 sourcefile~cptrwrapper.f90 CptrWrapper.F90 sourcefile~udsystem.f90->sourcefile~cptrwrapper.f90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~udsystem.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~fieldbinaryoperations.f90->sourcefile~fieldpointerutilities.f90 sourcefile~fieldbinaryoperations.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~fieldblas.f90->sourcefile~fieldpointerutilities.f90 sourcefile~fieldblas.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~fieldpointerutilities.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~fieldunaryfunctions.f90->sourcefile~fieldpointerutilities.f90 sourcefile~fieldunaryfunctions.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~fieldutilities.f90->sourcefile~errorhandling.f90 sourcefile~fieldutilities.f90->sourcefile~fieldpointerutilities.f90 sourcefile~fieldinfo.f90 FieldInfo.F90 sourcefile~fieldutilities.f90->sourcefile~fieldinfo.f90 sourcefile~infoutilities.f90 InfoUtilities.F90 sourcefile~fieldutilities.f90->sourcefile~infoutilities.f90 sourcefile~keywordenforcer.f90 KeywordEnforcer.F90 sourcefile~fieldutilities.f90->sourcefile~keywordenforcer.f90 sourcefile~lu_bound.f90 LU_Bound.F90 sourcefile~fieldutilities.f90->sourcefile~lu_bound.f90 sourcefile~ungriddeddims.f90 UngriddedDims.F90 sourcefile~fieldutilities.f90->sourcefile~ungriddeddims.f90 sourcefile~mapl_exceptionhandling.f90->sourcefile~errorhandling.f90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_throw.f90

Files dependent on this one

sourcefile~~unitsaspect.f90~~AfferentGraph sourcefile~unitsaspect.f90 UnitsAspect.F90 sourcefile~aspectcollection.f90 AspectCollection.F90 sourcefile~aspectcollection.f90->sourcefile~unitsaspect.f90 sourcefile~fieldspec.f90 FieldSpec.F90 sourcefile~fieldspec.f90->sourcefile~unitsaspect.f90 sourcefile~fieldspec.f90->sourcefile~aspectcollection.f90 sourcefile~variablespec.f90 VariableSpec.F90 sourcefile~fieldspec.f90->sourcefile~variablespec.f90 sourcefile~mockitemspec.f90 MockItemSpec.F90 sourcefile~mockitemspec.f90->sourcefile~unitsaspect.f90 sourcefile~mockitemspec.f90->sourcefile~aspectcollection.f90 sourcefile~mockitemspec.f90->sourcefile~variablespec.f90 sourcefile~variablespec.f90->sourcefile~unitsaspect.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~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_baseitemspec.pf Test_BaseItemSpec.pf sourcefile~test_baseitemspec.pf->sourcefile~mockitemspec.f90 sourcefile~test_bracketspec.pf Test_BracketSpec.pf sourcefile~test_bracketspec.pf->sourcefile~fieldspec.f90 sourcefile~test_extensionfamily.pf Test_ExtensionFamily.pf sourcefile~test_extensionfamily.pf->sourcefile~mockitemspec.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~test_stateregistry.pf Test_StateRegistry.pf sourcefile~test_stateregistry.pf->sourcefile~mockitemspec.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_UnitsAspect
   use mapl3g_StateItemAspect
   use mapl3g_ExtensionAction
   use mapl3g_ConvertUnitsAction
   use mapl3g_NullAction
   use mapl_ErrorHandling
   use udunits2f, only: are_convertible
   implicit none
   private

   public :: UnitsAspect


   type, extends(StateItemAspect) :: UnitsAspect
!#      private
      character(:), allocatable :: units
   contains
      procedure :: matches
      procedure :: supports_conversion_general
      procedure :: supports_conversion_specific
      procedure :: make_action
   end type UnitsAspect

   interface UnitsAspect
      procedure new_UnitsAspect
   end interface

contains

   function new_UnitsAspect(units, is_time_dependent) result(aspect)
      type(UnitsAspect) :: aspect
      character(*), optional, intent(in) :: units
      logical, optional, intent(in) :: is_time_dependent

      call aspect%set_mirror(.true.)
      if (present(units)) then
         aspect%units = units
         call aspect%set_mirror(.false.)
      end if
      call aspect%set_mirror(is_time_dependent)

   end function new_UnitsAspect

   logical function supports_conversion_general(src)
      class(UnitsAspect), intent(in) :: src
      supports_conversion_general = .true.
   end function supports_conversion_general

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

      integer :: ignore

      select type (dst)
      class is (UnitsAspect)
         supports_conversion_specific = .true.
         if (src%units == dst%units) return ! allow silly units so long as they are the same
         supports_conversion_specific = are_convertible(src%units, dst%units, rc=ignore)
      class default
         supports_conversion_specific = .false.
      end select

   end function supports_conversion_specific

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

      select type(dst)
      class is (UnitsAspect)
         matches = (src%units == dst%units)
      class default
         matches = .false.
      end select

   end function matches

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

      integer :: status

      select type (dst)
      class is (UnitsAspect)
         ! gfortran ugh
!#         action = ConvertUnitsAction(src%units, dst%units)
         allocate(action, source=ConvertUnitsAction(src%units, dst%units))
      class default
         allocate(action, source=NullAction())
         _FAIL('UnitsApsect cannot convert from other supclass.')
      end select

      _RETURN(_SUCCESS)
   end function make_action

end module mapl3g_UnitsAspect