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 Coy, > I am using NetCDF-4. Yes, I understood that. When I referenced netCDF-3, I was referring to the netCDF-3 library embedded in the netCDF-4 library that is still used to handle netCDF-3 files. But even if you are only using netCDF-4/HDF5 files, there is still a similar global linked list of open files, so if you have different threads opening and closing files that list can become corrupted unless you have a semaphore or lock that prevents use of the netCDF library by more than one thread at a time. > ... How would one make a call from the Windows C > interface to determine if another thread is currently using the NetCDF > dll? I don't know of an easy way to do that (maybe there's something in the Microsoft documentation that deals with that), but you could just make sure no two thredds are making calls to the library at the same time with your own lock/semaphore shared among your threads. It's not enough to make sure different threads are accessing distinct files, you must guarantee that they can't be making netCDF library calls at the same time. > I just need a simply way to make sure only one of my threads is using > the NetCDF dll at a time. Right. There's no netCDF call that can help with that. It should be done at the application level, unless there is a Microsoft-specific way that the OS provides for DLLs. Note that the underlying HDF5 library is also not thread-safe by default, but if you build it with the --enable-threadsafe configuration option, it prevents any concurrent calls to HDF5 functions from different threads. We eventually plan to provide a similar capability for netCDF, but it's not there yet. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: TLB-677315 Department: Support netCDF Priority: Normal Status: Closed