static public Variable findVariableWithAttributeValue ( NetcdfDataset ds , String attName , String attValue ) { for ( Variable v : ds . getVariables ( ) ) { String haveValue = ds . findAttValueIgnoreCase ( v , attName , null ) ; if ( ( haveValue != null ) && haveValue . equals ( attValue ) ) return v ; } // descend into structures for ( Variable v : ds . getVariables ( ) ) { if ( v instanceof Structure ) { Variable vn = findVariableWithAttributeValue ( ( Structure ) v , attName , attValue ) ; if ( null != vn ) return vn ; } } return null ; }
Find first variable with given attribute name and value . If not found search one level into structures .