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.
Hi Mike, You can use just use the NULL test and not bother with the is_valid() method for returns from get_dim(), get_var(), and get_att() methods. The purpose of the is_valid() method is to provide a way to handle the situation where you get an attribute, for example, close the file (which calls destructors for the dimensions and variables but not for the attributes), and then hand off the attribute to some other method. If the underlying file is no longer open, is_valid() will return false, because setting the value of the attribute will no longer change its value in the file. So the attribute might not be NULL, but is_valid() would return false. Use of the is_valid() method is an artifact of the lack of exceptions in most C++ compilers when the netCDF C++ interface was first written and the fact that constructors are not allowed to fail. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: GQK-400775 Department: Support netCDF Priority: Normal Status: Closed