UngriddedDim.F90 Source File


This file depends on

sourcefile~~ungriddeddim.f90~~EfferentGraph sourcefile~ungriddeddim.f90 UngriddedDim.F90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~ungriddeddim.f90->sourcefile~errorhandling.f90 sourcefile~lu_bound.f90 LU_Bound.F90 sourcefile~ungriddeddim.f90->sourcefile~lu_bound.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90

Files dependent on this one

sourcefile~~ungriddeddim.f90~~AfferentGraph sourcefile~ungriddeddim.f90 UngriddedDim.F90 sourcefile~componentspecparser.f90 ComponentSpecParser.F90 sourcefile~componentspecparser.f90->sourcefile~ungriddeddim.f90 sourcefile~ungriddeddims.f90 UngriddedDims.F90 sourcefile~componentspecparser.f90->sourcefile~ungriddeddims.f90 sourcefile~outputinfo.f90 OutputInfo.F90 sourcefile~outputinfo.f90->sourcefile~ungriddeddim.f90 sourcefile~outputinfo.f90->sourcefile~ungriddeddims.f90 sourcefile~ungriddeddimvector.f90 UngriddedDimVector.F90 sourcefile~outputinfo.f90->sourcefile~ungriddeddimvector.f90 sourcefile~sharedio.f90 SharedIO.F90 sourcefile~sharedio.f90->sourcefile~ungriddeddim.f90 sourcefile~sharedio.f90->sourcefile~outputinfo.f90 sourcefile~sharedio.f90->sourcefile~ungriddeddims.f90 sourcefile~test_fieldinfo.pf Test_FieldInfo.pf sourcefile~test_fieldinfo.pf->sourcefile~ungriddeddim.f90 sourcefile~test_fieldinfo.pf->sourcefile~ungriddeddims.f90 sourcefile~test_fieldspec.pf Test_FieldSpec.pf sourcefile~test_fieldspec.pf->sourcefile~ungriddeddim.f90 sourcefile~test_fieldspec.pf->sourcefile~ungriddeddims.f90 sourcefile~test_fieldspec.pf->sourcefile~ungriddeddimvector.f90 sourcefile~test_outputinfo.pf Test_OutputInfo.pf sourcefile~test_outputinfo.pf->sourcefile~ungriddeddim.f90 sourcefile~test_outputinfo.pf->sourcefile~outputinfo.f90 sourcefile~test_outputinfo.pf->sourcefile~ungriddeddimvector.f90 sourcefile~test_sharedio.pf Test_SharedIO.pf sourcefile~test_sharedio.pf->sourcefile~ungriddeddim.f90 sourcefile~test_sharedio.pf->sourcefile~sharedio.f90 sourcefile~test_sharedio.pf->sourcefile~ungriddeddims.f90 sourcefile~ungriddeddims.f90->sourcefile~ungriddeddim.f90 sourcefile~ungriddeddims.f90->sourcefile~ungriddeddimvector.f90 sourcefile~ungriddeddimvector.f90->sourcefile~ungriddeddim.f90 sourcefile~add_child_by_name.f90 add_child_by_name.F90 sourcefile~add_child_by_name.f90->sourcefile~componentspecparser.f90 sourcefile~fieldspec.f90~2 FieldSpec.F90 sourcefile~fieldspec.f90~2->sourcefile~ungriddeddims.f90 sourcefile~generic3g.f90 Generic3g.F90 sourcefile~generic3g.f90->sourcefile~outputinfo.f90 sourcefile~geom_pfio.f90 Geom_PFIO.F90 sourcefile~geom_pfio.f90->sourcefile~sharedio.f90 sourcefile~geomio.f90 GeomIO.F90 sourcefile~geomio.f90->sourcefile~sharedio.f90 sourcefile~grid_pfio.f90 Grid_PFIO.F90 sourcefile~grid_pfio.f90->sourcefile~sharedio.f90 sourcefile~historycollectiongridcomp_private.f90 HistoryCollectionGridComp_private.F90 sourcefile~historycollectiongridcomp_private.f90->sourcefile~outputinfo.f90 sourcefile~historycollectiongridcomp_private.f90->sourcefile~ungriddeddims.f90 sourcefile~mapl_generic.f90~2 MAPL_Generic.F90 sourcefile~mapl_generic.f90~2->sourcefile~ungriddeddims.f90 sourcefile~modelverticalgrid.f90 ModelVerticalGrid.F90 sourcefile~modelverticalgrid.f90->sourcefile~ungriddeddims.f90 sourcefile~parse_child.f90 parse_child.F90 sourcefile~parse_child.f90->sourcefile~componentspecparser.f90 sourcefile~parse_children.f90 parse_children.F90 sourcefile~parse_children.f90->sourcefile~componentspecparser.f90 sourcefile~parse_component_spec.f90 parse_component_spec.F90 sourcefile~parse_component_spec.f90->sourcefile~componentspecparser.f90 sourcefile~parse_connections.f90 parse_connections.F90 sourcefile~parse_connections.f90->sourcefile~componentspecparser.f90 sourcefile~parse_geometry_spec.f90 parse_geometry_spec.F90 sourcefile~parse_geometry_spec.f90->sourcefile~componentspecparser.f90 sourcefile~parse_setservices.f90 parse_setservices.F90 sourcefile~parse_setservices.f90->sourcefile~componentspecparser.f90 sourcefile~parse_var_specs.f90 parse_var_specs.F90 sourcefile~parse_var_specs.f90->sourcefile~componentspecparser.f90 sourcefile~restarthandler.f90 RestartHandler.F90 sourcefile~restarthandler.f90->sourcefile~sharedio.f90 sourcefile~setservices.f90 SetServices.F90 sourcefile~setservices.f90->sourcefile~componentspecparser.f90 sourcefile~test_addfieldspec.pf Test_AddFieldSpec.pf sourcefile~test_addfieldspec.pf->sourcefile~ungriddeddims.f90 sourcefile~test_bracketspec.pf Test_BracketSpec.pf sourcefile~test_bracketspec.pf->sourcefile~ungriddeddims.f90 sourcefile~test_componentspecparser.pf Test_ComponentSpecParser.pf sourcefile~test_componentspecparser.pf->sourcefile~componentspecparser.f90 sourcefile~variablespec.f90 VariableSpec.F90 sourcefile~variablespec.f90->sourcefile~ungriddeddims.f90

Source Code

#include "MAPL_Generic.h"
module mapl3g_UngriddedDim
   use mapl3g_LU_Bound
   use mapl_ErrorHandling
   use esmf, only: ESMF_Info
   use esmf, only: ESMF_InfoCreate
   use esmf, only: ESMF_InfoSet
   implicit none
   private

   public :: UngriddedDim
   public :: operator(==)
   public :: operator(/=)

   type :: UngriddedDim
      private
      character(:), allocatable :: name
      character(:), allocatable :: units
      real, allocatable :: coordinates(:)
   contains
      procedure :: get_extent
      procedure :: get_name
      procedure :: get_units
      procedure :: get_coordinates
      procedure :: get_bounds
      procedure :: make_info
   end type UngriddedDim

   interface UngriddedDim
      module procedure new_UngriddedDim_extent
      module procedure new_UngriddedDim_coordinates
   end interface UngriddedDim

   interface operator(==)
      module procedure equal_to
   end interface operator(==)

   interface operator(/=)
      module procedure not_equal_to
   end interface operator(/=)

   character(*), parameter :: UNKNOWN_DIM_NAME = 'NONE'
   character(*), parameter :: UNKNOWN_DIM_UNITS = 'NONE'

contains


   pure function new_UngriddedDim_extent(extent, name, units) result(spec)
      integer, intent(in) :: extent
      character(len=*), optional, intent(in) :: name
      character(len=*), optional, intent(in) :: units
      type(UngriddedDim) :: spec

      spec%name = UNKNOWN_DIM_NAME
      if (present(name)) spec%name = name
      spec%units = UNKNOWN_DIM_UNITS
      if (present(units)) spec%units = units
      spec%coordinates = default_coords(extent)

   end function new_UngriddedDim_extent

   pure function new_UngriddedDim_coordinates(coordinates, name, units) result(spec)
      real, intent(in) :: coordinates(:)
      character(len=*), optional, intent(in) :: name
      character(len=*), optional, intent(in) :: units
      type(UngriddedDim) :: spec

      spec%name = UNKNOWN_DIM_NAME
      if (present(name)) spec%name = name
      spec%units = UNKNOWN_DIM_UNITS
      if (present(units)) spec%units = units
      spec%coordinates = coordinates

   end function new_UngriddedDim_coordinates

   pure function default_coords(extent, lbound) result(coords)
      real, allocatable :: coords(:)
      integer, intent(in) :: extent
      integer, optional, intent(in) :: lbound

      integer :: i
      integer :: lbound_

      lbound_ = 1
      if (present(lbound)) lbound_ = lbound

      ! 10 levels lbound of 1:  [1,...,10]
      ! 10 levels lbound of 0:  [0,..., 9]
      coords = [(i, i=lbound_, lbound_ + extent - 1)]

   end function default_coords


   pure integer function get_extent(this) result(extent)
      class(UngriddedDim), intent(in) :: this
      extent = size(this%coordinates)
   end function get_extent


   pure function get_name(this) result(name)
      character(:), allocatable :: name
      class(UngriddedDim), intent(in) :: this
      name = this%name
   end function get_name


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


   pure function get_coordinates(this) result(coordinates)
      real, allocatable :: coordinates(:)
      class(UngriddedDim), intent(in) :: this
      coordinates = this%coordinates
   end function get_coordinates


   pure function get_bounds(this) result(bound)
      type(LU_Bound) :: bound
      class(UngriddedDim), intent(in) :: this
      bound%lower = 1
      bound%upper = size(this%coordinates)
   end function get_bounds


   pure logical function equal_to(a, b)
      class(UngriddedDim), intent(in) :: a
      class(UngriddedDim), intent(in) :: b

      equal_to = &
           same_type_as(a, b) .and. &
           (a%name == b%name) .and. &
           (a%units == b%units) .and. &
           all(a%coordinates == b%coordinates)

   end function equal_to


   pure logical function not_equal_to(a, b)
      type(UngriddedDim), intent(in) :: a
      type(UngriddedDim), intent(in) :: b

      not_equal_to = .not. (a == b)

   end function not_equal_to

   function make_info(this, rc) result(info)
      type(ESMF_Info) :: info
      class(UngriddedDim), intent(in) :: this
      integer, optional, intent(out) :: rc

      integer :: status

      info = ESMF_InfoCreate(_RC)
      if (allocated(this%name)) then
         call ESMF_InfoSet(info, key='name', value=this%name, _RC)
      end if
      if (allocated(this%units)) then
         call ESMF_InfoSet(info, key='units', value=this%units, _RC)
      end if
      call ESMF_InfoSet(info, key='coordinates', values=this%coordinates, _RC)

      _RETURN(_SUCCESS)
   end function make_info

end module mapl3g_UngriddedDim