MAPL_GridType.F90 Source File


Files dependent on this one

sourcefile~~mapl_gridtype.f90~~AfferentGraph sourcefile~mapl_gridtype.f90 MAPL_GridType.F90 sourcefile~mapl_gridspec.f90 MAPL_GridSpec.F90 sourcefile~mapl_gridspec.f90->sourcefile~mapl_gridtype.f90 sourcefile~mapl_identityregridder.f90 MAPL_IdentityRegridder.F90 sourcefile~mapl_identityregridder.f90->sourcefile~mapl_gridspec.f90 sourcefile~mapl_latlontolatlonregridder.f90 MAPL_LatLonToLatLonRegridder.F90 sourcefile~mapl_latlontolatlonregridder.f90->sourcefile~mapl_gridspec.f90 sourcefile~mapl_regriddermanager.f90 MAPL_RegridderManager.F90 sourcefile~mapl_regriddermanager.f90->sourcefile~mapl_identityregridder.f90 sourcefile~mapl_regriddermanager.f90->sourcefile~mapl_latlontolatlonregridder.f90 sourcefile~newregriddermanager.f90 NewRegridderManager.F90 sourcefile~newregriddermanager.f90->sourcefile~mapl_identityregridder.f90 sourcefile~base.f90 Base.F90 sourcefile~base.f90->sourcefile~mapl_regriddermanager.f90 sourcefile~base.f90->sourcefile~newregriddermanager.f90 sourcefile~griddedio.f90 GriddedIO.F90 sourcefile~griddedio.f90->sourcefile~newregriddermanager.f90 sourcefile~mapl_cfio.f90 MAPL_CFIO.F90 sourcefile~mapl_cfio.f90->sourcefile~mapl_regriddermanager.f90 sourcefile~mapl_cfio.f90->sourcefile~newregriddermanager.f90 sourcefile~mapl_epochswathmod.f90 MAPL_EpochSwathMod.F90 sourcefile~mapl_epochswathmod.f90->sourcefile~newregriddermanager.f90 sourcefile~regrid_util.f90 Regrid_Util.F90 sourcefile~regrid_util.f90->sourcefile~newregriddermanager.f90

Source Code

module MAPL_GridTypeMod
   implicit none
   private

   public :: GridType

   type :: GridType
      private
      character(len=:), allocatable :: name
   contains
      procedure :: equals
      procedure :: not_equals
      procedure :: less_than
      procedure :: greater_than_or_equal
      generic :: operator(<) => less_than
      generic :: operator(>=) => greater_than_or_equal
      generic :: operator(==) => equals
      generic :: operator(/=) => not_equals
   end type GridType

   interface GridType
      module procedure newGridType_name
      module procedure newGridType_mapl
   end interface GridType


contains


   function newGridType_name(name) result (grid_type)
      type (GridType) :: grid_type
      character(len=*), intent(in) :: name

      grid_type%name = name

   end function newGridType_name

   function newGridType_mapl(grid) result (grid_type)
      use ESMF
      type (GridType) :: grid_type
      type (ESMF_Grid), intent(in) :: grid

      character(len=60) :: name
      logical :: isPresent
      type(ESMF_Info) :: infoh

      call ESMF_InfoGetFromHost(grid,infoh)
      isPresent = ESMF_InfoIsPresent(infoh,'GridType')
      if (isPresent) then
         call ESMF_InfoGet(infoh,'GridType',name)

         grid_type%name = name
      end if

   end function newGridType_mapl


   logical function less_than(a, b)
      class (GridType), intent(in) :: a
      class (GridType), intent(in) :: b

      
      if (allocated(a%name)) then
         if (allocated(b%name)) then
            less_than = (a%name < b%name)
         else
            less_than = .true.
         end if
      else
         less_than = .false.
      end if

   end function less_than


   logical function greater_than_or_equal(a, b)
      class (GridType), intent(in) :: a
      class (GridType), intent(in) :: b

      greater_than_or_equal = .not. a%less_than(b)

   end function greater_than_or_equal


   logical function equals(a, b)
      class (GridType), intent(in) :: a
      class (GridType), intent(in) :: b

      
      if (allocated(a%name)) then
         if (allocated(b%name)) then
            equals = (a%name == b%name)
         else
            equals = .false.
         end if
      else
         equals = .false.
      end if

   end function equals


   logical function not_equals(a, b)
      class (GridType), intent(in) :: a
      class (GridType), intent(in) :: b

      not_equals = .not. (a == b)

   end function not_equals

end module MAPL_GridTypeMod