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.
Leopold, The python netcdf4 library wraps the netcdf4 C library. The C library handles all of the calls that open files, so there is no Python file object available to use with posix_fadvise() in Python. As far as I can tell, I don't think what you want to achieve would be possible. Ryan > Linux provides the function posix_fadvise to instruct the kernel to > discard the IO cache for an open file after use with the parameter > POSIX_FADV_DONTNEED. This is useful if many large files are read in > (only once). I can use fadvise with files opened with a python "open" > statement but not with the file objects returned by netcdf4.Dataset. > > f=netCDF4.Dataset(fn,'r') > m=fallocate.posix_fadvise(f, 0, siz,fallocate.POSIX_FADV_DONTNEED) > > fails. > Can you instruct me how to use fadvise with netcdf files? Ticket Details =================== Ticket ID: SID-581519 Department: Support Python Priority: Normal Status: Closed