NetCDF  4.9.3
FAQ.md
1 FAQ {#faq}
2 =======================
3 
4 [TOC]
5 
6 General {#ncFAQGeneral}
7 =======
8 
9 What Is netCDF? {#What-Is-netCDF}
10 -----------------
11 
12 
13 NetCDF (network Common Data Form) is a set of interfaces for
14 array-oriented data access and a [freely](https://docs.unidata.ucar.edu/netcdf-c/current/copyright.html) distributed
15 collection of data access libraries for C, Fortran, C++, Java, and other
16 languages. The netCDF libraries support a machine-independent format for
17 representing scientific data. Together, the interfaces, libraries, and
18 format support the creation, access, and sharing of scientific data.
19 
20 NetCDF data is:
21 
22 - *Self-Describing*. A netCDF file includes information about the data
23  it contains.
24 - *Portable*. A netCDF file can be accessed by computers with
25  different ways of storing integers, characters, and floating-point
26  numbers.
27 - *Scalable*. A small subset of a large dataset may be accessed
28  efficiently.
29 - *Appendable*. Data may be appended to a properly structured netCDF
30  file without copying the dataset or redefining its structure.
31 - *Shareable*. One writer and multiple readers may simultaneously
32  access the same netCDF file.
33 - *Archivable*. Access to all earlier forms of netCDF data will be
34  supported by current and future versions of the software.
35 
36 The netCDF software was developed by Glenn Davis, Russ Rew, Ed Hartnett,
37 John Caron, Dennis Heimbigner, Steve Emmerson, Harvey Davies, and Ward
38 Fisher at the Unidata Program Center in Boulder, Colorado, with
39 [contributions](https://docs.unidata.ucar.edu/netcdf-c/current/credits.html) from many other netCDF users.
40 
41 ----------
42 
43 How do I get the netCDF software package? {#HowdoIgetthenetCDFsoftwarepackage}
44 -----------------
45 
46 
47 The latest source distribution, which includes the C libraries and
48 utility programs, is available from [the NetCDF Downloads
49 page](https://downloads.unidata.ucar.edu/netcdf-c). Separate source distributions for
50 the Java library, Fortran libraries, and C++ libraries are also
51 available there. Installation instructions are available with the
52 distribution or [online](https://docs.unidata.ucar.edu/netcdf-c/current/netCDF-CMake.html).
53 
54 Binary distributions of netCDF are available for various platforms from
55 package management systems such as dpkg, RPM, fink, MacPorts, Homebrew,
56 OpenCSW, OpenPKG, and the FreeBSD Ports Collection.
57 
58 ----------
59 
60 How do I convert netCDF data to ASCII or text? {#How-do-I-convert-netCDF-data-to-ASCII-or-text}
61 -----------------
62 
63 
64 
65 One way to convert netCDF data to text is to use the **ncdump** tool
66 that is part of the netCDF software distribution. It is a command line
67 tool that provides a text representation of a netCDF file's data, just its
68 metadata, or just the data for specified
69 variables, depending on what arguments you use. For more information,
70 see the [ncdump User's Guide](https://docs.unidata.ucar.edu/nug/current/netcdf_utilities_guide.html#ncdump_guide) documentation.
71 
72 Another good tool for conversion of netCDF data to text is the ["ncks" program](http://nco.sourceforge.net/nco.html#ncks-netCDF-Kitchen-Sink) that's one of the utility programs in the [NCO (NetCDF Operators)](software.html#NCO) package. Similar capabilities are available using programs from the [CDO (Climate Data Operators)](software.html#CDO) software, commands from [NCL (NCAR Command Language)](software.html#NCL), or various other packages such as [ANAX](http://science.arm.gov/~cflynn/ARM_Tested_Tools/), cdf2asc, and NOESYS, all "third party" netCDF utilities developed and supported by other organizations. You can find more information about these third-party packages on the [Software for Manipulating or Displaying NetCDF Data](software.html) page.
73 
74 You can also get netCDF data in ASCII from an OPeNDAP server by using a
75 ".ascii" extension with the URL that specifies the data. For details,
76 see the OPeNDAP page on [Using a Spreadsheet Application with DODS](http://www.opendap.org/useExcel).
77 
78 Another freely available tool, [netcdf4excel](https://code.google.com/p/netcdf4excel/), has been developed as a netCDF add-in for MS Excel that can facilitate the conversion of netCDF data to and from text form.
79 
80 Note that **ncdump** and similar tools can print metadata and data values
81 from netCDF files, but in general they don't understand coordinate
82 systems specified in the metadata, only variable arrays and their
83 indices. To interpret georeferencing metadata so you can print the data
84 within a latitude/longitude bounding box, for example, you need a higher
85 level tool that interprets conventions for specifying coordinates, such
86 as the CF conventions. Or you can write a small program using one of the
87 language APIs that provide netCDF support, for which [examples are available](https://www.unidata.ucar.edu/software/netcdf/examples/programs/).
88 
89 ----------
90 
91 How do I convert ASCII or text data to netCDF? {#How-do-I-convert-ASCII-or-text-data-to-netCDF}
92 -----------------
93 
94 
95 One way to convert data in text form to netCDF is to use the **ncgen**
96 tool that is part of the netCDF software distribution. Using **ncgen** for
97 this purpose is a two-step process:
98 
99 1. Convert text data to a file in [CDL form](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf.html#CDL-Syntax) using a text
100  editor or text manipulation tools
101 2. Convert the CDL representation to netCDF using the **ncgen** tool with
102  the "-o" or "-b" option
103 
104 For more information, see the [ncgen documentation](https://docs.unidata.ucar.edu/netcdf-c/current/ncgen-man-1.html).
105 
106 If you have installed the NCAR Command Language
107 ([NCL](http://www.ncl.ucar.edu/)) software, there are functions
108 available and described
109 [here](http://www.ncl.ucar.edu/Applications/list_io.shtml) and
110 [here](http://www.ncl.ucar.edu/Applications/read_ascii.shtml) for
111 reading ASCII and tables into NCL and writing the data out to netCDF
112 files.
113 
114 With access to [MATLAB](http://www.mathworks.com/), you can create a
115 schema for the desired netCDF file using
116 [ncwriteschema](http://www.mathworks.com/help/techdoc/ref/ncwriteschema.html),
117 read the data using
118 [textscan](http://www.mathworks.com/help/techdoc/ref/textscan.html), and
119 write the data to a netCDF file using
120 [ncwrite](http://www.mathworks.com/help/techdoc/ref/ncwrite.html).
121 
122 What's new in the latest netCDF release?
123 
124 
125 [Release notes](https://www.unidata.ucar.edu/software/netcdf/release-notes-latest.html) for the
126 latest netCDF release are available that describe new features and fixed
127 bugs since the previous release.
128 
129 ----------
130 
131 What is the best way to represent [some particular data] using netCDF? {#What-is-the-best-way-to-represent-some-particular-data-using-netCDF}
132 -----------------
133 
134 There are many ways to represent the same information in any
135 general-purpose data model. Choices left up to the user in the case of
136 netCDF include which information to represent as variables or as
137 variable attributes; what names to choose for variables, dimensions, and
138 attributes; what order to use for the dimensions of multidimensional
139 variables; what variables to include in the same netCDF file; and how to
140 use variable attributes to capture the structure and meaning of data. We
141 provide some guidelines in the NetCDF User's Guide (e.g., the section on
142 [Differences between Attributes and Variables](https://docs.unidata.ucar.edu/nug/current/netcdf_data_set_components.html#differences_atts_vars))
143 and in a new web document [Writing NetCDF Files: BestPractices](https://docs.unidata.ucar.edu/nug/current/_best_practices.html), but we've found that
144 a little experience helps. Occasionally we have decided it was useful to
145 change the structure of netCDF files after experience with how the data
146 is used.
147 
148 ----------
149 
150 What convention should be used for the names of netCDF files? {#What-convention-should-be-used-for-the-names-of-netCDF-files}
151 -----------------
152 
153 
154 NetCDF files should have the file name extension ".nc". The recommended
155 extension for netCDF files was changed from ".cdf" to ".nc" in 1994 in
156 order to avoid a clash with the NASA CDF file extension, and now it also
157 avoids confusion with "Channel Definition Format" files.
158 
159 
160 
161 ----------
162 
163 Is there a mailing list for netCDF discussions and questions? {#Is-there-a-mailing-list-for-netCDF-discussions-and-questions}
164 -----------------
165 
166 The netcdfgroup@unidata.ucar.edu mailing-list is intended for
167 discussions and announcements about netCDF interfaces, software, and
168 use. The volume of this list varies widely, from one message per month
169 to a dozen messages per day (especially after a new release). A message
170 posted to this mailing-list will be seen by several hundred people, so
171 it's usually not appropriate for asking simple questions about use. Such
172 questions should instead be sent to support-netcdf@unidata.ucar.edu.
173 
174 If you would prefer to get only a single daily digest of the postings to
175 the netcdfgroup mailing-list, subscribe instead to the digest form of
176 the mailing-list, containing the same messages but appearing at most
177 once per day instead of whenever anyone sends a message to the group.
178 
179 To subscribe or unsubscribe to either of these mailing lists, use one of
180 these mailing list actions:
181 
182 * [subscribe: non-digest](mailto:netcdfgroup-join@unidata.ucar.edu) ]
183 * [subscribe: digest](mailto:netcdfgroup-request@unidata.ucar.edu?subject=subscribe%0A%20%20%20%20%20%20%20%20%20%20digest)
184 ]
185 * [change subscription options](http://mailman.unidata.ucar.edu/mailman/options/netcdfgroup)
186 * [view posts](/mailing_lists/archives/netcdfgroup/)
187 * [search archives](/search.jsp).
188 
189 ----------
190 
191 Where are some examples of netCDF datasets? {#Where-are-some-examples-of-netCDF-datasets}
192 -----------------
193 
194 Here are some [example netCDF files](https://www.unidata.ucar.edu/software/netcdf/examples/files.html).
195 
196 ----------
197 
198 What is the best way to handle time using netCDF? {#What-is-the-best-way-to-handle-time-using-netCDF}
199 -----------------
200 
201 
202 Discussions of conventions for representing time and handling
203 time-dependent data have been a past topic of discussion on the
204 netcdfgroup mailing list. When the subject comes up, interesting
205 discussions often result, so we've archived past discussions on this
206 subject at
207 [https://www.unidata.ucar.edu/software/netcdf/time/](https://www.unidata.ucar.edu/software/netcdf/time/).
208 
209 A summary of Unidata's recommendations is available from
210 [https://www.unidata.ucar.edu/software/netcdf/time/recs.html](https://www.unidata.ucar.edu/software/netcdf/time/recs.html).
211 Briefly, we recommend use of the units conventions supported by the
212 [udunits library](/software/udunits/) for time and other units
213 attributes.
214 
215 Other groups have established more specific conventions that include the
216 representation of time in netCDF files. For more information on such
217 conventions, see the NetCDF Conventions Page at
218 [https://www.unidata.ucar.edu/software/netcdf/conventions.html](https://www.unidata.ucar.edu/software/netcdf/conventions.html).
219 
220 ----------
221 
222 Who else uses netCDF? {#Who-else-uses-netCDF}
223 -----------------
224 
225 The netCDF mailing list has over 500 addresses (some of which are
226 aliases to more addresses) in thirty countries. Several groups have
227 [adopted netCDF as a standard](https://docs.unidata.ucar.edu/netcdf-c/current/standards.html) for
228 representing some forms of scientific data.
229 
230 A somewhat dated description of some of the projects and groups that
231 have used netCDF is available from
232 [https://www.unidata.ucar.edu/software/netcdf/usage.html](https://www.unidata.ucar.edu/software/netcdf/usage.html).
233 
234 ----------
235 
236 What are some references to netCDF? {#What-are-some-references-to-netCDF}
237 -----------------
238 
239 A primary reference is the User's Guide:
240 
241 Rew, R. K., G. P. Davis, S. Emmerson, and H. Davies, **NetCDF User's
242 Guide for C, An Interface for Data Access, Version 3**, April 1997.
243 
244 Current online and downloadable documentation is available from the
245 [documentation directory](https://docs.unidata.ucar.edu/netcdf-c/current/).
246 
247 Other references include:
248 
249 Brown, S. A, M. Folk, G. Goucher, and R. Rew, "Software for Portable
250 Scientific Data Management," Computers in Physics, American Institute of
251 Physics, Vol. 7, No. 3, May/June 1993, pp. 304-308.
252 
253 Fulker, D. W., "Unidata Strawman for Storing Earth-Referencing Data,"
254 Seventh International Conference on Interactive Information and
255 Processing Systems for Meteorology, Oceanography, and Hydrology, New
256 Orleans, La., American Meteorology Society, January 1991.
257 
258 Jenter, H. L. and R. P. Signell, 1992. "[NetCDF: A Freely-Available Software-Solution to Data-Access Problems for Numerical Modelers](https://www.unidata.ucar.edu/software/netcdf/papers/jenter_signell_92.pdf)". Proceedings
259 of the American Society of Civil Engineers Conference on Estuarine and
260 Coastal Modeling. Tampa, Florida.
261 
262 Kuehn, J.A., "Faster Libraries for Creating Network-Portable
263 Self-Describing Datasets", Proceedings of the 37th Cray User Group
264 Meeting, (Barcelona, Spain, March 1996), Cray User Group, Inc.
265 
266 Rew, R. K. and G. P. Davis, "NetCDF: An Interface for Scientific Data
267 Access," IEEE Computer Graphics and Applications, Vol. 10, No. 4, pp.
268 76-82, July 1990.
269 
270 Rew, R. K. and G. P. Davis, "The Unidata netCDF: Software for Scientific
271 Data Access," Sixth International Conference on Interactive Information
272 and Processing Systems for Meteorology, Oceanography, and Hydrology,
273 Anaheim, California, American Meteorology Society, pp. 33-40, February
274 1990.
275 
276 Rew, R. K. and G. P. Davis, " [Unidata's netCDF Interface for Data Access: Status and Plans](/netcdf/ams97.html)," Thirteenth International Conference on Interactive Information and Processing Systems for Meteorology, Oceanography, and Hydrology, Anaheim, California, American Meteorology Society, February 1997.
277 
278 ----------
279 
280 I'm submitting a paper for publication and want to include a citation for use of netCDF software. What reference should I use? {#How-should-I-cite-use-of-netCDF-software}
281 -----------------
282 
283 The registered Digital Object Identifier for all versions of netCDF software is `http://doi.org/10.5065/D6H70CW6`.
284 
285 The following can be used as a citation:
286 
287 Unidata, (_year_): Network Common Data Form (netCDF) version _nc_version_ [software]. Boulder, CO: UCAR/Unidata. (http://doi.org/10.5065/D6H70CW6)
288 
289 where _year_ is the year in which the work being described was done and _nc_version_ is the version of netCDF used. For example:
290 
291 Unidata, (2015): Network Common Data Form (netCDF) version 4.3.3.1 [software]. Boulder, CO: UCAR/Unidata. (http://doi.org/10.5065/D6H70CW6)
292 
293 ----------
294 
295 Is there a document describing the actual physical format for a Unidata netCDF file? {#Is-there-a-document-describing-the-actual-physical-format-for-a-Unidata-netCDF-file}
296 -----------------
297 
298 A short document that specifies the [format of netCDF classic and 64-bit offset files](http://earthdata.nasa.gov/sites/default/files/esdswg/spg/rfc/esds-rfc-011/ESDS-RFC-011v2.00.pdf) has been approved as a standard by the NASA ESDS Software Process Group.
299 
300 In addition, the NetCDF User's Guide contains an
301 [appendix](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf.html#File-Format) with the same format specification.
302 
303 The ["NetCDF File Structure and Performance"](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf.html#Structure) chapter provides a less formal explanation of the format of netCDF data to help clarify the performance implications of different data organizations.
304 
305 If users only access netCDF data through the documented interfaces, future changes to the format will be transparent.
306 
307 ----------
308 
309 Installation and Porting {#Installation-and-Porting}
310 ================
311 
312 What does netCDF run on? {#What-does-netCDF-run-on}
313 -----------------
314 
315 We test releases on the following operating systems with various compilers:
316 
317 - AIX
318 - HPUX
319 - IRIX, IRIX64
320 - Linux
321 - MacOS X
322 - Solaris
323 - Windows (some versions, see below)
324 
325 The [NetCDF Installation and Porting Guide](https://docs.unidata.ucar.edu/nug/current/getting_and_building_netcdf.html) explains how to build netCDF from source on various platforms. Often, it's as easy as running
326 
327 ~~~~ {.boldcode}
328  ./configure
329  make check install
330 ~~~~
331 
332 ----------
333 
334 
335 How can I use current versions of netCDF-4 with Windows? {#HowcanIusecu}
336 ------------------
337 
338 
339 See [https://docs.unidata.ucar.edu/netcdf-c/current/winbin.html](https://www.unidata.ucar.edu/software/netcdf/win_netcdf).
340 
341 How can I use netCDF-4.1 with Windows? {#HowcanIusenetCDF41withWindows}
342 -----------------
343 
344 
345 We recently (Summer of 2010) refactored the core building of the netCDF
346 library. Unfortunately this hopelessly broke the existing port to
347 Microsoft Visual Studio. Resources permitting, the development of a new
348 Visual Studio port will be undertaken in the second half of 2010 at
349 Unidata. Until then, no Visual Studio port of the latest version of the
350 library is available.
351 
352 Users are advised that the netCDF build is known to work with Cygwin,
353 the free POSIX layer for Windows. Building netCDF with Cygwin, and
354 including the netCDF, HDF5, zlib, and Cygwin DLLs, will allow you to
355 access the netCDF C library on Windows, even from Visual Studio builds.
356 
357 We understand that Windows users are most comfortable with a Visual
358 Studio build, and we intend to provide one.
359 
360 The Visual Studio port is complicated by the following factors:
361 
362 - No configure script support on windows - the Unix build system uses
363  a configure script to determine details of the build platform and
364  allow the user to specify settings. Windows has no mechanism for
365  this other than statically set properties. A Windows-only config.h
366  file needs to be created for windows using Cygwin, then included
367  with the distribution. Since this contains the version string, it
368  must be updated "by hand" before each release.
369 - No m4 on windows - the Unix build uses the macro language m4 to
370  generate some of the C code in the netCDF library (for example,
371  libsrc/putget.c). M4 must be run under Cygwin to generate these
372  files, and then they must be statically added to the windows
373  distribution. Each new version of netCDF these files should be
374  checked for changes. We are restricting new use of m4 for netCDF
375  compiles, but that doesn't help with the existing files.
376 - No user options on Windows - since Windows does not support a
377  configure step, all user options must be pre-set in the Visual
378  Studio property lists. As a simplification, many options available
379  to Unix users will be unavailable to builders on Windows, such as
380  --disable-dap, --disable-netcdf-4, and --disable-shared.
381 - Large files (> 2 GB) have proved to be a problem area in past
382  Windows builds.
383 - Previous Windows ports have not had to deal with the new OPeNDAP
384  client.
385 
386 Unidata is a community supported organization, and we welcome
387 collaboration with users who would like to assist with the windows port.
388 Users should be sure to start with the netCDF daily snapshot, not a
389 previous release of netCDF.
390 
391 NOTE: [Paratools](http://www.paratools.com/) has contributed
392 [instructions for how to build netCDF-4.1.3](http://www.paratools.com/Azure/NetCDF) as a Windows DLL using the MinGW cross compiler.
393 
394 Nikolay Khabarov has contributed [documentation describing a netCDF-4.1.3 port](http://user.iiasa.ac.at/~khabarov/netcdf-win64-and-win32-mingw/) using MinGW to build native Windows 64-bit and 32-bit DLLs. Current limitations include leaving out support for Fortran and C++ interfaces, NetCDF-4, HDF5, the old version 2 API, and DAP access. The netCDF classic format and 64-bit offset format are fully supported. Links are provided to compiled 32-bit and 64-bit DLLs and static libraries.
395 
396 A developer on the GMT Wiki has posted [detailed instructions for using CMake](http://gmtrac.soest.hawaii.edu/projects/gmt/wiki/BuildingNetCDF) and MS Visual C++ on Windows to build netCDF-4.1.3, including OPeNDAP support.
397 
398 Another developer has contributed an unsupported native Windows build of
399 netCDF-4.1.3 with 32- and 64-bit versions, Fortran bindings, and OPeNDAP
400 support. The announcement of the availability of that port is
401 [here](https://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2011/msg00363.html).
402 
403 How can I use netCDF-4 with Windows? {#How-can-I-use-netCDF-4-with-Windows}
404 -----------------
405 
406 
407 Note that we have not ported the F90 or C++ APIs to the Windows
408 platform, only the C and F77 APIs. User contributions of ports to F90
409 windows compilers are very welcome (send them to
410 support-netcdf@unidata.ucar.edu).
411 
412 On windows, NetCDF consists of a DLL and the ncgen/ncdump executables.
413 The easiest course is to download one of the pre-built DLLs and
414 utilities and just install them on your system.
415 
416 Unlike Unix builds, the Visual Studio build **always** requires HDF5,
417 zlib, and szlib in all cases. All Windows DLL users must also have the
418 HDF5, zlib, and szlib DLLs.
419 
420 To use netCDF, install the DLLs in /system/win32 and the .h files in a
421 directory known to your compiler, and define the DLL\_NETCDF
422 preprocessor macro before including netcdf.h.
423 
424 The netCDF-4 library can also be built using Visual Studio 2008. Open
425 the solution file win32/NET/netcdf.sln.
426 
427 If you install the header files in \\include directory, the netCDF
428 solution file will work without modifications. Otherwise the properties
429 of the netcdf project must be changed to include the proper header
430 directory.
431 
432 Both the debug and release builds work. The release build links to
433 different system libraries on Windows, and will not allow debuggers to
434 step into netCDF library code. This is the build most users will be
435 interested in. The debug build is probably of interest only to netCDF
436 library developers.
437 
438 As of version 4.0.1 (March 2009), the DLL build does not yet include any
439 testing of the extended netCDF-4 data model. The netCDF4/HDF5 format is
440 extensively tested in the classic model, but tests for groups,
441 user-defined types, and other features of the expanded netCDF-4 data
442 model have not yet been ported to Windows.
443 
444 The [NetCDF Installation and Porting Guide](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-install/index.html) documents how to
445 use netCDF with Windows.
446 
447 Some users have built and released netCDF with Intel Fortran on Windows.
448 See the [ifort entry in other builds document](https://docs.unidata.ucar.edu/netcdf-c/current/other-builds.html#ifort-361-windows).
449 
450 Windows is a complicated platform to build on. Some useful explanations
451 of the oddities of Windows can be found here:
452 
453 - Cygwin documentation for [Building and Using DLLs](http://cygwin.com/cygwin-ug-net/dll.html)
454 - [OpenLDAP FAQ answer: MinGW Support in Cygwin](http://www.openldap.org/faq/data/cache/301.html), by Jon
455  Leichter.
456 - [cygwin mailing list explanation of Windows DL requirements.](http://cygwin.com/ml/cygwin/2000-06/msg00688.html)
457 - [-mno-cygwin - Building Mingw executables using Cygwin](http://www.delorie.com/howto/cygwin/mno-cygwin-howto.html)
458 
459 The SDS ([Scientific DataSet](http://research.microsoft.com/en-us/projects/sds/)) library and tools provide .Net developers a way to read, write and share scalars, vectors, and multidimensional grids using CSV, netCDF, and other file formats. It currently uses netCDF version 4.0.1. In addition to .Net libraries, SDS provides a set of utilities and packages: an sds command line utility, a DataSet Viewer application and an add-in for Microsoft Excel 2007 (and later versions).
460 
461 ----------
462 
463 How do I build and install netCDF for a specific development environment? {#How-do-I-build-and-install-netCDF-for-a-specific-development-environment}
464 -----------------
465 
466 You have to build and install the netCDF C library first, before you build and install other language libraries that depend on it, such as Fortran, C++, or Python netCDF libraries. The netCDF Java library is mostly independent of the netCDF C library, unless you need to write netCDF-4 files from Java, in which case you will also need an installed netCDF C library.
467 
468 For more details, see
469 [NetCDF Installation and Porting Guide](https://docs.unidata.ucar.edu/nug/current/getting_and_building_netcdf.html).
470 
471 
472 ----------
473 
474 How can I tell if I successfully built and installed netCDF? {#How-can-I-tell-if-I-successfully-built-and-installed-netCDF}
475 -----------------
476 
477 
478 We make build output from various platforms [available](../builds) for
479 comparison with your output. In general, you can ignore compiler
480 warnings if the "make test" step is successful. Lines that begin with
481 "\*\*\*" in the "make test" output indicate results from tests. The C
482 and Fortran-77 interfaces are tested extensively, but only rudimentary
483 tests are currently used for the C++ and Fortran-90 interfaces.
484 
485 How can I tell what version I'm using? {#How-can-I-tell-what-version-Im-using}
486 -----------------
487 
488 
489 If you invoke
490 
491 ~~~~ {.boldcode}
492  ncdump --version
493 ~~~~
494 
495 the last line of the resulting output will identify the version
496 associated with the **ncdump** utility. You can also call one of the
497 functions `nc_inq_libvers()`, `nf_inq_libvers()`, or
498 `nf90_inq_libvers()` from C, Fortran-77, or Fortran-90 programs to get a
499 version string.
500 
501 ----------
502 
503 Where does netCDF get installed? {#Where-does-netCDF-get-installed}
504 -----------------
505 
506 
507 The netCDF installation directory can be set at the time configure is
508 run using the --prefix argument. If it is not specified, /usr/local is
509 used as the default prefix.
510 
511 For more information see the [NetCDF Installation and Porting Guide](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-install).
512 
513 Formats, Data Models, and Software Releases {#formatsdatamodelssoftwarereleases}
514 ===========================================
515 
516 In different contexts, "netCDF" may refer to a data model, a software
517 implementation with associated application program interfaces (APIs), or
518 a data format. Confusion may arise in discussions of different versions
519 of the data models, software, and formats. For example, compatibility
520 commitments require that new versions of the software support all
521 previous versions of the format and data model. This section of FAQs is
522 intended to clarify netCDF versions and help users determine what
523 version to build and install.
524 
525 How many netCDF formats are there, and what are the differences among them? {#How-many-netCDF-formats-are-there-and-what-are-the-differences-among-them}
526 -----------------
527 
528 
529 There are four netCDF format variants:
530 
531 - the classic format
532 - the 64-bit offset format
533 - the 64-bit data format
534 - the netCDF-4 format
535 - the netCDF-4 classic model format
536 
537 (In addition, there are two textual representations for netCDF data,
538 though these are not usually thought of as formats: CDL and NcML.)
539 
540 The **classic format** was the only format for netCDF data created
541 between 1989 and 2004 by the reference software from Unidata. It is
542 still the default format for new netCDF data files, and the form in
543 which most netCDF data is stored. This format is also referred as CDF-1 format.
544 
545 In 2004, the **64-bit offset format** variant was added. Nearly
546 identical to netCDF classic format, it allows users to create and access
547 far larger datasets than were possible with the original format. (A
548 64-bit platform is not required to write or read 64-bit offset netCDF
549 files.) This format is also referred as CDF-2 format.
550 
551 In 2008, the **netCDF-4 format** was added to support per-variable
552 compression, multiple unlimited dimensions, more complex data types, and
553 better performance, by layering an enhanced netCDF access interface on
554 top of the HDF5 format.
555 
556 At the same time, a fourth format variant, **netCDF-4 classic model
557 format**, was added for users who needed the performance benefits of the
558 new format (such as compression) without the complexity of a new
559 programming interface or enhanced data model.
560 
561 In 2016, the **64-bit data format** variant was added. To support large
562 variables with more than 4-billion array elements, it replaces most of the
563 32-bit integers used in the format specification with 64-bit integers. It also
564 adds support for several new data types including unsigned byte, unsigned
565 short, unsigned int, signed 64-bit int and unsigned 64-bit int. A 64-bit
566 platform is required to write or read 64-bit data netCDF files. This format is
567 also referred as CDF-5 format.
568 
569 With each additional format variant, the C-based reference software from
570 Unidata has continued to support access to data stored in previous
571 formats transparently, and to also support programs written using
572 previous programming interfaces.
573 
574 Although strictly speaking, there is no single "netCDF-3 format", that
575 phrase is sometimes used instead of the more cumbersome but correct
576 "netCDF classic CDF-1, 64-bit offset CDF-2, or 64-bit data CDF-5 format" to
577 describe files created by the netCDF-3 (or netCDF-1 or netCDF-2) libraries.
578 Similarly "netCDF-4 format" is sometimes used informally to mean "either the
579 general netCDF-4 format or the restricted netCDF-4 classic model format". We
580 will use these shorter phrases in FAQs below when no confusion is likely.
581 
582 A more extensive description of the netCDF formats and a formal specification
583 of the classic and 64-bit formats is available as a [NASA ESDS community
584 standard](https://earthdata.nasa.gov/sites/default/files/esdswg/spg/rfc/esds-rfc-011/ESDS-RFC-011v2.00.pdf).
585 
586 The 64-bit data CDF-5 format specification is available in
587 http://cucis.ece.northwestern.edu/projects/PnetCDF/CDF-5.html.
588 
589 How can I tell which format a netCDF file uses? {#How-can-I-tell-which-format-a-netCDF-file-uses}
590 -----------------
591 
592 
593 The short answer is that under most circumstances, you should not care,
594 if you use version 4.0 or later of the netCDF library to access data in
595 the file. But the difference is indicated in the first four bytes of the
596 file, which are 'C', 'D', 'F', '\\001' for the classic netCDF CDF-1 format;
597 'C', 'D', 'F', '\\002' for the 64-bit offset CDF-2 format;
598 'C', 'D', 'F', '\\005' for the 64-bit data CDF-5 format; or '\\211', 'H',
599 'D', 'F' for an HDF5 file, which could be either a netCDF-4 file or a
600 netCDF-4 classic model file. (HDF5 files may also begin with a
601 user-block of 512, 1024, 2048, ... bytes before what is actually an
602 8-byte signature beginning with the 4 bytes above.)
603 
604 With netCDF version 4.0 or later, there is an easy way that will
605 distinguish between netCDF-4 and netCDF-4 classic model files, using the
606 "-k" option to **ncdump** to determine the kind of file, for example:
607 
608 ~~~~~ {.boldcode}
609  ncdump -k foo.nc
610  classic
611 ~~~~~
612 
613 
614 In a program, you can call the function
615 [nc_inq_format](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-c.html#nc_005finq-Family)(or [nf90_inq_format](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-f90.html#Compiling-and-Linking-with-the-NetCDF-Library) for the Fortran-90 interface) to determine the format variant of an open netCDF file.
616 
617 Finally, on a Unix system, one way to display the first four bytes of a
618 file, say foo.nc, is to run the following command:
619 
620 ~~~~ {.boldcode}
621  od -An -c -N4 foo.nc
622 ~~~~
623 
624 which will output
625 
626 ~~~~ {.boldcode}
627  C D F 001
628 ~~~~
629 
630 ~~~~ {.boldcode}
631  C D F 002
632 ~~~~
633 
634 ~~~~ {.boldcode}
635  C D F 005
636 ~~~~
637 
638 ~~~~ {.boldcode}
639  211 H D F
640 ~~~~
641 
642 depending on whether foo.nc is a classic CDF-1, 64-bit offset CDF-2, 64-bit
643 data CDF-5, or netCDF-4 file, respectively. This method cannot be used to
644 distinguish between netCDF-4 and netCDF-4 classic model variants, or between a
645 netCDF-4 file and a different kind of HDF5 file.
646 
647 ----------
648 
649 How many netCDF data models are there? {#How-many-netCDF-data-models-are-there}
650 -----------------
651 
652 There are only two netCDF data models, the [classic
653 model](/netcdf/workshops/2008/datamodel/NcClassicModel.html) and the [enhanced
654 model](/netcdf/workshops/2008/netcdf4/Nc4DataModel.html) (also called the
655 netCDF-4 data model). The classic model is the simpler of the two, and is used
656 for all data stored in classic CDF-1 format, 64-bit offset CDF-2 format, 64-bit
657 data CDF-5 format, or netCDF-4 classic model format. The enhanced model
658 (sometimes also referred to as the netCDF-4 data model) is an extension of the
659 classic model that adds more powerful forms of data representation and data
660 types at the expense of some additional complexity. Although data represented
661 with the classic model can also be represented using the enhanced model,
662 datasets that use enhanced model features, such as user-defined data types,
663 cannot be represented with the classic model. Use of the enhanced model
664 requires storage in the netCDF-4 format.
665 
666 How many releases of the C-based netCDF software are supported? {#How-many-releases-of-the-C-based-netCDF-software-are-supported}
667 -----------------
668 
669 
670 When netCDF version 4.0 was released in June 2008, version 3.6.3 was
671 released simultaneously, and both releases were supported by Unidata.
672 Version 3.6.3 supported only the classic and 64-bit offset formats.
673 Version 4.0 supported both of those format variants by default, and also
674 the netCDF-4 and netCDF-4 classic model formats, if built using a
675 previously installed HDF5 library and using the "--enable-netcdf-4"
676 configure option. Software built from the netCDF-4.0 release without
677 specifying "--enable-netcdf-4" (the default) was identical to software
678 built with netCDF-3.6.3. Starting from version 4.4.0, netCDF added support
679 for CDF-5 format.
680 
681 Both netCDF-3 and netCDF-4 C libraries are part of a single software
682 release. The netCDF software may be built to support just the classic
683 CDF-1 and 64-bit offset CDF-2 formats (the default), 64-bit data CDF-5 format,
684 or to also support the netCDF-4 and netCDF-4 classic model formats, if the
685 HDF5-1.8.x library is installed. Unidata no longer supports a separate
686 netCDF-3-only version of the software, but instead supports both the classic
687 and enhanced data models and all four format variants in a single source
688 distribution.
689 
690 This does not indicate any plan to drop support for netCDF-3 or the
691 formats associated with netCDF-3. Support for earlier formats and APIs
692 will continue with all future versions of netCDF software from Unidata.
693 
694 Should I get netCDF-3 or netCDF-4? {#Should-I-get-netCDF-3-or-netCDF-4}
695 -----------------
696 
697 By downloading a current version of netCDF-4, you have the choice to
698 build either
699 
700 - the default netCDF-3 libraries, which support classic CDF-1, 2, and 5
701  formats, and the classic data model; or
702 - the netCDF-4 libraries, which support netCDF-4 and netCDF-4 classic
703  model formats, as well as classic formats, and the
704  enhanced data model.
705 
706 Which version to build depends on how you will use the software.
707 
708 Installing the simpler netCDF-3 version of the software is recommended
709 if the following situations apply:
710 
711 - all the data you need to access is available in netCDF classic
712  formats
713 - you are installing netCDF in order to support another software
714  package that uses only netCDF-3 features
715 - you plan to only write data in a form that netCDF-3 software and
716  applications can access
717 - you want to delay upgrading to support netCDF-4 until netCDF-4
718  formats are more widely used
719 - you cannot install the prerequisite HDF5 1.8 software required to
720  build and install netCDF-4
721 
722 Installing the netCDF-4 version of the software is required for any of
723 the following situations:
724 
725 - you need to access netCDF data that makes use of netCDF-4
726  compression or chunking
727 - you need to access data in all netCDF formats including netCDF-4 or
728  netCDF-4 classic model formats
729 - you need to write non-record variables larger than 4GiB or record variables with more than 4GiB per record (see ["Have all netCDF size limits been eliminated?"](https://docs.unidata.ucar.edu/netcdf-c/current/faq.html#Large%20File%20Support10))
730 - you are installing netCDF to support other software packages that
731  require netCDF-4 features
732 - you want to write data that takes advantage of compression,
733  chunking, or other netCDF-4 features
734 - you want to be able to read netCDF-4 classic model data with no
735  changes to your current software except relinking with the new
736  library
737 - you want to benchmark your current applications with the new
738  libraries to determine whether the benefits are significant enough
739  to justify the upgrade
740 - you need to use parallel I/O with netCDF-4 or netCDF-4 classic files
741 
742 What is the "enhanced data model" of netCDF-4, and how does it differ from the netCDF-3 classic data model? {#whatisenhanceddatamodel}
743 -------------
744 
745 
746 The enhanced model (sometimes referred to as the netCDF-4 data model) is
747 an extension to the [classic model](/netcdf/workshops/2008/datamodel/NcClassicModel.html) that adds more powerful forms of data representation and data types at the expense of some additional complexity. Specifically, it adds six new primitive data types, four kinds of user-defined data types, multiple unlimited
748 dimensions, and groups to organize data hierarchically and provide
749 scopes for names. A [picture](/netcdf/workshops/2008/netcdf4/Nc4DataModel.html) of the enhanced data model, with the extensions to the classic model
750 highlighted in red, is available from the online netCDF workshop.
751 
752 Although data represented with the classic model can also be represented
753 using the enhanced model, datasets that use features of the enhanced
754 model, such as user-defined data types, cannot be represented with the
755 classic model. Use of added features of the enhanced model requires that
756 data be stored in the netCDF-4 format.
757 
758 Why doesn't the new netCDF-4 installation I built seem to support any of the new features? {#Whydoesnt-the-new-netCDF-4-installation-I-built-seem-to-support-any-of-the-new-features}
759 -----------------
760 
761 
762 If you built the software from source without access to an HDF5 library,
763 then only the netCDF-3 library was built and installed. The current
764 release will build full netCDF-4 support if the HDF5 1.8.x library is
765 already installed where it can be found by the configure script or
766 cmake.
767 
768 Will Unidata continue to support netCDF-3? {#Will-Unidata-continue-to-support-netCDF-3}
769 -----------------
770 
771 
772 Yes, Unidata has a commitment to preserving backward compatibility.
773 
774 Because preserving access to archived data for future generations is
775 very important:
776 
777 - New netCDF software will provide read and write access to *all*
778  earlier forms of netCDF data.
779 - C and Fortran programs using documented netCDF APIs from previous
780  releases will be supported by new netCDF software (after recompiling
781  and relinking, if needed).
782 - Future releases of netCDF software will continue to support data
783  access and API compatibility.
784 
785 To read compressed data, what changes do I need to make to my netCDF-3 program? {#To-read-compressed-data-what-changes-do-I-need-to-make-to-my-netCDF-3-program}
786 -----------------
787 
788 
789 None. No changes to the program source are needed, because the library
790 handles decompressing data as it is accessed. All you need to do is
791 relink your netCDF-3 program to the netCDF-4 library to recognize and
792 handle compressed data.
793 
794 To write compressed data, what changes do I need to make to my netCDF-3 program? {#To-write-compressed-data-what-changes-do-I-need-to-make-to-my-netCDF-3-program}
795 -----------------
796 
797 
798 The **nccopy** utility in versions 4.1.2 and later supports a "-d *level*"
799 deflate option that copies a netCDF file, compressing all variables
800 using the specified level of deflation and default chunking parameters,
801 or you can specify chunking with the "-c" option.
802 
803 To do this within a program, or if you want different variables to have
804 different levels of deflation, define compression properties when each
805 variable is defined. The function to call is
806 [nc_def_var_deflate](/netcdf-c.html#nc_005fdef_005fvar_005fdeflate)
807 for C programs, [nf90_def_var_deflate](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-f90.html#NF90_005fDEF_005fVAR_005fDEFLATE) for Fortran 90 programs, [NF_DEF_VAR_DEFLATE](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-f77.html#NF_005fDEF_005fVAR_005fDEFLATE) for Fortran 77. For C++ programs, the experimental cxx4 API may be used,
808 assuming you have configured with --enable-cxx-4.
809 
810 Although default variable chunking parameters may be adequate,
811 compression can sometimes be improved by choosing good chunking
812 parameters when a variable is first defined. For example, if a 3D field
813 tends to vary a lot with vertical level, but not so much within a
814 horizontal slice corresponding to a single level, then defining chunks
815 to be all or part of a horizontal slice would typically produce better
816 compression than chunks that included multiple horizontal slices. There
817 are other factors in choosing chunk sizes, especially matching how the
818 data will be accessed most frequently. Chunking properties may only be
819 specified when a variable is first defined. The function to call is
820 [nc_def_var_chunking](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-c.html#nc_005fdef_005fvar_005f)
821 for C programs,
822 [nf90_def_var_chunking](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-f90.html#NF90_005fDEF_005fVAR_005fCHUNKING)
823 for Fortran 90 programs, and
824 [NF_DEF_VAR_CHUNKING](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-f77.html#NF_005fDEF_005fVAR_005fCHUNKING)
825 for Fortran 77 programs. For C++ programs, the experimental cxx4 API may
826 be used, assuming you have configured with --enable-cxx-4.
827 
828 If I create netCDF-4 classic model files, can they be read by IDL, MATLAB, R, Python and ArcGIS? {#If-I-create-netCDF-4-classic-model-files-can-they-be-read-by-IDL-MATLAB-R-Python-and-ArcGIS}
829 -----------------
830 
831 
832 IDL 8.0 ships with support for netCDF-4, including support for OPeNDAP
833 remote access.
834 
835 MATLAB 2012a includes netCDF 4 support with OPeNDAP support turned on,
836 enabling remote access to many kinds of data, as well as use of groups,
837 compression, and chunking. An example is available demonstrating some of
838 the new functions. [NCTOOLBOX](http://nctoolbox.github.io/nctoolbox/),
839 uses netCDF-Java to provide read access to datasets in netCDF-4, GRIB,
840 GRIB2 and other formats through Unidata's Common Data Model.
841 
842 R has the [ncdf4 package](http://cirrus.ucsd.edu/~pierce/ncdf/).
843 
844 Python has the [netcdf4-python package](http://code.google.com/p/netcdf4-python/).
845 
846 ArcGIS 10.0 can read netcdf4 using the Multidimensional Tools in
847 ArcToolbox, and in ArcGIS 10.1, the [Multidimensional Supplemental toolbox](http://esriurl.com/MultidimensionSupplementalTools) uses NetCDF4-Python to read OPeNDAP and netCDF4 files, taking advantage of CF conventions if they exist.
848 
849 What applications are able to deal with *arbitrary* netCDF-4 files? {#What-applications-are-able-to-deal-with-arbitrary-netCDF-4-files}
850 -----------------
851 
852 The netCDF utilities **ncdump**, **ncgen**, and **nccopy**, available in
853 the Unidata C-based netCDF-4 distribution, are able to deal with
854 arbitrary netCDF-4 files (as well as all other kinds of netCDF files).
855 
856 How can I convert netCDF-3 files into netCDF-4 files? {#How-can-I-convert-netCDF-3-files-into-netCDF-4-files}
857 -----------------
858 
859 
860 Every netCDF-3 file can be read or written by a netCDF version 4 library, so in
861 that respect netCDF-3 files are already netCDF-4 files and need no conversion.
862 But if you want to convert a classic format file (CDF-1, 2, or 5) into a
863 netCDF-4 format or netCDF-4 classic model format file, the easiest way is to
864 use the **nccopy** utility. For example to convert a classic format file
865 foo3.nc to a netCDF-4 format file foo4.nc, use:
866 
867 ~~~~~~~~~~~~~~~~~~~~~~~~~ {.boldcode}
868  nccopy -k netCDF-4 foo3.nc foo4.nc
869 ~~~~~~~~~~~~~~~~~~~~~~~~~
870 
871 To convert a classic format file foo3.nc to a netCDF-4 classic
872 model format file foo4c.nc, you could use:
873 
874 ~~~~~~~~~~~~~~~~~~~~~~~~~~ {.boldcode}
875  nccopy -k netCDF-4-classic foo3.nc foo4c.nc
876 ~~~~~~~~~~~~~~~~~~~~~~~~~~
877 
878 If you have installed [NCO](https://www.unidata.ucar.edu/software/netcdf/software.html#NCO), the NCO
879 utility "ncks" can be used to accomplish the same task, as follows:
880 
881 ~~~~~~~~~~~~~~~~~~~~~~~~ {.boldcode}
882  ncks -7 foo3.nc foo4c.nc
883 ~~~~~~~~~~~~~~~~~~~~~~~~
884 
885 Another method is available for relatively small files, using the **ncdump**
886 and **ncgen** utilities (built with a netCDF-4 library). Assuming "small3.nc"
887 is a small classic format netCDF file, you can create an equivalent netCDF-4
888 file named "small4.nc" as follows:
889 
890 ~~~~ {.boldcode}
891  ncdump small3.nc > small.cdl
892  ncgen -o small4.nc -k netCDF-4-classic small.cdl
893 ~~~~
894 
895 Why might someone want to convert netCDF-4 files into netCDF-3 files? {#Why-might-someone-want-to-convert-netCDF-4-files-into-netCDF-3-files}
896 -----------------
897 
898 
899 NetCDF-4 classic model files that use compression can be smaller than
900 the equivalent netCDF-3 files, so downloads are quicker. If they are
901 then unpacked and converted to the equivalent netCDF-3 files, they can
902 be accessed by applications that haven't yet upgraded to netCDF-4.
903 
904 How can I convert netCDF-4 files into netCDF-3 files? {#How-can-I-convert-netCDF-4-files-into-netCDF-3-files}
905 -----------------
906 
907 
908 In general, you can't, because netCDF-4 files may have features of the
909 netCDF enhanced data model, such as groups, compound types,
910 variable-length types, or multiple unlimited dimensions, for which no
911 netCDF-3 representation is available. However, if you know that a
912 netCDF-4 file conforms to the classic model, either because it was
913 written as a netCDF-4 classic model file, because the program that wrote
914 it was a netCDF-3 program that was merely relinked to a netCDF-4
915 library, or because no features of the enhanced model were used in
916 writing the file, then there are several ways to convert it to a
917 netCDF-3 file.
918 
919 You can use the **nccopy** utility. For
920 example to convert a netCDF-4 classic-model format file foo4c.nc to a
921 classic format file foo3.nc, use:
922 
923 ~~~~~~~~~~~~~~~~~~~~~~~~~ {.boldcode}
924  nccopy -k classic foo4c.nc foo3.nc
925 ~~~~~~~~~~~~~~~~~~~~~~~~~
926 
927 If you have installed [NCO](https://docs.unidata.ucar.edu/netcdf-c/current/software.html#NCO), the NCO utility "ncks" can be used to accomplish the same task, as follows:
928 
929 ~~~~~~~~~~~~~~~~~~~~~~~~~ {.boldcode}
930  ncks -3 foo4c.nc foo3.nc
931 ~~~~~~~~~~~~~~~~~~~~~~~~~
932 
933 For a relatively small netCDF-4 classic model file, "small4c.nc" for
934 example, you can also use the **ncdump** and **ncgen** utilities to create an
935 equivalent netCDF-3 classic format file named "small3.nc" as follows:
936 
937 ~~~~ {.boldcode}
938  ncdump small4c.nc > small4.cdl
939  ncgen -o small3.nc small4.cdl
940 ~~~~
941 
942 How can I convert HDF5 files into netCDF-4 files? {#How-can-I-convert-HDF5-files-into-netCDF-4-files}
943 -----------------
944 
945 
946 NetCDF-4 intentionally supports a simpler data model than HDF5, which
947 means there are HDF5 files that cannot be converted to netCDF-4,
948 including files that make use of features in the following list:
949 
950 - Multidimensional data that doesn't use shared dimensions implemented
951  using HDF5 "dimension scales". (This restriction was eliminated in
952  netCDF 4.1.1, permitting access to HDF5 datasets that don't use
953  dimension scales.)
954 - Non-hierarchical organizations of Groups, in which a Group may have
955  multiple parents or may be both an ancestor and a descendant of
956  another Group, creating cycles in the subgroup graph. In the
957  netCDF-4 data model, Groups form a tree with no cycles, so each
958  Group (except the top-level unnamed Group) has a unique parent.
959 - HDF5 "references" which are like pointers to objects and data
960  regions within a file. The netCDF-4 data model does not support
961  references.
962 - Additional primitive types not included in the netCDF-4 data model,
963  including H5T\_TIME, H5T\_BITFIELD, and user-defined atomic types.
964 - Multiple names for data objects such as variables and groups. The
965  netCDF-4 data model requires that each variable and group have a
966  single distinguished name.
967 - Attributes attached to user-defined types.
968 - Stored property lists
969 - Object names that begin or end with a space
970 
971 If you know that an HDF5 file conforms to the netCDF-4 enhanced data
972 model, either because it was written with netCDF function calls or
973 because it doesn't make use of HDF5 features in the list above, then it
974 can be accessed using netCDF-4, and analyzed, visualized, and
975 manipulated through other applications that can access netCDF-4 files.
976 
977 The [ncks tool](http://nco.sourceforge.net/nco.html#ncks-netCDF-Kitchen-Sink) of the NCO collection of netCDF utilities can take simple HDF5 data as input and produce a netCDF file as output, so this may work:
978 
979 ~~~~ {.boldcode}
980  ncks infile.hdf5 outfile.nc
981 ~~~~
982 
983 Another tool has been developed to convert HDF5-EOS Aura files to
984 netCDF-4 files, and it is currently undergoing testing and documentation
985 before release on the HDF5 web site.
986 
987 How can I convert netCDF-4 files into HDF5 files? {#How-can-I-convert-netCDF-4-files-into-HDF5-files}
988 -----------------
989 
990 
991 Every netCDF-4 or netCDF-4 classic model file can be read or written by
992 the HDF5 library, version 1.8 or later, so in that respect netCDF-4
993 files are already HDF5 files and need no conversion.
994 
995 The way netCDF-4 data objects are represented using HDF5 is described in
996 detail in the User Manual section ["C.3 The NetCDF-4 Format"](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf.html#NetCDF_002d4-Format).
997 
998 Why aren't different extensions used for the different formats, for example ".nc3" and ".nc4"? {#why-arent-different-extensions-used}
999 ------------------
1000 
1001 The file extension used for netCDF files is purely a convention. The
1002 netCDF libraries don't use the file extension. A user can currently
1003 create a netCDF file with any extension, even one not consistent with
1004 the format of the file.
1005 
1006 The **ncgen** utility uses ".nc" as a default extension for output, but this
1007 can be overridden using the "-o" option to specify the name for the
1008 output file. Recent versions of **ncgen** also have a "-k" option to specify
1009 what kind of output file is desired, selecting any of the 4 format
1010 variants, using either a numeric code or a text string. Most other
1011 netCDF client software pays no attention to the file extension, so using
1012 more explicit extensions by convention has no significant drawbacks,
1013 except possibly causing confusion about format differences that may not
1014 be important.
1015 
1016 Why is the default of netCDF-4 to continue to create classic files, rather than netCDF-4 files? {#Why-is-the-default-of-netCDF-4-to-continue-to-create-classic-files-rather-than-netCDF-4-files}
1017 -----------------
1018 
1019 
1020 Until widely used netCDF client software has been adapted or upgraded to
1021 read netCDF-4 data, classic file format is the default for
1022 interoperability with most existing netCDF software.
1023 
1024 Can netCDF-4 read arbitrary HDF5 files? {#Can-netCDF-4-read-arbitrary-HDF5-files}
1025 -----------------
1026 
1027 
1028 No, but it can read many HDF5 files, and more recent versions can access
1029 more HDF5 data. If you want to access HDF5 data through netCDF
1030 interfaces, avoid HDF5 features not included in the netCDF enhanced data
1031 model. For more details see "[How can I convert HDF5 files into netCDF-4 files?](#fv15)", above.
1032 
1033 I installed netCDF-3 with --enable-shared, but it looks like the libraries it installed were netCDF-4, with names like libnetcdf.4.dylib. What's going on? {#I-installed-netCDF-3-with---enable-shared-but-it-looks-like-the-libraries-it-installed-were-netCDF-4-with-names-like-libnetcdf4dylib-Whats-going-on}
1034 -----------------
1035 
1036 
1037 The number used for the shared library name is not related to the netCDF
1038 library version number.
1039 
1040 NetCDF-3.6.3 permits UTF-8 encoded Unicode names. Won't this break backward compatibility with previous software releases that didn't allow such names? {#NetCDF-363-permits-UTF-8-encoded-Unicode-names-Wont-this-break-backward-compatibility-with-previous-software-releases-that-didnt-allow-such-names}
1041 -----------------
1042 
1043 
1044 Earlier versions of the netCDF libraries have always been able to read
1045 data with arbitrary characters in names. The restriction has been on
1046 *creating* files with names that contained "invalid" special characters.
1047 The check for characters used in names occurred when a program tried to
1048 define a new variable, dimension, or attribute, and an error would be
1049 returned if the characters in the names didn't follow the rules.
1050 However, there has never been any such check on reading data, so
1051 arbitrary characters have been permitted in names created through a
1052 different implementation of the netCDF APIs, or through early versions
1053 of netCDF software (before 2.4), which allowed arbitrary names.
1054 
1055 In other words, the expansion to handle UTF-8 encoded Unicode characters
1056 and special characters such as \`:' and \` ' still conforms with
1057 Unidata's commitment to backwards compatibility. All old files are still
1058 readable and writable by the new software, and programs that used to
1059 work will still work when recompiled and relinked with the new
1060 libraries. Files using new characters in names will still be readable
1061 and writable by programs that used older versions of the libraries.
1062 However, programs linked to older library versions will not be able to
1063 create new data objects with the new less-restrictive names.
1064 
1065 Can I use UTF-8 File Names with Windows? {#Can-I-use-UTF-8-File-Names-with-Windows}
1066 -----------------
1067 
1068 Starting with Windows 10 build 17134, Windows can support use of
1069 the UTF-8 character set. We strongly encourage Windows users to
1070 enable this feature. This requires the following steps.
1071 
1072 1. In the "run" toolbar, execute the command "intl.cpl".
1073 2. Move to the Administrative tab.
1074 3. Move to "Change system locale"
1075 4. Check the box at the bottom labeled something like
1076 "Beta: Use Unicode UTF-8 for worldwide language support"
1077 
1078 
1079 How difficult is it to convert my application to handle arbitrary netCDF-4 files? {#How-difficult-is-it-to-convert-my-application-to-handle-arbitrary-netCDF-4-files}
1080 -----------------
1081 
1082 Modifying an application to fully support the new enhanced data model
1083 may be relatively easy or arbitrarily difficult :-), depending on what
1084 your application does and how it is written. Use of recursion is the
1085 easiest way to handle nested groups and nested user-defined types. An
1086 object-oriented architecture is also helpful in dealing with
1087 user-defined types.
1088 
1089 We recommend proceeding incrementally, supporting features that are
1090 easier to implement first. For example, handling the six new primitive
1091 types is relatively straightforward. After that, using recursion (or the
1092 group iterator interface used in **nccopy**) to support Groups is not too
1093 difficult. Providing support for user-defined types is more of a
1094 challenge, especially since they can be nested.
1095 
1096 The utility program **nccopy**, provided in releases 4.1 and later, shows
1097 how this can be done using the C interface. It copies an input netCDF
1098 file in any of the format variants, handling nested groups, strings, and
1099 any user-defined types, including arbitrarily nested compound types,
1100 variable-length types, and data of any valid netCDF-4 type. It also
1101 demonstrates how to handle variables that are too large to fit in memory
1102 by using an iterator interface. Other generic utility programs can make
1103 use of parts of **nccopy** for more complex operations on netCDF data.
1104 
1105 ----------
1106 
1107 Shared Libraries {#Shared-Libraries}
1108 ================
1109 
1110 What are shared libraries? {#What-are-shared-libraries}
1111 -----------------
1112 
1113 
1114 Shared libraries are libraries that can be shared by multiple running
1115 applications at the same time. This **may** improve performance.
1116 
1117 For example, if I have a library that provides function foo(), and I
1118 have two applications that call foo(), then with a shared library, only
1119 one copy of the foo() function will be loaded into memory, and both
1120 programs will use it. With static libraries, each application would have
1121 its own copy of the foo() function.
1122 
1123 More information on shared libraries can be found at the following
1124 external sites:
1125 
1126 - [The Program-Library HowTo](http://www.tldp.org/HOWTO/Program-Library-HOWTO/index.html),
1127  by David Wheeler.
1128 
1129 - [Wikipedia Library Entry](http://en.wikipedia.org/wiki/Library_(computer_science))
1130 
1131 ----------
1132 
1133 Can I build netCDF with shared libraries? {#Can-I-build-netCDF-with-shared-libraries}
1134 -----------------
1135 
1136 
1137 Starting with version 3.6.2, netCDF can build shared libraries on
1138 platforms that support them, but by default netCDF will build static
1139 libraries only. To turn on shared libraries, use the --enable-shared
1140 option to the [netCDF configure script](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-install/Running-the-configure-Script.html).
1141 
1142 ----------
1143 
1144 How do I use netCDF shared libraries? {#How-do-I-use-netCDF-shared-libraries}
1145 -----------------
1146 
1147 
1148 With netCDF version 3.6.2, shared libraries can be built on platforms
1149 that support them by using the --enable-shared argument to [netCDF configure script](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-install/Running-the-configure-Script.html).
1150 
1151 Users of earlier versions of netCDF can build shared libraries by
1152 setting flags correctly during builds.
1153 
1154 When you use a static library, the code is copied from the library into
1155 your program when the program is built. The library is only needed at
1156 build time.
1157 
1158 With a shared library the code in the library is not copied into your
1159 executable, so the library is needed every time the program is run.
1160 
1161 If you write a program that uses the netCDF shared library, the
1162 operating system will have to find it every time your program is run. It
1163 will look in these places:
1164 
1165 1. Directories you specified as shared library locations at **build
1166  time**. Unfortunately this is done differently with different
1167  compilers.
1168 
1169 2. Directories specified in the environment variable LD\_RUN\_PATH at
1170  **build time**.
1171 
1172 3. Directories specified in the OS-specific environment variable for
1173  this purpose at **run time**. (LD\_LIBRARY\_PATH on Linux and many
1174  other Unix variants, LOADLIBS on AIX systems, etc.)
1175 
1176 4. A default list of directories that includes /usr/lib (but don't
1177  install software there!), and may or may not contain places you
1178  might install netCDF, like /usr/local/lib.
1179 
1180 5. The directories specified in an OS file such as /etc/ld.conf.
1181 
1182 By default the netCDF library will be installed in /usr/local/lib. (This
1183 can be overridden with the --prefix option to the [netCDF configure script](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf-install/Running-the-configure-Script.html)).
1184 
1185 An external site by Arnaud Desitter has a [table of different tools and command line options relating to shared libraries](http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html) on Linux, Solaris, HP-UX, Tru64, AIX, SGI, Win32, MacOS X, VMS (wow!), and OS/390.
1186 
1187 For more information about how do to this in Linux users may find it
1188 useful to read this external webpage, some documentation from Caldera, a
1189 Linux distributor: [Specifying directories to be searched by the dynamic linker](http://osr507doc.sco.com/en/tools/ccs_linkedit_dynamic_dirsearch.html).
1190 
1191 ----------
1192 
1193 Large File Support {#Large-File-Support}
1194 ================
1195 
1196 Was it possible to create netCDF files larger than 2 GiBytes before version 3.6? {#Was-it-possible-to-create-netCDF-files-larger-than-2-GiBytes-before-version-36}
1197 -----------------
1198 
1199 
1200 Yes, but there are significant restrictions on the structure of large
1201 netCDF files that result from the 32-bit relative offsets that are part
1202 of the classic netCDF format. For details, see [NetCDF Classic Format Limitations](https://docs.unidata.ucar.edu/nug/current/netcdf_introduction.html#classic_format)
1203 in the User's Guide.
1204 
1205 ----------
1206 
1207 What is Large File Support? {#What-is-Large-File-Support}
1208 -----------------
1209 
1210 
1211 Large File Support (LFS) refers to operating system and C library
1212 facilities to support files larger than 2 GiB. On a few 32-bit platforms
1213 the default size of a file offset is still a 4-byte signed integer,
1214 which limits the maximum size of a file to 2 GiB. Using LFS interfaces
1215 and the 64-bit file offset type, the maximum size of a file may be as
1216 large as 2^63^ bytes, or 8 EiB. For some current platforms, large file
1217 macros or appropriate compiler flags have to be set to build a library
1218 with support for large files. This is handled automatically in netCDF
1219 3.6 and later versions.
1220 
1221 More information about Large File Support is available from [Adding Large File Support to the Single UNIX Specification](http://www.unix.org/version2/whatsnew/lfs.html).
1222 
1223 ----------
1224 
1225 What does Large File Support have to do with netCDF? {#What-does-Large-File-Support-have-to-do-with-netCDF}
1226 -----------------
1227 
1228 
1229 When the netCDF format was created in 1988, 4-byte fields were reserved
1230 for file offsets, specifying where the data for each variable started
1231 relative to the beginning of the file or the start of a record boundary.
1232 
1233 This first netCDF format variant, the only format supported in versions
1234 3.5.1 and earlier, is referred to as the netCDF *classic* format. The
1235 32-bit file offset in the classic format limits the total sizes of all
1236 but the last non-record variables in a file to less than 2 GiB, with a
1237 similar limitation for the data within each record for record variables.
1238 For more information see [Classic Format Limitations](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf/NetCDF-Classic-Format-Limitations.html#NetCDF-Classic-Format-Limitations).
1239 
1240 The netCDF classic format is also identified as *version 1* or *CDF1* in
1241 reference to the format label at the start of a file.
1242 
1243 With netCDF version 3.6 and later, a second variant of netCDF format is
1244 supported in addition to the classic format. The new variant is referred
1245 to as the *64-bit offset* format, *version 2*, or *CDF-2*. The primary
1246 difference from the classic format is the use of 64-bit file offsets
1247 instead of 32-bit offsets, but it also supports larger variable and
1248 record sizes.
1249 
1250 Starting from version 4.4.0, netCDF added support for CDF-5 format, which
1251 allows multiple large variables with more than 4-billion array elements defined
1252 in the file. This format is only supported on 64-bit machine platforms.
1253 
1254 ----------
1255 
1256 Do I have to know which netCDF file format variant is used in order to access or modify a netCDF file? {#Do-I-have-to-know-which-netCDF-file-format-variant-is-used-in-order-to-access-or-modify-a-netCDF-file}
1257 -----------------
1258 
1259 
1260 No, version 3.6 and later versions of the netCDF C/Fortran library
1261 detect which variant of the format is used for each file when it is
1262 opened for reading or writing, so it is not necessary to know which
1263 variant of the format is used. The version of the format will be
1264 preserved by the library on writing. If you want to modify a classic
1265 format file to use the CDF-2 or CDF-5 format so you can make it much
1266 larger, you will have to create a new file and copy the data to it. The
1267 **nccopy** utility available in version 4.1 can copy a classic file to a
1268 CDF-2 or CDF-5 file.
1269 
1270 ----------
1271 
1272 Will future versions of the netCDF library continue to support accessing files in the classic format? {#Will-future-versions-of-the-netCDF-library-continue-to-support-accessing-files-in-the-classic-format}
1273 -----------------
1274 
1275 
1276 Yes, the 3.6 library and all planned future versions of the library will
1277 continue to support reading and writing files using the classic CDF-1 (32-bit
1278 offset), 64-bit offset CDF-2, and 64-bit data CDF-5 format. There is no need to
1279 convert existing archives from the classic to the 64-bit offset format.
1280 Even netCDF-4, which introduces a third variant of the netCDF format
1281 based on HDF5, continues to support accessing classic CDF-1, 2, and 5 format
1282 files. NetCDF-4 HDF5 files have even fewer restrictions on size than CDF-1 and
1283 CDF-2 files.
1284 
1285 ----------
1286 
1287 Should I start using the new 64-bit offset format for all my netCDF files? {#Should-I-start-using-the-new-64-bit-offset-format-for-all-my-netCDF-files}
1288 -----------------
1289 
1290 
1291 No, we discourage users from making use of the 64-bit offset format
1292 unless they need it for large files. It may be some time until
1293 third-party software that uses the netCDF library is upgraded to 3.6 or
1294 later versions that support the large file facilities, so we advise
1295 continuing to use the classic netCDF format for data that doesn't
1296 require file offsets larger than 32 bits. The library makes this
1297 recommendation easy to follow, since the default for file creation is
1298 the classic format.
1299 
1300 ----------
1301 
1302 How can I tell if a netCDF file uses the classic format (CDF-1), 64-bit offset format (CDF-2) or 64-bit data format (CDF-5)? {#How-can-I-tell-if-a-netCDF-file-uses-the-classic-format-or-64-bit-offset-format}
1303 -----------------
1304 
1305 
1306 The short answer is that under most circumstances, you should not care,
1307 if you use version 3.6.0 or later of the netCDF library. But the
1308 difference is indicated in the first four bytes of the file, which are
1309 'C', 'D', 'F', '\\001' for the classic CDF-1 format, 'C', 'D', 'F',
1310 '\\002' for the 64-bit offset CDF-2 format, and 'C', 'D', 'F', '\\005' for the
1311 64-bit data CDF-5 format. On a Unix system, one way to display the first four
1312 bytes of a file, say foo.nc, is to run the following command:
1313 
1314 ~~~~ {.boldcode}
1315  od -An -c -N4 foo.nc
1316 ~~~~
1317 
1318 which will output
1319 
1320 ~~~~ {.boldcode}
1321  C D F 001
1322 ~~~~
1323 
1324 or
1325 
1326 ~~~~ {.boldcode}
1327  C D F 002
1328 ~~~~
1329 
1330 or
1331 
1332 ~~~~ {.boldcode}
1333  C D F 005
1334 ~~~~
1335 
1336 depending on whether foo.nc is a CDF-1, CDF-2, or CDF-5 netCDF file,
1337 respectively.
1338 
1339 With netCDF version 3.6.2 or later, there is an easier way, using the
1340 "-k" option to **ncdump** to determine the kind of file, for example:
1341 
1342 ~~~~ {.boldcode}
1343  ncdump -k foo.nc
1344  classic
1345 ~~~~
1346 
1347 ----------
1348 
1349 What happens if I create a 64-bit offset format netCDF file and try to open it with an older netCDF application that hasn't been linked with netCDF 3.6? {#What-happens-if-I-create-a-64-bit-offset-format-netCDF-file-and-try-to-open-it-with-an-older-netCDF-application-that-hasnt-been-linked-with-netCDF-36}
1350 -----------------
1351 
1352 
1353 The application will indicate an error trying to open the file and
1354 present an error message equivalent to "not a netCDF file". This is why
1355 it's a good idea not to create 64-bit offset netCDF files until you
1356 actually need them.
1357 
1358 ----------
1359 
1360 Can I create 64-bit offset files on 32-bit platforms? {#Can-I-create-64-bit-offset-files-on-32-bit-platforms}
1361 -----------------
1362 
1363 
1364 Yes, by specifying the appropriate file creation flag you can create
1365 64-bit offset netCDF files the same way on 32-bit platforms as on 64-bit
1366 platforms. You do not need to compile the C/Fortran libraries as 64-bit
1367 to support access to 64-bit offset netCDF files.
1368 
1369 ----------
1370 
1371 How do I create a 64-bit offset netCDF file from C, Fortran-77, Fortran-90, or C++? {#How-do-I-create-a-64-bit-offset-netCDF-file-from-C-Fortran-77-Fortran-90-or-Cpp}
1372 -----------------
1373 
1374 
1375 With netCDF version 3.6.0 or later, use the NC\_64BIT\_OFFSET flag when
1376 you call nc\_create(), as in:
1377 
1378 ~~~~ {.boldcode}
1379  err = nc_create("foo.nc",
1380  NC_NOCLOBBER | NC_64BIT_OFFSET,
1381  &ncid);
1382 ~~~~
1383 
1384 In Fortran-77, use the NF\_64BIT\_OFFSET flag when you call
1385 nf\_create(), as in:
1386 
1387 ~~~~ {.boldcode}
1388  iret = nf_create('foo.nc',
1389  IOR(NF_NOCLOBBER,NF_64BIT_OFFSET),
1390  ncid)
1391 ~~~~
1392 
1393 In Fortran-90, use the NF90\_64BIT\_OFFSET flag when you call
1394 nf90\_create(), as in:
1395 
1396 ~~~~ {.boldcode}
1397  iret = nf90_create(path="foo.nc",
1398  cmode=or(nf90_noclobber,nf90_64bit_offset),
1399  ncid=ncFileID)
1400 ~~~~
1401 
1402 In C++, use the Offset64Bits enum in the NcFile constructor, as in:
1403 
1404 ~~~~ {.boldcode}
1405  NcFile nc("foo.nc",
1406  FileMode=NcFile::New,
1407  FileFormat=NcFile::Offset64Bits);
1408 ~~~~
1409 
1410 In Java, use the setLargeFile() method of the NetcdfFileWritable class.
1411 
1412 ----------
1413 
1414 How do I create a 64-bit offset netCDF file using the ncgen utility? {#How-do-I-create-a-64-bit-offset-netCDF-file-using-the-ncgen-utility}
1415 -----------------
1416 
1417 
1418 A command-line option, '-k', specifies the kind of file format
1419 variant. By default or if '-k classic' is specified, the generated
1420 file will be in netCDF classic format. If '-k 64-bit-offset' is
1421 specified, the generated file will use the 64-bit offset format.
1422 
1423 ----------
1424 
1425 Have all netCDF size limits been eliminated? {#Have-all-netCDF-size-limits-been-eliminated}
1426 -----------------
1427 
1428 
1429 The netCDF-4 HDF5-based format has no practical limits on the size of a
1430 variable.
1431 
1432 However, for the classic and 64-bit offset formats there are still
1433 limits on sizes of netCDF objects. Each fixed-size variable (except the
1434 last, when there are no record variables) and the data for one record's
1435 worth of a single record variable (except the last) are limited in size
1436 to a little less that 4 GiB, which is twice the size limit in versions
1437 earlier than netCDF 3.6.
1438 
1439 The maximum number of records remains 2^32^-1.
1440 
1441 ----------
1442 
1443 Why are variables still limited in size? {#Why-are-variables-still-limited-in-size}
1444 -----------------
1445 
1446 
1447 While most platforms support a 64-bit file offset, many platforms only
1448 support a 32-bit size for allocated memory blocks, array sizes, and
1449 memory pointers. In C developer's jargon, these platforms have a 64-bit
1450 `off_t` type for file offsets, but a 32-bit `size_t` type for size of
1451 arrays. Changing netCDF to assume a 64-bit `size_t` would restrict
1452 netCDF's use to 64-bit platforms.
1453 
1454 ----------
1455 
1456 How can I write variables larger than 4 GiB? {#How-can-I-write-variables-larger-than-4-GiB}
1457 -----------------
1458 
1459 
1460 You can overcome the 4 GiB size barrier by using the netCDF-4 HDF5
1461 format for your data. The only change required to the program that
1462 writes the data is an extra flag to the file creation call, followed by
1463 recompiling and relinking to the netCDF-4 library. Programs that access
1464 the data would also need to be recompiled and relinked to the netCDF-4
1465 library.
1466 
1467 For classic and 64-bit offset netCDF formats, if you change the first
1468 dimension of a variable from a fixed size to an unlimited size instead,
1469 the variable can be much larger. Even though record variables are
1470 restricted to 4 Gib per record, there may be 4 billion records. NetCDF
1471 classic or 64-bit offset files can only have one unlimited dimension, so
1472 this won't work if you are already using a record dimension for other
1473 purposes.
1474 
1475 It is also possible to overcome the 4 GiB variable restriction for a
1476 single fixed size variable, when there are no record variables, by
1477 making it the last variable, as explained in the example in [NetCDF Classic Format Limitations](https://docs.unidata.ucar.edu/nug/current/netcdf_introduction.html#classic_format).
1478 
1479 ----------
1480 
1481 Why do I get an error message when I try to create a file larger than 2 GiB with the new library? {#Why-do-I-get-an-error-message-when-I-try-to-create-a-file-larger-than-2-GiB-with-the-new-library}
1482 -----------------
1483 
1484 
1485 There are several possible reasons why creating a large file can fail
1486 that are not related to the netCDF library:
1487 
1488 - User quotas may prevent you from creating large files. On a Unix
1489  system, you can use the "ulimit" command to report limitations such
1490  as the file-size writing limit.
1491 
1492 - There is insufficient disk space for the file you are trying to
1493  write.
1494 
1495 - The file system in which you are writing may not be configured to
1496  allow large files. On a Unix system, you can test this with a
1497  commands such as
1498 
1499  ~~~~ {.boldcode}
1500  dd if=/dev/zero bs=1000000 count=3000 of=./largefile
1501  ls -l largefile
1502  rm largefile
1503  ~~~~
1504 
1505  which should write a 3 GByte file named "largefile" in the current
1506  directory, verify its size, and remove it.
1507 
1508 If you get the netCDF library error "One or more variable sizes violate
1509 format constraints", you are trying to define a variable larger than
1510 permitted for the file format variant. This error typically occurs when
1511 leaving "define mode" rather than when defining a variable. The error
1512 status cannot be returned when a variable is first defined, because the
1513 last fixed-size variable defined is permitted to be larger than other
1514 fixed-size variables (when there are no record variables).
1515 
1516 Similarly, the last record variable may be larger than other record
1517 variables. This means that subsequently adding a small variable to an
1518 existing file may be invalid, because it makes what was previously the
1519 last variable now in violation of the format size constraints. For
1520 details on the format size constraints, see the Users Guide sections
1521 [NetCDF Classic Format Limitations](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf.html#Classic-Limitations) and [NetCDF 64-bit Offset Format Limitations](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf.html#64-bit-Offset-Limitations).
1522 
1523 If you get the netCDF library error "Invalid dimension size" for a
1524 non-negative size, you are exceeding the size limit of netCDF
1525 dimensions, which must be less than 2,147,483,644 for classic files with
1526 no large file support and otherwise less than 4,294,967,292.
1527 
1528 ----------
1529 
1530 Do I need to use special compiler flags to compile and link my applications that use netCDF with Large File Support? {#Do-I-need-to-use-special-compiler-flags-to-compile-and-link-my-applications-that-use-netCDF-with-Large-File-Support}
1531 -----------------
1532 
1533 
1534 No, except that 32-bit applications should link with a 32-bit version of
1535 the library and 64-bit applications should link with a 64-bit library,
1536 similarly to use of other libraries that can support either a 32-bit or
1537 64-bit model of computation. But note that a 32-bit version of the
1538 netCDF library fully supports writing and reading 64-bit offset netCDF
1539 files.
1540 
1541 ----------
1542 
1543 Is it possible to create a "classic" format netCDF file with netCDF version 3.6.0 that cannot be accessed by applications compiled and linked against earlier versions of the library? {#isitpossibleclassic360}
1544 ----------------
1545 
1546 No, classic files created with the new library should be compatible with
1547 all older applications, both for reading and writing, with one minor
1548 exception. The exception is due to a correction of a netCDF bug that
1549 prevented creating records larger than 4 GiB in classic netCDF files
1550 with software linked against versions 3.5.1 and earlier. This limitation
1551 in total record size was not a limitation of the classic format, but an
1552 unnecessary restriction due to the use of too small a type in an
1553 internal data structure in the library.
1554 
1555 If you want to always make sure your classic netCDF files are readable
1556 by older applications, make sure you don't exceed 4 GiBytes for the
1557 total size of a record's worth of data. (All records are the same size,
1558 computed by adding the size for a record's worth of each record
1559 variable, with suitable padding to make sure each record begins on a
1560 byte boundary divisible by 4.)
1561 
1562 ----------
1563 
1564 NetCDF and Other Software {#NetCDF-and-Other-Software}
1565 ================
1566 
1567 What other software is available for accessing, displaying, and manipulating netCDF data? {#What-other-software-is-available-for-accessing-displaying-and-manipulating-netCDF-data}
1568 -----------------
1569 
1570 
1571 Utilities available in the current netCDF distribution from Unidata are
1572 **ncdump**, for converting netCDF files to an ASCII human-readable form,
1573 and **ncgen** for converting from the ASCII human-readable form back to
1574 a binary netCDF file or a C or FORTRAN program for generating the netCDF
1575 file. [Software for Manipulating or Displaying NetCDF Data](software.html) provides a list of other software useful for access, visualization, and analysis of netCDF data and data represented in other forms. Another useful [guide to netCDF utilities](http://nomads.gfdl.noaa.gov/sandbox/products/vis/data/netcdf/GFDL_VG_NetCDF_Utils.html) is available from NOAA's Geophysical Fluid Dynamics Laboratory.
1576 
1577 ----------
1578 
1579 What other data access interfaces and formats are available for scientific data? {#What-other-data-access-interfaces-and-formats-are-available-for-scientific-data}
1580 -----------------
1581 
1582 
1583 The [Scientific Data Format Information FAQ](http://www.cv.nrao.edu/fits/traffic/scidataformats/faq.html) provides a somewhat dated description of other access interfaces and formats for scientific data, including [CDF](http://nssdc.gsfc.nasa.gov/cdf/cdf_home.html) and [HDF](http://hdf.ncsa.uiuc.edu/). A brief comparison of CDF, netCDF, and HDF is available in the [CDF FAQ](http://nssdc.gsfc.nasa.gov/cdf/html/FAQ.html). Another comparison is in Jan Heijmans' [An Introduction to Distributed Visualization](http://www.xi-advies.nl/downloads/AnIntroductionToDistributedVisualization.pdf). John May's book [*Parallel I/O for High Performance Computing*](http://www.llnl.gov/CASC/news/johnmay/John_May_book.html) includes a chapter on Scientific Data Libraries that describes netCDF and HDF5, with example source code for reading and writing files using both interfaces.
1584 
1585 ----------
1586 
1587 What is the connection between netCDF and CDF? {#What-is-the-connection-between-netCDF-and-CDF}
1588 -----------------
1589 
1590 
1591 [CDF](http://cdf.gsfc.nasa.gov/) was developed at the NASA Space Science
1592 Data Center at Goddard, and is freely available. It was originally a VMS
1593 FORTRAN interface for scientific data access. Unidata reimplemented the
1594 library from scratch to use [XDR](http://www.faqs.org/rfcs/rfc1832.html)
1595 for a machine-independent representation, designed the
1596 [CDL](https://docs.unidata.ucar.edu/netcdf/NUG/_c_d_l.html) (network Common Data form Language) text
1597 representation for netCDF data, and added aggregate data access, a
1598 single-file implementation, named dimensions, and variable-specific
1599 attributes.
1600 
1601 NetCDF and CDF have evolved independently. CDF now supports many of the
1602 same features as netCDF (aggregate data access, XDR representation,
1603 single-file representation, variable-specific attributes), but some
1604 differences remain (netCDF doesn't support native-mode representation,
1605 CDF doesn't support named dimensions). There is no compatibility between
1606 data in CDF and netCDF form, but NASA makes available [some
1607 translators](http://cdf.gsfc.nasa.gov/html/dtws.html) between various
1608 scientific data formats. For a more detailed description of differences
1609 between CDF and netCDF, see the [CDF FAQ](http://cdf.gsfc.nasa.gov/html/FAQ.html).
1610 
1611 ----------
1612 
1613 What is the connection between netCDF and HDF? {#What-is-the-connection-between-netCDF-and-HDF}
1614 -----------------
1615 
1616 
1617 The National Center for Supercomputing Applications (NCSA) originally
1618 developed [HDF4](http://hdf.ncsa.uiuc.edu/) and made it freely
1619 available. HDF4 is an extensible data format for self-describing files
1620 that was developed independently of netCDF. HDF4 supports both C and
1621 Fortran interfaces, and it has been successfully ported to a wide
1622 variety of machine architectures and operating systems. HDF4 emphasizes
1623 a single common format for data, on which many interfaces can be built.
1624 
1625 NCSA implemented software that provided a netCDF-2 interface to HDF4.
1626 With this software, it was possible to use the netCDF calling interface
1627 to place data into an HDF4 file.
1628 
1629 HDF5, developed and supported by The HDF Group, Inc., a non-profit
1630 spin-off from the NCSA group, provides a richer data model, with
1631 emphasis on efficiency of access, parallel I/O, and support for
1632 high-performance computing. The netCDF-4 project has implemented an
1633 enhanced netCDF interface on the HDF5 storage layer to preserve the
1634 desirable common characteristics of netCDF and HDF5 while taking
1635 advantage of their separate strengths: the widespread use and simplicity
1636 of netCDF and the generality and performance of HDF5.
1637 
1638 ----------
1639 
1640 Has anyone implemented client-server access for netCDF data? {#Has-anyone-implemented-client-server-access-for-netCDF-data}
1641 -----------------
1642 
1643 
1644 Yes, as part of the [OPeNDAP](http://www.opendap.org/) framework,
1645 developers have implemented a client-server system for access to remote
1646 data that supports use of the netCDF interface for clients. A reference
1647 version of the software is available from the [OPeNDAP download site](http://www.opendap.org/download/index.html/). After linking your netCDF application with the OPeNDAP netCDF library, you can use URL's to access data from other sites running an OPeNDAP server. This supports accessing small subsets of large datasets remotely through the netCDF interfaces, without copying the datasets.
1648 
1649 The 4.1 release of netCDF will include OPeNDAP client support; an
1650 experimental version is available now in the snapshot distributions.
1651 
1652 Other clients and servers support access through a netCDF interface to
1653 netCDF and other kinds of data, including clients written using the
1654 [netCDF-Java library](https://www.unidata.ucar.edu/software/netcdf-java/) and servers that use the
1655 [THREDDS Data Server](https://www.unidata.ucar.edu/software/tds/).
1656 
1657 The [GrADS Data Server](http://grads.iges.org/grads/gds/) provides
1658 subsetting and analysis services across the Internet for any
1659 GrADS-readable dataset, including suitable netCDF datasets. The latest
1660 version of the [PMEL Live Access Server](http://ferret.pmel.noaa.gov/LAS) uses THREDDS Data Server technology to provide flexible access to geo-referenced scientific data, including netCDF data.
1661 
1662 ----------
1663 
1664 How do I convert between GRIB and netCDF? {#How-do-I-convert-between-GRIB-and-netCDF}
1665 -----------------
1666 
1667 
1668 Several programs and packages have been developed that convert between
1669 [GRIB](http://www.wmo.ch/web/www/DPS/grib-2.html) and netCDF data:
1670 [ncl_convert2nc](http://www.ncl.ucar.edu/Applications/grib2netCDF.shtml),
1671 [degrib](http://www.nws.noaa.gov/mdl/NDFD_GRIB2Decoder/),
1672 [CDAT](software.html#CDAT), [CDO](software.html#CDO),
1673 [GDAL](http://www.gdal.org/), [GrADS](software.html#GrADS), and
1674 [wgrib2](http://www.cpc.noaa.gov/products/wesley/wgrib2/).
1675 
1676 The Unidata [netCDF Java Library](https://www.unidata.ucar.edu/software/netcdf-java/) can
1677 read GRIB1 and GRIB2 data (and many other data formats) through a netCDF
1678 interface. As a command-line example, you could convert *fileIn.grib* to
1679 *fileOut.nc* as follows:
1680 
1681 ~~~~ {.boldcode}
1682  java -Xmx1g -classpath netcdfAll-4.3.jar ucar.nc2.dataset.NetcdfDataset \
1683  -in fileIn.grib -out fileOut.nc [-isLargeFile] [-netcdf4]
1684 ~~~~
1685 
1686 For more details on using netCDF Java, see the CDM man pages for
1687 [nccopy](https://www.unidata.ucar.edu/software/netcdf-java/reference/manPages.html#nccopy).
1688 
1689 ----------
1690 
1691 Problems and Bugs
1692 -----------------
1693 
1694 Can I recover data from a netCDF file that was not closed properly? {#Can-I-recover-data-from-a-netCDF-file-that-was-not-closed-properly}
1695 -----------------
1696 
1697 
1698 _I have some netcdf files which have data in them and were apparently
1699 not properly closed. When I examine them using **ncdump** they report zero
1700 data points, although the size is a few megabytes. Is there a way of
1701 recovering them?_
1702 
1703 If the files are in classic format or 64-bit offset format (if they were
1704 created by netCDF version 3.6.3 or earlier, for example), then you can
1705 use an editor that allows you to change binary files, such as emacs, to
1706 correct the four-byte number of records field in the file. This is a
1707 bigendian 4 byte integer that begins at the 4th byte in the file.
1708 
1709 This is what the first eight bytes would look like for classic format if
1710 you had zero records, where printable characters are specified as
1711 US-ASCII characters within single-quotes and non-printable bytes are
1712 denoted using a hexadecimal number with the notation '\\xDD', where each
1713 D is a hexadecimal digit:
1714 
1715 ~~~~ {.boldcode}
1716  'C' 'D' 'F' \x01 \x00 \x00 \x00 \x00
1717 ~~~~
1718 
1719 or
1720 
1721 ~~~~ {.boldcode}
1722  'C' 'D' 'F' \x02 \x00 \x00 \x00 \x00
1723 ~~~~
1724 
1725 for 64-bit-offset format.
1726 
1727 And this is what the first eight bytes should look like for classic
1728 format if you had 500 records (500 is 01F4 in hexadecimal)
1729 
1730 ~~~~ {.boldcode}
1731  'C' 'D' 'F' \x01 \x00 \x01 \x0f \x04
1732 ~~~~
1733 
1734 or
1735 
1736 ~~~~ {.boldcode}
1737  'C' 'D' 'F' \x02 \x00 \x01 \x0f \x04
1738 ~~~~
1739 
1740 for 64-bit-offset format.
1741 
1742 So if you can compute how many records should be in the file, you can
1743 edit the second four bytes to fix this. You can find out how many
1744 records should be in the file from the size of the file and from the
1745 variable types and their shapes. See the [description of the netCDF format](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf.html#File-Format)
1746 for classic and 64-bit offset files for how to figure out how large the
1747 file should be for fixed sized variables of particular shapes and for a
1748 specified number of record variables of particular shapes.
1749 
1750 Note that if you neglected to call the appropriate netCDF close function
1751 on a file, data in the last record written but not flushed to the disk
1752 may also be lost, but correcting the record count should allow recovery
1753 of the other records.
1754 
1755 ----------
1756 
1757 Is there a list of reported problems and workarounds? {#Is-there-a-list-of-reported-problems-and-workarounds}
1758 -----------------
1759 
1760 
1761 Yes, the document [Known problems with the netCDF Distribution](known_problems.html) describes reported problems and workarounds in the latest version and some earlier releases.
1762 
1763 ----------
1764 
1765 How do I make a bug report? {#How-do-I-make-a-bug-report}
1766 -----------------
1767 
1768 
1769 If you find a bug, send a description to
1770 support-netcdf@unidata.ucar.edu. This is also the address to use for
1771 questions or discussions about netCDF that are not appropriate for the
1772 entire netcdfgroup mailing list.
1773 
1774 ----------
1775 
1776 How do I search through past problem reports? {#How-do-I-search-through-past-problem-reports}
1777 -----------------
1778 
1779 
1780 A search link is available at the bottom of the [netCDF homepage](https://www.unidata.ucar.edu/software/netcdf/), providing a full-text search of the
1781 support questions and answers about netCDF provided by Unidata support
1782 staff.
1783 
1784 ----------
1785 
1786 Programming with NetCDF {#Programming-with-NetCDF}
1787 ================
1788 
1789 Which programming languages have netCDF interfaces? {#Which-programming-languages-have-netCDF-interfaces}
1790 -----------------
1791 
1792 The netCDF distribution comes with interfaces for C, Fortran77,
1793 Fortran90, and C++. Other languages for which interfaces are available
1794 separately include:
1795 
1796 - [Ada](http://freshmeat.net/projects/adanetcdf/)
1797 - [IDL](software.html#IDL)
1798 - [Java](software.html#Java%20interface)
1799 - [MATLAB](software.html#MATLAB)
1800 - [Perl](software.html#Perl)
1801 - [Python](software.html#Python)
1802 - [R](software.html#R)
1803 - [Ruby](software.html#Ruby)
1804 - [Tcl/Tk](software.html#Tcl/Tk)
1805 
1806 ----------
1807 
1808 Are the netCDF libraries thread-safe? {#Are-the-netCDF-libraries-thread-safe}
1809 -----------------
1810 
1811 The C-based libraries are *not* thread-safe. C-based libraries are those
1812 that depend on the C library, which currently include all language
1813 interfaces except for the Java interface. The Java interface is
1814 thread-safe when a few simple rules are followed, such as each thread
1815 getting their handle to a file.
1816 
1817 ----------
1818 
1819 How does the C++ interface differ from the C interface? {#How-does-the-Cpp-interface-differ-from-the-C-interface}
1820 -----------------
1821 
1822 It provides all the functionality of the C interface (except for the
1823 generalized mapped access of ncvarputg() and ncvargetg()) and is
1824 somewhat simpler to use than the C interface. With the C++ interface, no
1825 IDs are needed for netCDF components, there is no need to specify types
1826 when creating attributes, and less indirection is required for dealing
1827 with dimensions. However, the C++ interface is less mature and
1828 less-widely used than the C interface, and the documentation for the C++
1829 interface is less extensive, assuming a familiarity with the netCDF data
1830 model and the C interface. Recently development of the C++ interface has
1831 languished as resources have been redirected to enhancing the Java
1832 interface.
1833 
1834 ----------
1835 
1836 How does the Fortran interface differ from the C interface? {#How-does-the-Fortran-interface-differ-from-the-C-interface}
1837 -----------------
1838 
1839 It provides all the functionality of the C interface. The Fortran
1840 interface uses Fortran conventions for array indices, subscript order,
1841 and strings. There is no difference in the on-disk format for data
1842 written from the different language interfaces. Data written by a C
1843 language program may be read from a Fortran program and vice-versa. The
1844 Fortran-90 interface is much smaller than the FORTRAN 77 interface as a
1845 result of using optional arguments and overloaded functions wherever
1846 possible.
1847 
1848 ----------
1849 
1850 How do the Java, Perl, Python, Ruby, ... interfaces differ from the C interface? {#How-do-the-Java-Perl-Python-Ruby-interfaces-differ-from-the-C-interface}
1851 -----------------
1852 
1853 They provide all the functionality of the C interface, using appropriate
1854 language conventions. There is no difference in the on-disk format for
1855 data written from the different language interfaces. Data written by a C
1856 language program may be read from programs that use other language
1857 interfaces, and vice-versa.
1858 
1859 ----------
1860 
1861 How do I handle errors in C? {#How-do-I-handle-errors-in-C}
1862 -----------------
1863 
1864 For clarity, the NetCDF C Interface Guide contains examples which use a
1865 function called handle\_err() to handle potential errors like this:
1866 
1867 ~~~~ {.boldcode}
1868  status = nc_create("foo.nc", NC_NOCLOBBER, &ncid);
1869  if (status != NC_NOERR) handle_error(status);
1870 ~~~~
1871 
1872 Most developers use some sort of macro to invoke netCDF functions and
1873 test the status returned in the calling context without a function call,
1874 but using such a macro in the User's Guides arguably makes the examples
1875 needlessly complex. For example, some really excellent developers define
1876 an "ERR" macro and write code like this:
1877 
1878 ~~~~ {.boldcode}
1879  if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
1880 ~~~~
1881 
1882 where Err is defined in a header file:
1883 
1884 ~~~~ {.boldcode}
1885 /* This macro prints an error message with line number and name of
1886  * test program. */
1887 #define ERR do { \
1888 fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
1889 err++; \
1890 fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
1891  __FILE__, __LINE__); \
1892 } while (0)
1893 ~~~~
1894 
1895 Ultimately, error handling depends on the application which is calling
1896 netCDF functions. However we strongly suggest that some form of error
1897 checking be used for all netCDF function calls.
1898 
1899 ----------
1900 
1901 
1902 CMake-Related Frequently Asked Questions {#cmake_faq}
1903 ========================================
1904 
1905 Below are a list of commonly-asked questions regarding NetCDF and CMake.
1906 
1907 How can I see the options available to CMake? {#listoptions}
1908 ---------------------------------------------
1909 
1910  $ cmake [path to source tree] -L - This will show the basic options.
1911  $ cmake [path to source tree] -LA - This will show the basic and advanced options.
1912 
1913 
1914 How do I specify how to build a shared or static library? {#sharedstatic}
1915 --------------------------------------------------------
1916 
1917  This is controlled with the internal `cmake` option, `BUILD_SHARED_LIBS`.
1918 
1919  $ cmake [Source Directory] -DBUILD_SHARED_LIBS=[ON/OFF]
1920 
1921 
1922 Can I build both shared and static libraries at the same time with cmake? {#sharedstaticboth}
1923 -------------------------------------------------------------------------
1924 
1925 Not at this time; it is required to instead build first one version, and then the other, if you need both.
1926 
1927 How can I specify linking against a particular library? {#partlib}
1928 -------------------------------------------------------
1929 
1930 For most libraries, you can specify `<library name>_ROOT`. To specify
1931 custom `ZLib` and `HDF5`, for example, you would do the following:
1932 
1933  $ cmake [Source Directory] \
1934  -DZLIB_ROOT=/path/to/zlib/install \
1935  -DHDF5_ROOT=/path/to/hdf5/install
1936 
1937 
1938 What if I want to link against multiple libraries in a non-standard location {#nonstdloc}
1939 ----------------------------------------------------------------------------
1940 
1941  You can specify the path to search when looking for dependencies and header files using the `CMAKE_PREFIX_PATH` variable:
1942 
1943 * Windows:
1944 
1945  $ cmake [Source Directory] -DCMAKE_PREFIX_PATH=c:\shared\libs\
1946 
1947 
1948 * Linux/Unix/OSX:
1949 
1950  $ cmake [Source Directory] -DCMAKE_PREFIX_PATH=/usr/custom_library_locations/
1951 
1952 How can I specify a Parallel Build using HDF5 {#parallelhdf}
1953 ----------------------------------------------
1954 
1955 If cmake is having problems finding the parallel `HDF5` install, you can specify the location manually:
1956 
1957  $ cmake [Source Directory] -DENABLE_PARALLEL=ON \
1958  -DHDF5_ROOT=/usr/lib64/openmpi/lib/
1959 
1960 You will, of course, need to use the location of the libraries specific to your development environment.
1961 
1962 ----------------
1963 
1964 Plans {#Plans}
1965 ================
1966 
1967 What other future work on netCDF is planned? {#What-other-future-work-on-netCDF-is-planned}
1968 -----------------
1969 
1970 Issues, bugs, and plans for netCDF are maintained in the Unidata issue
1971 tracker sites for
1972 [netCDF-C](https://github.com/Unidata/netcdf-c/issues), [Common Data Model / NetCDF-Java](https://github.com/Unidata/netcdf-java/issues),
1973 [netCDF-Fortran](https://github.com/Unidata/netcdf-fortran/issues),
1974 and [netCDF-CXX4](https://github.com/Unidata/netcdf-cxx4/issues), and