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.
> Another (hopefully quick) question: > How do I enable compression in NETCDF4? > I opened the file with the following statement: > iret = nf90_create(path=trim(fname),cmode=nf90_hdf5, ncid=ftn) > > but I didn't notice any difference in the file sizes. I guess there are other > things I need to do? Here's an answer to an FAQ on that: http://www.unidata.ucar.edu/netcdf/docs/faq.html#fv8 Compression is done on a variable-by-variable basis, so it's possible to use different compression levels on different variables. But if you just want to compress all variables in the file using the same compression level, the easiest way is using the nccopy utility, as in nccopy -d1 foo.nc foo-compressed.nc to use "deflation level" 1. Note that for small files, the compressed netCDF-4 files will actually be larger than uncompressed netCDF-3 (classic format) files, because the underlying HDF5 format has some fixed-size overhead. But for large datasets, compression will save space, at the expense of taking more time to read and write the data. I just tested the 4.1.3 nccopy on an example file for compression and got this: $ nccopy -d1 llnl.nc llnl-compressed.nc && ls -l llnl*.nc -rw-rw-r-- 1 russ ustaff 13802 Feb 15 14:58 llnl-compressed.nc -rw-rw-r-- 1 russ ustaff 32864 Oct 17 11:05 llnl.nc --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: WCR-337446 Department: Support netCDF Priority: Normal Status: Closed