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: "Reggie Chang" <address@hidden> >Subject: file size >Organization: ZONA Technology >Keywords: 200107310123.f6V1NH117343 netCDF file size Hi Reggie, > I'm trying to convert the data file (unformatted, > written out from FORTRAN code) into NetCDF > format. Although I have the results correct, I > notice that the file size in the NetCDF format is > a lot bigger than original one. In general, the overhead for netCDF files is low; for details see the description of the format in Appendix B of the User's Guide: http://www.unidata.ucar.edu/packages/netcdf/f90/Documentation/f90-html-docs/guide67.html#1017343 Netcdf files need not be any larger than other binary formats such as unformatted binary files written out from Fortran, if the external netCDF types match the Fortran types you are using. But if you're writing doubles for Fortran REAL variables on platforms where REALs are stored in 32-bits, for example, you should expect the file to be twice as large, since you're using 64-bit doubles to store 32-bit values. To say anything much more specific, we would have to see the CDL for the file (the output of "ncdump -h foo.nc"). > I found a tip in NetCDF User's Guide for FORTRAN. > Basically it is related to NF_ENDDEF/NF_REDEF. > (Chapter 9) Is this an overhead to execution or file > size? Will arrays with 'unlimited' time coordinate > cost anything? That's about execution time, not file size. There is only one unlimited dimension in a netCDF file, and all the arrays that use it have the same size in that dimension. So if most of your arrays have 10 times but you've written the 100th time for one array, then all of the arrays will be extended to have 100 times. But arrays that use the unlimited dimension don't cost any extra size just because they use the unlimited dimension. In fact if you haven't written any data for such variables, the current size of the unlimited dimension will be zero and the arrays won't take up any space in the file. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu