get_variable_attribute Function

public function get_variable_attribute(this, var_name, attr_name, rc) result(units)

Type Bound

FileMetadataUtils

Arguments

Type IntentOptional Attributes Name
class(FileMetadataUtils), intent(inout) :: this
character(len=*), intent(in) :: var_name
character(len=*), intent(in) :: attr_name
integer, intent(out), optional :: rc

Return Value character(len=:), pointer


Calls

proc~~get_variable_attribute~~CallsGraph proc~get_variable_attribute FileMetadataUtils%get_variable_attribute interface~mapl_assert MAPL_Assert proc~get_variable_attribute->interface~mapl_assert none~get_attribute Variable%get_attribute proc~get_variable_attribute->none~get_attribute none~get_value UnlimitedEntity%get_value proc~get_variable_attribute->none~get_value none~get_variable FileMetadata%get_variable proc~get_variable_attribute->none~get_variable none~is_attribute_present Variable%is_attribute_present proc~get_variable_attribute->none~is_attribute_present proc~get_file_name FileMetadataUtils%get_file_name proc~get_variable_attribute->proc~get_file_name proc~mapl_return MAPL_Return proc~get_variable_attribute->proc~mapl_return proc~mapl_verify MAPL_Verify proc~get_variable_attribute->proc~mapl_verify none~get_attribute->interface~mapl_assert none~get_attribute->proc~mapl_return none~at~226 StringAttributeMap%at none~get_attribute->none~at~226 none~get_value->proc~mapl_return none~get_variable->proc~mapl_return none~at~139 StringVariableMap%at none~get_variable->none~at~139 none~is_attribute_present->proc~mapl_return none~is_attribute_present->none~at~226 proc~get_file_name->proc~mapl_return at at 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 none~find~35 StringVariableMap%find none~at~139->none~find~35 none~find~59 StringAttributeMap%find none~at~226->none~find~59

Called by

proc~~get_variable_attribute~~CalledByGraph proc~get_variable_attribute FileMetadataUtils%get_variable_attribute proc~get_level_name FileMetadataUtils%get_level_name proc~get_level_name->proc~get_variable_attribute proc~create_grid~2 regrid_support%create_grid proc~create_grid~2->proc~get_level_name proc~get_file_levels get_file_levels proc~get_file_levels->proc~get_level_name proc~get_file_levels~2 get_file_levels proc~get_file_levels~2->proc~get_level_name proc~mapl_create_bundle_from_metdata_id MAPL_create_bundle_from_metdata_id proc~mapl_create_bundle_from_metdata_id->proc~get_level_name program~time_ave time_ave program~time_ave->proc~get_level_name program~time_ave->proc~get_file_levels proc~mapl_read_bundle MAPL_read_bundle program~time_ave->proc~mapl_read_bundle proc~main~2 main proc~main~2->proc~get_file_levels~2 proc~main~2->proc~mapl_read_bundle proc~process_command_line~3 regrid_support%process_command_line proc~main~2->proc~process_command_line~3 proc~mapl_read_bundle->proc~mapl_create_bundle_from_metdata_id proc~process_command_line~3->proc~create_grid~2 program~regrid_util Regrid_Util program~regrid_util->proc~main~2 program~ut_regridding ut_ReGridding program~ut_regridding->proc~mapl_read_bundle

Source Code

   function get_variable_attribute(this,var_name,attr_name,rc) result(units)
      class (FileMetadataUtils), intent(inout) :: this
      character(len=*), intent(in) :: var_name
      character(len=*), intent(in) :: attr_name
      integer, optional, intent(out) :: rc
      character(:), allocatable :: fname
      character(len=:), pointer :: units 
      type(Attribute), pointer :: attr => null()
      class(Variable), pointer :: var => null()
      class(*), pointer :: vunits
      logical :: isPresent
      integer :: status
    
      fname = this%get_file_name(_RC)
      var => this%get_variable(var_name,rc=status)
      _VERIFY(status)
      isPresent = var%is_attribute_present(trim(attr_name))
      if (isPresent) then
         attr => var%get_attribute(trim(attr_name))
         vunits => attr%get_value()
         select type(vunits)
         type is (character(*))
            units => vunits
         class default
            _FAIL('units must be string for '//var_name//' in '//fname)
         end select
      else
         units => null()
      end if
      _RETURN(_SUCCESS)

   end function get_variable_attribute