This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Bob, > This is a clarification to your e-mail regarding > the confusion over the generation of lines such as: > > float latitude(latitude); > int woce_date(woce_date); > char pcode(pcode_no, strlen10); > float temperature(time,pressure, latitude,longitude); > > In my question I should have said that the above lines were > from a generation of CDL from an existing binary netCDF file by "ncdump", > and, that I am attempting to do this in a Java program. I have > done this by the command "System.out.println( nc )", but I would like > to know how this can be done by individul Java commands. OK, thanks, now I understand the question. Assume you have a ucar.netcdf.Variable ncvar that you got from the getVariableIterator() method of NetcdfFile, for example. To get its type, use ncvar.getComponentType() which returns a Class whose toString() method can be used for the type string. To get its dimensions, use a dimension iterator: ucar.netcdf.DimensionIterator iter=ncvar.getDimensionIterator(); To get the name for each dimension, use its getName() method: iter.next().getName() This is all done in a private method in the source for ucar.nc2.Variable: private void getFullNameN(StringBuffer buf) { buf.append(ncvar.getComponentType()); buf.append(" "); buf.append(ncvar.getName()); buf.append("("); ucar.netcdf.DimensionIterator iter=ncvar.getDimensionIterator(); while( iter.hasNext()) { buf.append( iter.next().getName() ); if(!iter.hasNext()) break; buf.append(","); } buf.append(")"); } --Russ