FieldDictionaryItem.F90 Source File


Files dependent on this one

sourcefile~~fielddictionaryitem.f90~~AfferentGraph sourcefile~fielddictionaryitem.f90 FieldDictionaryItem.F90 sourcefile~fielddictionary.f90 FieldDictionary.F90 sourcefile~fielddictionary.f90->sourcefile~fielddictionaryitem.f90 sourcefile~fielddictionaryitemmap.f90 FieldDictionaryItemMap.F90 sourcefile~fielddictionary.f90->sourcefile~fielddictionaryitemmap.f90 sourcefile~fielddictionaryitemmap.f90->sourcefile~fielddictionaryitem.f90 sourcefile~test_fielddictionary.pf Test_FieldDictionary.pf sourcefile~test_fielddictionary.pf->sourcefile~fielddictionaryitem.f90 sourcefile~test_fielddictionary.pf->sourcefile~fielddictionary.f90 sourcefile~fieldspec.f90 FieldSpec.F90 sourcefile~fieldspec.f90->sourcefile~fielddictionary.f90 sourcefile~variablespec.f90 VariableSpec.F90 sourcefile~fieldspec.f90->sourcefile~variablespec.f90 sourcefile~variablespec.f90->sourcefile~fielddictionary.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~make_itemspec.f90 make_itemSpec.F90 sourcefile~make_itemspec.f90->sourcefile~fieldspec.f90 sourcefile~make_itemspec.f90->sourcefile~variablespec.f90 sourcefile~mapl_generic.f90 MAPL_Generic.F90 sourcefile~mapl_generic.f90->sourcefile~variablespec.f90 sourcefile~mockitemspec.f90 MockItemSpec.F90 sourcefile~mockitemspec.f90->sourcefile~variablespec.f90 sourcefile~modelverticalgrid.f90 ModelVerticalGrid.F90 sourcefile~modelverticalgrid.f90->sourcefile~fieldspec.f90 sourcefile~outermetacomponent.f90 OuterMetaComponent.F90 sourcefile~outermetacomponent.f90->sourcefile~variablespec.f90 sourcefile~servicespec.f90 ServiceSpec.F90 sourcefile~servicespec.f90->sourcefile~variablespec.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~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

Source Code

module mapl3g_FieldDictionaryItem

   use gftl2_StringVector
   use esmf

   implicit none
   private

   public :: FieldDictionaryItem

   type :: FieldDictionaryItem
      private
      character(:), allocatable :: long_name
      character(:), allocatable :: canonical_units
      type(ESMF_RegridMethod_Flag) :: regrid_method
      type(StringVector) :: aliases
!!$      character(:), allocatable :: physical_dimensions
   contains
      procedure :: get_long_name
      procedure :: get_units
      procedure :: get_aliases
      procedure :: get_regrid_method
   end type FieldDictionaryItem

   !************************
   ! Caution:  Multiple constructor arguments are strings, and
   ! as such incorrect order is a potential source of error
   ! in client code.
   !************************
   
   interface FieldDictionaryItem
      module procedure new_FieldDictionaryItem_
      module procedure new_FieldDictionaryItem_one_alias
      module procedure new_FieldDictionaryItem_multi_aliases
      module procedure new_FieldDictionaryItem_vector
   end interface

contains

   function new_FieldDictionaryItem_(long_name, canonical_units) result(item)
      type(FieldDictionaryItem) :: item
      character(*), intent(in) :: long_name
      character(*), intent(in) :: canonical_units

      item = FieldDictionaryItem(long_name, canonical_units, [character(1) ::])

   end function new_FieldDictionaryItem_

   function new_FieldDictionaryItem_one_alias(long_name, canonical_units, alias) result(item)
      type(FieldDictionaryItem) :: item
      character(*), intent(in) :: long_name
      character(*), intent(in) :: canonical_units
      character(*), intent(in) :: alias

      item = FieldDictionaryItem(long_name, canonical_units, [alias])

   end function new_FieldDictionaryItem_one_alias

   function new_FieldDictionaryItem_multi_aliases(long_name, canonical_units, aliases) result(item)
      type(FieldDictionaryItem) :: item
      character(*), intent(in) :: long_name
      character(*), intent(in) :: canonical_units
      character(*), intent(in) :: aliases(:)

      integer :: i
      type(StringVector) :: aliases_vector

      do i = 1, size(aliases)
         call aliases_vector%push_back(trim(aliases(i)))
      end do

      item = FieldDictionaryItem(long_name, canonical_units, aliases_vector)
      
   end function new_FieldDictionaryItem_multi_aliases

   function new_FieldDictionaryItem_vector(long_name, canonical_units, aliases) result(item)
      type(FieldDictionaryItem) :: item
      character(*), intent(in) :: long_name
      character(*), intent(in) :: canonical_units
      type(StringVector), intent(in) :: aliases

      item%long_name = long_name
      item%canonical_units = canonical_units
      item%regrid_method = ESMF_REGRIDMETHOD_BILINEAR
      item%aliases = aliases
      
   end function new_FieldDictionaryItem_vector

   ! accessors

   pure function get_long_name(this) result(long_name)
      character(len=:), allocatable :: long_name
      class(FieldDictionaryItem), intent(in) :: this
      long_name = this%long_name
   end function get_long_name

   pure function get_units(this) result(units)
      character(len=:), allocatable :: units
      class(FieldDictionaryItem), intent(in) :: this
      units = this%canonical_units
   end function get_units

   pure function get_aliases(this) result(aliases)
      type(StringVector) :: aliases
      class(FieldDictionaryItem), intent(in) :: this
      aliases = this%aliases
   end function get_aliases

   pure function get_regrid_method(this) result(regrid_method)
      type(ESMF_RegridMethod_Flag) :: regrid_method
      class(FieldDictionaryItem), intent(in) :: this
      regrid_method = this%regrid_method
   end function get_regrid_method

end module mapl3g_FieldDictionaryItem