MAPL_IOCountLevels Subroutine

public subroutine MAPL_IOCountLevels(cf, nlev, rc)

Arguments

Type IntentOptional Attributes Name
type(FileMetadata), intent(inout) :: cf
integer, intent(out) :: nlev
integer, intent(out), optional :: rc

Calls

proc~~mapl_iocountlevels~~CallsGraph proc~mapl_iocountlevels MAPL_IOCountLevels at at proc~mapl_iocountlevels->at get_index get_index proc~mapl_iocountlevels->get_index none~begin~52 StringVariableMap%begin proc~mapl_iocountlevels->none~begin~52 none~get_dimension FileMetadata%get_dimension proc~mapl_iocountlevels->none~get_dimension none~get_dimensions~2 FileMetadata%get_dimensions proc~mapl_iocountlevels->none~get_dimensions~2 none~get_variables FileMetadata%get_variables proc~mapl_iocountlevels->none~get_variables none~key~117 StringVariableMapIterator%key proc~mapl_iocountlevels->none~key~117 none~next~48 StringVariableMapIterator%next proc~mapl_iocountlevels->none~next~48 proc~mapl_return MAPL_Return proc~mapl_iocountlevels->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_iocountlevels->proc~mapl_verify none~get_dimension->at none~get_dimension->proc~mapl_return find find none~get_dimension->find none~get_variables->proc~mapl_return proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception

Source Code

  subroutine MAPL_IOCountLevels(cf,nlev,rc)
  type(FileMetadata), intent(inout) :: cf
  integer, intent(out) :: nlev
  integer, intent(out), optional :: rc

  integer :: status
  type(StringVariableMap), pointer :: vars
  type(StringVariableMapIterator) :: iter
  type(StringIntegerMap), pointer :: dims
  integer, pointer :: dimsize => null()
  character(len=:), pointer :: name
  type(StringVector), pointer :: vdims
  type(Variable), pointer :: var
  integer :: levsize

  nlev = 0
  dims => cf%get_dimensions()
  vars => cf%get_variables()
  iter = vars%begin()
  do while(iter/=vars%end())

     name => iter%key()
     var => iter%value()
     dimsize => dims%at(trim(name))
     if (.not.associated(dimsize)) then
        vdims => var%get_dimensions()
        if (vdims%get_index('lev') /=0) then
           levsize = cf%get_dimension('lev',rc=status)
           _VERIFY(status)
           nlev=nlev+levsize
        else if (vdims%get_index('edge') /=0) then
           levsize = cf%get_dimension('edge',rc=status)
           _VERIFY(status)
           nlev=nlev+levsize
        else
           nlev=nlev+1
        end if
     end if
     if (associated(dimsize)) nullify(dimsize)

     call iter%next()
  end do

  _RETURN(ESMF_SUCCESS)

  end subroutine MAPL_IOCountLevels