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.
>Keywords: 199503021330.AA14268 Hi Mechthild, > how can I get the names and values of the attributes in a netCDF-file > - -if I know only the ncid- using the C-Interface? There is a section in the User's Guide named "Reading a netCDF File with Unknown Names" that describes the sequence of calls. For example if you wanted only the global attributes, you would call ncinquire to find out how many there were, and then call ncattinq and ncattget in a loop to get the name, type, length, and value of each attribute. To get information about global attributes, you use the same interface as for variable attributes, except that you use NC_GLOBAL instead of the variable ID. For an example of how this is done, you can look at the source code for the ncdump program, which determines everything about a netCDF file using only the C interface. ______________________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden P.O. Box 3000 http://www.unidata.ucar.edu/ Boulder, CO 80307-3000 ______________________________________________________________________________