NCL Home >
Documentation >
Functions >
Metadata routines
getvaratts
Returns a list of attribute names for the given variable.
Prototype
function getvaratts ( var ) return_val [*] : string
Arguments
varAny NCL variable.
Description
This function returns a list of attribute names for a given NCL variable. If the variable has no attributes, then the default missing value for the type "string" is returned.
See Also
Examples
Example 1
f = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/Tstorm.cdf","r") reftime = f->reftime lat = f->lat print(getvaratts(reftime)) ; should be (/"units","long_name"/) print(getvaratts(lat)) ; should be a missing value
Example 2
This example pulls the global attributes off a file and prints out their values:
f = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/fice.nc","r") file_atts = getvaratts(f) print(file_atts) ; should be (/"TITLE","history"/) if(.not.any(ismissing(file_atts))) then do i=0,dimsizes(file_atts)-1 print("Attribute " + file_atts(i) + " = " + f@$file_atts(i)$) end do end if