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.
> From: Leigh Angus <address@hidden> > Subject: file descriptors... > To: address@hidden Hi Leigh, > My name is Leigh Angus and I'm a meteorologist/programmer with the > Cooperative Institute for Research in the Atmosphere (CIRA) working > with the NOAA Forecast System Lab here in Boulder. I > have a quick question for you regarding the C++ implementation of > netCDF. > > > Can I retrieve the file descriptor of an open netCDF data file that > was opened as a result of my instantiating an "NcFile" class. I have > given the constructor the name of the file I want to open (path) and > I've set the FileMode to be "NcFile::Write". Can I somehow get the > open netCDF file's integer file descriptor using some member function > (or otherwise) using the C++ interface? Yes, the NcFile::id() member function actually returns the file descriptor, if you are using netCDF version 3: int id( void ) const; // id used by C interface In netCDF version 2, the id was merely a small integer that had no relation to the file descriptor, so you couldn't get access to the actual file descriptor in either the C or C++ interface. --Russ