subroutine get_coordinate_info(this,coordinate_name,coordSize,coordUnits,long_name,standard_name,coords,coordinate_attr,rc)
class (FileMetadataUtils), intent(inout) :: this
character(len=*), intent(in) :: coordinate_name
integer, optional, intent(out) :: coordSize
character(len=*), optional, intent(out) :: coordUnits
character(len=*), optional, intent(out) :: long_name
character(len=*), optional, intent(out) :: standard_name
character(len=*), optional, intent(out) :: coordinate_attr
real, allocatable, optional, intent(inout) :: coords(:)
integer, optional, intent(out) :: rc
integer :: status
character(:), allocatable :: fname
class(CoordinateVariable), pointer :: var
type(Attribute), pointer :: attr
character(len=:), pointer :: vdim
class(*), pointer :: coordUnitPtr
class(*), pointer :: ptr(:)
fname = this%get_file_name(_RC)
var => this%get_coordinate_variable(trim(coordinate_name),rc=status)
_VERIFY(status)
if (present(coordSize)) then
vdim => var%get_ith_dimension(1)
coordSize = this%get_dimension(vdim,rc=status)
end if
if (present(coordUnits)) then
attr => var%get_attribute('units')
coordUnitPtr => attr%get_value()
select type(coordUnitPtr)
type is (character(*))
coordUnits = trim(coordUnitPtr)
class default
_FAIL(trim(coordinate_name)//' units must be string in '//fname)
end select
end if
if (present(long_name)) then
if (this%var_has_attr(coordinate_name,"long_name")) then
attr => var%get_attribute('long_name')
coordUnitPtr => attr%get_value()
select type(coordUnitPtr)
type is (character(*))
long_name = trim(coordUnitPtr)
class default
_FAIL(trim(coordinate_name)//' long_name must be string in '//fname)
end select
else
long_name = 'not found'
endif
end if
if (present(standard_name)) then
if (this%var_has_attr(coordinate_name,"standard_name")) then
attr => var%get_attribute('standard_name')
coordUnitPtr => attr%get_value()
select type(coordUnitPtr)
type is (character(*))
standard_name = trim(coordUnitPtr)
class default
_FAIL(trim(coordinate_name)//' standard_name must be string in '//fname)
end select
else
standard_name = 'not found'
endif
end if
if (present(coordinate_attr)) then
if (this%var_has_attr(coordinate_name,"coordinate")) then
attr => var%get_attribute('coordinate')
coordUnitPtr => attr%get_value()
select type(coordUnitPtr)
type is (character(*))
coordinate_attr = trim(coordUnitPtr)
class default
_FAIL(trim(coordinate_name)//' name must be string in '//fname)
end select
else
coordinate_attr = 'not found'
endif
end if
if (present(coords)) then
ptr => var%get_coordinate_data()
_ASSERT(associated(ptr),"coord variable coordinate data not found in "//fname)
select type (ptr)
type is (real(kind=REAL64))
coords=ptr
type is (real(kind=REAL32))
coords=ptr
type is (integer(kind=INT64))
coords=ptr
type is (integer(kind=INT32))
coords=ptr
class default
_FAIL("unsupported coordinate variable type in "//fname)
end select
end if
_RETURN(_SUCCESS)
end subroutine get_coordinate_info