VerticalDimSpec.F90 Source File


This file depends on

sourcefile~~verticaldimspec.f90~~EfferentGraph sourcefile~verticaldimspec.f90 VerticalDimSpec.F90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~verticaldimspec.f90->sourcefile~errorhandling.f90 sourcefile~mapl_esmf_infokeys.f90 MAPL_ESMF_InfoKeys.F90 sourcefile~verticaldimspec.f90->sourcefile~mapl_esmf_infokeys.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~mapl_esmf_infokeys.f90->sourcefile~errorhandling.f90

Files dependent on this one

sourcefile~~verticaldimspec.f90~~AfferentGraph sourcefile~verticaldimspec.f90 VerticalDimSpec.F90 sourcefile~basicverticalgrid.f90 BasicVerticalGrid.F90 sourcefile~basicverticalgrid.f90->sourcefile~verticaldimspec.f90 sourcefile~bracketspec.f90 BracketSpec.F90 sourcefile~bracketspec.f90->sourcefile~verticaldimspec.f90 sourcefile~componentspecparser.f90 ComponentSpecParser.F90 sourcefile~componentspecparser.f90->sourcefile~verticaldimspec.f90 sourcefile~fieldspec.f90 FieldSpec.F90 sourcefile~fieldspec.f90->sourcefile~verticaldimspec.f90 sourcefile~fixedlevelsverticalgrid.f90 FixedLevelsVerticalGrid.F90 sourcefile~fixedlevelsverticalgrid.f90->sourcefile~verticaldimspec.f90 sourcefile~generic3g.f90 Generic3g.F90 sourcefile~generic3g.f90->sourcefile~verticaldimspec.f90 sourcefile~mirrorverticalgrid.f90 MirrorVerticalGrid.F90 sourcefile~mirrorverticalgrid.f90->sourcefile~verticaldimspec.f90 sourcefile~modelverticalgrid.f90 ModelVerticalGrid.F90 sourcefile~modelverticalgrid.f90->sourcefile~verticaldimspec.f90 sourcefile~test_addfieldspec.pf Test_AddFieldSpec.pf sourcefile~test_addfieldspec.pf->sourcefile~verticaldimspec.f90 sourcefile~test_bracketspec.pf Test_BracketSpec.pf sourcefile~test_bracketspec.pf->sourcefile~verticaldimspec.f90 sourcefile~test_fieldspec.pf Test_FieldSpec.pf sourcefile~test_fieldspec.pf->sourcefile~verticaldimspec.f90 sourcefile~test_modelverticalgrid.pf Test_ModelVerticalGrid.pf sourcefile~test_modelverticalgrid.pf->sourcefile~verticaldimspec.f90 sourcefile~variablespec.f90 VariableSpec.F90 sourcefile~variablespec.f90->sourcefile~verticaldimspec.f90

Source Code

#include "MAPL_Generic.h"

module mapl3g_VerticalDimSpec
   use mapl3g_esmf_info_keys
   use esmf, only: ESMF_Info
   use esmf, only: ESMF_InfoCreate
   use esmf, only: ESMF_InfoSet
   use esmf, only: ESMF_MAXSTR
   use mapl_ErrorHandling

   implicit none
   private
  
   public :: VerticalDimSpec
  
   public :: VERTICAL_DIM_UNKNOWN
   public :: VERTICAL_DIM_NONE
   public :: VERTICAL_DIM_CENTER
   public :: VERTICAL_DIM_EDGE
   public :: VERTICAL_DIM_MIRROR

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

   type :: VerticalDimSpec
      private
      integer :: id = -1
   contains
      procedure :: make_info
      procedure :: write_formatted
      generic :: write(formatted) => write_formatted
   end type VerticalDimSpec

   type(VerticalDimSpec), parameter :: VERTICAL_DIM_UNKNOWN = VerticalDimSpec(-1)
   type(VerticalDimSpec), parameter :: VERTICAL_DIM_NONE = VerticalDimSpec(1)
   type(VerticalDimSpec), parameter :: VERTICAL_DIM_CENTER = VerticalDimSpec(2)
   type(VerticalDimSpec), parameter :: VERTICAL_DIM_EDGE = VerticalDimSpec(3)
   type(VerticalDimSpec), parameter :: VERTICAL_DIM_MIRROR = VerticalDimSpec(4)

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

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

   elemental logical function equal_to(a, b)
      type(VerticalDimSpec), intent(in) :: a, b
      equal_to = a%id == b%id
   end function equal_to

   subroutine write_formatted(this, unit, iotype, v_list, iostat, iomsg)
      class(VerticalDimSpec), intent(in) :: this
      integer, intent(in) :: unit
      character(*), intent(in) :: iotype
      integer, intent(in) :: v_list(:)
      integer, intent(out) :: iostat
      character(*), intent(inout) :: iomsg

      integer :: id
      character(len=ESMF_MAXSTR) :: dim_spec_str

      id = this%id
      select case(id)
      case(-1)
         dim_spec_str = "VERTICAL_DIM_UNKNOWN"
      case(1)
         dim_spec_str = "VERTICAL_DIM_NONE"
      case(2)
         dim_spec_str = "VERTICAL_DIM_CENTER"
      case(3)
         dim_spec_str = "VERTICAL_DIM_EDGE"
      case(4)
         dim_spec_str = "VERTICAL_DIM_MIRROR"
      ! case default
      !    _FAIL("Invalid vertical dim spec")
      end select
      write(unit, '("VerticalDimSpec(",a,")")', iostat=iostat, iomsg=iomsg) trim(dim_spec_str)

      _UNUSED_DUMMY(iotype)
      _UNUSED_DUMMY(v_list)
   end subroutine write_formatted

   elemental logical function not_equal_to(a, b)
      type(VerticalDimSpec), intent(in) :: a, b
      not_equal_to = .not. (a == b)
   end function not_equal_to

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

      integer :: status

      info = ESMF_InfoCreate(_RC)
      select case (this%id)
      case (VERTICAL_DIM_NONE%id)
         call ESMF_InfoSet(info, key='vloc', value='VERTICAL_DIM_NONE', _RC)
      case (VERTICAL_DIM_CENTER%id)
         call ESMF_InfoSet(info, key='vloc', value='VERTICAL_DIM_CENTER', _RC)
      case (VERTICAL_DIM_EDGE%id)
         call ESMF_InfoSet(info, key='vloc', value='VERTICAL_DIM_EDGE', _RC)
      case default
         _FAIL('unsupported vertical dim spec')
      end select

      _RETURN(_SUCCESS)
   end function make_info
   
end module mapl3g_VerticalDimSpec