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.
> Sorry, but we have not used mmap calls in netCDF, because we needed > netCDF to work on systems that don't support memory mapping. > > However, I'm forwarding this reply to Glenn Davis, because he did some > experiments with this at one time and may have a suggestion for how to > most easily modify netCDF to use memory mapping. > > --Russ The main reason I've avoided putting mmap access in netcdf is that it is a portability nightmare. We have a product, LDM, which we support on a much more restricted set of platforms than netcdf. It does use mmap where it can. The main problem beyond portabilty is shakey interoperability when one mmap()'s a NFS file. Sometimes it works, sometimes it doesn't depending on which NFS client and which NFS server. Many netcdf users aren't aware which files are NFS mounted on their systems :-). Having said all that, netcdf-3 _is_ layered so that an mmap-based "ncio" layer could be easily slid in underneath. For read-only, non-shared access, it would be a simple as mmap'ping the whole file in ncio_open() and calculating an offset for ncio->get(). The interface is defined in libsrc/ncio.h and an implementation is libsrc/posixio.c. Hope this helps. -glenn