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.
>To: address@hidden >From: address@hidden (Ethan Alpert) >Subject: Support for 64bit longs in netCDF 3.x? >Organization: . >Keywords: 199801061814.LAA10344 Hi Ethan, > I remember seeing a discussion about this but I can't seem to locate any > on-line information about this. Does netCDF support 64bit longs? Can > you point me to the documentation for it? No, sorry, netCDF has no support for external storage of 64-bit longs, although it does provide interfaces in C for storing and retrieving data from and to longs to any of the 5 numeric external netCDF data types (8-, 16-, and 32-bit ints, 32-, 64-bit floats). If the native long type happens to be 64-bits, then this will convert to and from 32-bit external ints, returning an error in case you try to put an int value that cannot be contained in 32-bits. Since some C/C++ compilers don't yet support 64-bit ints, writing 64-bit int values into a file would be a portability problem, because the value couldn't be read into a scalar variable on such a platform. If you're asking because you wonder about file offsets in huge files, netCDF *will* work with large files if the native "off_t" offset type happens to be 64 bits, since it uses the off_t type in the implementation. However, if you create such a file, it may not be readable on platforms that don't support files larger than 4 Gbytes. For most purposes, a double is a better type than a 64-bit long for numeric values, since it can represent a much wider range with a very high precision. I'm curious what application you have for 64-bit ints as data values in a netCDF file (digital signatures? bit sets?). 64-bit ints will probably be added as a supported external data type with the change to the netCDF data format in an upcoming release (netCDF 4?). By then, it may be a supported data type ("long long") in most C compilers and the C standard. --Russ