NetCDF  4.5.0
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](http://www.unidata.ucar.edu/software/netcdf/docs/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 - *Sharable*. 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](http://www.unidata.ucar.edu/software/netcdf/docs/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](/downloads/netcdf/index.jsp). 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](http://www.unidata.ucar.edu/software/netcdf/docs/building.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 \ref 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](http://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](http://www.unidata.ucar.edu/software/netcdf/docs/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](http://www.unidata.ucar.edu/software/netcdf/docs/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](http://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](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf/Differences-between-Attributes-and-Variables.html#Differences%20between%20Attributes%20and%20Variables))
143 and in a new web document [Writing NetCDF Files: BestPractices](http://www.unidata.ucar.edu/software/netcdf/BestPractices.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](http://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 [http://www.unidata.ucar.edu/software/netcdf/time/](http://www.unidata.ucar.edu/software/netcdf/time/).
208 
209 A summary of Unidata's recommendations is available from
210 [http://www.unidata.ucar.edu/software/netcdf/time/recs.html](http://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 [http://www.unidata.ucar.edu/software/netcdf/conventions.html](http://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](http://www.unidata.ucar.edu/software/netcdf/docs/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 [http://www.unidata.ucar.edu/software/netcdf/usage.html](http://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](http://www.unidata.ucar.edu/software/netcdf/docs/).
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](http://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](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf.html#File-Format) with the same format specification.
302 
303 The ["NetCDF File Structure and Performance"](http://www.unidata.ucar.edu/software/netcdf/docs/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](@ref getting_and_building_netcdf) 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 [http://www.unidata.ucar.edu/software/netcdf/docs/winbin.html](http://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](http://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2011/msg00363.html).
402 
403 User Veit Eitner has contributed a port of 4.1.1 to Visual Studio,
404 including an F90 port to Intel Fortran. Download [source (ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/netcdf-4.1.1-win32-src.zip)](ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/netcdf-4.1.1-win32-src.zip) or [binary](ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/netcdf-4.1.1-win32-bin.zip) versions. This port was done before the code was refactored in 4.1.2.
405 
406 How can I use netCDF-4 with Windows? {#How-can-I-use-netCDF-4-with-Windows}
407 -----------------
408 
409 
410 Note that we have not ported the F90 or C++ APIs to the Windows
411 platform, only the C and F77 APIs. User contributions of ports to F90
412 windows compilers are very welcome (send them to
413 support-netcdf@unidata.ucar.edu).
414 
415 On windows, NetCDF consists of a DLL and the ncgen/ncdump executables.
416 The easiest course is to download one of the pre-built DLLs and
417 utilities and just install them on your system.
418 
419 Unlike Unix builds, the Visual Studio build **always** requires HDF5,
420 zlib, and szlib in all cases. All Windows DLL users must also have the
421 HDF5, zlib, and szlib DLLs. These are now available from the Unidata FTP
422 site:
423 
424 - [zlib DLLs for 32-bit Windows](ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/zlib123-vs2005.zip)
425 - [szlib DLLs for 32-bit Windows](ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/szip21-vs6-enc.zip)
426 - [HDF5 DLLs for 32-bit Windows](ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/5-181-win-vs2005.zip)
427 
428 Two versions of the netCDF DLLs are available, for different Fortran
429 compilers:
430 
431 - [NetCDF for Intel and Portland Group Fortran compilers.](ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/win32_vs_PGI_dll_4.0.1.zip)
432 - [NetCDF for other Fortran compilers.](ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/win32_vs_f2c_dll_4.0.1.zip)
433 
434 To use netCDF, install the DLLs in /system/win32 and the .h files in a
435 directory known to your compiler, and define the DLL\_NETCDF
436 preprocessor macro before including netcdf.h.
437 
438 The netCDF-4 library can also be built using Visual Studio 2008. Open
439 the solution file win32/NET/netcdf.sln.
440 
441 If you install the header files in \\include directory, the netCDF
442 solution file will work without modifications. Otherwise the properties
443 of the netcdf project must be changed to include the proper header
444 directory.
445 
446 Both the debug and release builds work. The release build links to
447 different system libraries on Windows, and will not allow debuggers to
448 step into netCDF library code. This is the build most users will be
449 interested in. The debug build is probably of interest only to netCDF
450 library developers.
451 
452 As of version 4.0.1 (March 2009), the DLL build does not yet include any
453 testing of the extended netCDF-4 data model. The netCDF4/HDF5 format is
454 extensively tested in the classic model, but tests for groups,
455 user-defined types, and other features of the expanded netCDF-4 data
456 model have not yet been ported to Windows.
457 
458 The [NetCDF Installation and Porting Guide](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/index.html) documents how to
459 use netCDF with Windows.
460 
461 Some users have built and released netCDF with Intel Fortran on Windows.
462 See the [ifort entry in other builds document](http://www.unidata.ucar.edu/software/netcdf/docs/other-builds.html#ifort-361-windows).
463 
464 Windows is a complicated platform to build on. Some useful explanations
465 of the oddities of Windows can be found here:
466 
467 - Cygwin documentation for [Building and Using DLLs](http://cygwin.com/cygwin-ug-net/dll.html)
468 - [OpenLDAP FAQ answer: MinGW Support in Cygwin](http://www.openldap.org/faq/data/cache/301.html), by Jon
469  Leichter.
470 - [cygwin mailing list explanation of Windows DL requirements.](http://cygwin.com/ml/cygwin/2000-06/msg00688.html)
471 - [-mno-cygwin - Building Mingw executables using Cygwin](http://www.delorie.com/howto/cygwin/mno-cygwin-howto.html)
472 
473 Once you have the netCDF DLL, you may wish to call it from Visual Basic.
474 The [netCDF VB wrapper](ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/netcdf_vb_net_wrapper.zip) will help you do this.
475 
476 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).
477 
478 ----------
479 
480 How do I build and install netCDF for a specific development environment? {#How-do-I-build-and-install-netCDF-for-a-specific-development-environment}
481 -----------------
482 
483 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.
484 
485 For more details, see
486 [NetCDF Installation and Porting Guide](@ref getting_and_building_netcdf).
487 
488 
489 ----------
490 
491 How can I tell if I successfully built and installed netCDF? {#How-can-I-tell-if-I-successfully-built-and-installed-netCDF}
492 -----------------
493 
494 
495 We make build output from various platforms [available](../builds) for
496 comparison with your output. In general, you can ignore compiler
497 warnings if the "make test" step is successful. Lines that begin with
498 "\*\*\*" in the "make test" output indicate results from tests. The C
499 and Fortran-77 interfaces are tested extensively, but only rudimentary
500 tests are currently used for the C++ and Fortran-90 interfaces.
501 
502 How can I tell what version I'm using? {#How-can-I-tell-what-version-Im-using}
503 -----------------
504 
505 
506 If you invoke
507 
508 ~~~~ {.boldcode}
509  ncdump --version
510 ~~~~
511 
512 the last line of the resulting output will identify the version
513 associated with the **ncdump** utility. You can also call one of the
514 functions `nc_inq_libvers()`, `nf_inq_libvers()`, or
515 `nf90_inq_libvers()` from C, Fortran-77, or Fortran-90 programs to get a
516 version string.
517 
518 ----------
519 
520 Where does netCDF get installed? {#Where-does-netCDF-get-installed}
521 -----------------
522 
523 
524 The netCDF installation directory can be set at the time configure is
525 run using the --prefix argument. If it is not specified, /usr/local is
526 used as the default prefix.
527 
528 For more information see the [NetCDF Installation and Porting Guide](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install).
529 
530 Formats, Data Models, and Software Releases {#formatsdatamodelssoftwarereleases}
531 ===========================================
532 
533 In different contexts, "netCDF" may refer to a data model, a software
534 implementation with associated application program interfaces (APIs), or
535 a data format. Confusion may arise in discussions of different versions
536 of the data models, software, and formats. For example, compatibility
537 commitments require that new versions of the software support all
538 previous versions of the format and data model. This section of FAQs is
539 intended to clarify netCDF versions and help users determine what
540 version to build and install.
541 
542 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}
543 -----------------
544 
545 
546 There are four netCDF format variants:
547 
548 - the classic format
549 - the 64-bit offset format
550 - the netCDF-4 format
551 - the netCDF-4 classic model format
552 
553 (In addition, there are two textual representations for netCDF data,
554 though these are not usually thought of as formats: CDL and NcML.)
555 
556 The **classic format** was the only format for netCDF data created
557 between 1989 and 2004 by the reference software from Unidata. It is
558 still the default format for new netCDF data files, and the form in
559 which most netCDF data is stored.
560 
561 In 2004, the **64-bit offset format** variant was added. Nearly
562 identical to netCDF classic format, it allows users to create and access
563 far larger datasets than were possible with the original format. (A
564 64-bit platform is not required to write or read 64-bit offset netCDF
565 files.)
566 
567 In 2008, the **netCDF-4 format** was added to support per-variable
568 compression, multiple unlimited dimensions, more complex data types, and
569 better performance, by layering an enhanced netCDF access interface on
570 top of the HDF5 format.
571 
572 At the same time, a fourth format variant, **netCDF-4 classic model
573 format**, was added for users who needed the performance benefits of the
574 new format (such as compression) without the complexity of a new
575 programming interface or enhanced data model.
576 
577 With each additional format variant, the C-based reference software from
578 Unidata has continued to support access to data stored in previous
579 formats transparently, and to also support programs written using
580 previous programming interfaces.
581 
582 Although strictly speaking, there is no single "netCDF-3 format", that
583 phrase is sometimes used instead of the more cumbersome but correct
584 "netCDF classic or 64-bit offset format" to describe files created by
585 the netCDF-3 (or netCDF-1 or netCDF-2) libraries. Similarly "netCDF-4
586 format" is sometimes used informally to mean "either the general
587 netCDF-4 format or the restricted netCDF-4 classic model format". We
588 will use these shorter phrases in FAQs below when no confusion is
589 likely.
590 
591 A more extensive description of the netCDF formats and a formal
592 specification of the classic and 64-bit formats is available as a [NASA ESDS community standard](https://earthdata.nasa.gov/sites/default/files/esdswg/spg/rfc/esds-rfc-011/ESDS-RFC-011v2.00.pdf).
593 
594 How can I tell which format a netCDF file uses? {#How-can-I-tell-which-format-a-netCDF-file-uses}
595 -----------------
596 
597 
598 The short answer is that under most circumstances, you should not care,
599 if you use version 4.0 or later of the netCDF library to access data in
600 the file. But the difference is indicated in the first four bytes of the
601 file, which are 'C', 'D', 'F', '\\001' for the classic netCDF format;
602 'C', 'D', 'F', '\\002' for the 64-bit offset format; or '\\211', 'H',
603 'D', 'F' for an HDF5 file, which could be either a netCDF-4 file or a
604 netCDF-4 classic model file. (HDF5 files may also begin with a
605 user-block of 512, 1024, 2048, ... bytes before what is actually an
606 8-byte signature beginning with the 4 bytes above.)
607 
608 With netCDF version 4.0 or later, there is an easy way that will
609 distinguish between netCDF-4 and netCDF-4 classic model files, using the
610 "-k" option to **ncdump** to determine the kind of file, for example:
611 
612 ~~~~~ {.boldcode}
613  ncdump -k foo.nc
614  classic
615 ~~~~~
616 
617 
618 In a program, you can call the function
619 [nc_inq_format](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c.html#nc_005finq-Family)(or [nf90_inq_format](http://www.unidata.ucar.edu/software/netcdf/docs/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.
620 
621 Finally, on a Unix system, one way to display the first four bytes of a
622 file, say foo.nc, is to run the following command:
623 
624 ~~~~ {.boldcode}
625  od -An -c -N4 foo.nc
626 ~~~~
627 
628 which will output
629 
630 ~~~~ {.boldcode}
631  C D F 001
632 ~~~~
633 
634 ~~~~ {.boldcode}
635  C D F 002
636 ~~~~
637 
638 ~~~~ {.boldcode}
639  211 H D F
640 ~~~~
641 
642 depending on whether foo.nc is a classic, 64-bit offset, or netCDF-4
643 file, respectively. This method cannot be used to distinguish between
644 netCDF-4 and netCDF-4 classic model variants, or between a netCDF-4 file
645 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 model](/netcdf/workshops/2008/datamodel/NcClassicModel.html) and the [enhanced model](/netcdf/workshops/2008/netcdf4/Nc4DataModel.html) (also called the netCDF-4 data model). The classic model is the simpler of the two, and is used for all data stored in classic format, 64-bit offset format, or netCDF-4 classic model format. The enhanced model (sometimes also referred to as the netCDF-4 data model) is an extension of the classic model that adds more powerful forms of data representation and
653 data types at the expense of some additional complexity. Although data represented with the classic model can also be represented using the enhanced model, datasets that use enhanced model features, such as user-defined data types, cannot be represented with the classic model. Use of the enhanced model requires storage in the netCDF-4 format.
654 
655 How many releases of the C-based netCDF software are supported? {#How-many-releases-of-the-C-based-netCDF-software-are-supported}
656 -----------------
657 
658 
659 When netCDF version 4.0 was released in June 2008, version 3.6.3 was
660 released simultaneously, and both releases were supported by Unidata.
661 Version 3.6.3 supported only the classic and 64-bit offset formats.
662 Version 4.0 supported both of those format variants by default, and also
663 the netCDF-4 and netCDF-4 classic model formats, if built using a
664 previously installed HDF5 library and using the "--enable-netcdf-4"
665 configure option. Software built from the netCDF-4.0 release without
666 specifying "--enable-netcdf-4" (the default) was identical to software
667 built with netCDF-3.6.3.
668 
669 Both netCDF-3 and netCDF-4 C libraries are part of a single software
670 release. The netCDF software may be built to support just the classic
671 and 64-bit offset formats (the default) or to also support the netCDF-4
672 and netCDF-4 classic model formats, if the HDF5-1.8.x library is
673 installed. Unidata no longer supports a separate netCDF-3-only version
674 of the software, but instead supports both the classic and enhanced data
675 models and all four format variants in a single source distribution.
676 
677 This does not indicate any plan to drop support for netCDF-3 or the
678 formats associated with netCDF-3. Support for earlier formats and APIs
679 will continue with all future versions of netCDF software from Unidata.
680 
681 Should I get netCDF-3 or netCDF-4? {#Should-I-get-netCDF-3-or-netCDF-4}
682 -----------------
683 
684 
685 By downloading a current version of netCDF-4, you have the choice to
686 build either
687 
688 - the default netCDF-3 libraries, which support classic and 64-bit
689  offset formats, and the classic data model; or
690 - the netCDF-4 libraries, which support netCDF-4 and netCDF-4 classic
691  model formats, as well as classic and 64-bit offset formats, and the
692  enhanced data model.
693 
694 Which version to build depends on how you will use the software.
695 
696 Installing the simpler netCDF-3 version of the software is recommended
697 if the following situations apply:
698 
699 - all the data you need to access is available in netCDF classic or
700  64-bit offset formats
701 - you are installing netCDF in order to support another software
702  package that uses only netCDF-3 features
703 - you plan to only write data in a form that netCDF-3 software and
704  applications can access
705 - you want to delay upgrading to support netCDF-4 until netCDF-4
706  formats are more widely used
707 - you cannot install the prerequisite HDF5 1.8 software required to
708  build and install netCDF-4
709 
710 Installing the netCDF-4 version of the software is required for any of
711 the following situations:
712 
713 - you need to access netCDF data that makes use of netCDF-4
714  compression or chunking
715 - you need to access data in all netCDF formats including netCDF-4 or
716  netCDF-4 classic model formats
717 - 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?"](http://www.unidata.ucar.edu/software/netcdf/docs/faq.html#Large%20File%20Support10))
718 - you are installing netCDF to support other software packages that
719  require netCDF-4 features
720 - you want to write data that takes advantage of compression,
721  chunking, or other netCDF-4 features
722 - you want to be able to read netCDF-4 classic model data with no
723  changes to your current software except relinking with the new
724  library
725 - you want to benchmark your current applications with the new
726  libraries to determine whether the benefits are significant enough
727  to justify the upgrade
728 - you need to use parallel I/O with netCDF-4 or netCDF-4 classic files
729 
730 What is the "enhanced data model" of netCDF-4, and how does it differ from the netCDF-3 classic data model? {#whatisenhanceddatamodel}
731 -------------
732 
733 
734 The enhanced model (sometimes referred to as the netCDF-4 data model) is
735 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
736 dimensions, and groups to organize data hierarchically and provide
737 scopes for names. A [picture](/netcdf/workshops/2008/netcdf4/Nc4DataModel.html) of the enhanced data model, with the extensions to the classic model
738 highlighted in red, is available from the online netCDF workshop.
739 
740 Although data represented with the classic model can also be represented
741 using the enhanced model, datasets that use features of the enhanced
742 model, such as user-defined data types, cannot be represented with the
743 classic model. Use of added features of the enhanced model requires that
744 data be stored in the netCDF-4 format.
745 
746 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}
747 -----------------
748 
749 
750 If you built the software from source without access to an HDF5 library,
751 then only the netCDF-3 library was built and installed. The current
752 release will build full netCDF-4 support if the HDF5 1.8.x library is
753 already installed where it can be found by the configure script or
754 cmake.
755 
756 Will Unidata continue to support netCDF-3? {#Will-Unidata-continue-to-support-netCDF-3}
757 -----------------
758 
759 
760 Yes, Unidata has a commitment to preserving backward compatibility.
761 
762 Because preserving access to archived data for future generations is
763 very important:
764 
765 - New netCDF software will provide read and write access to *all*
766  earlier forms of netCDF data.
767 - C and Fortran programs using documented netCDF APIs from previous
768  releases will be supported by new netCDF software (after recompiling
769  and relinking, if needed).
770 - Future releases of netCDF software will continue to support data
771  access and API compatibility.
772 
773 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}
774 -----------------
775 
776 
777 None. No changes to the program source are needed, because the library
778 handles decompressing data as it is accessed. All you need to do is
779 relink your netCDF-3 program to the netCDF-4 library to recognize and
780 handle compressed data.
781 
782 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}
783 -----------------
784 
785 
786 The **nccopy** utility in versions 4.1.2 and later supports a "-d *level*"
787 deflate option that copies a netCDF file, compressing all variables
788 using the specified level of deflation and default chunking parameters,
789 or you can specify chunking with the "-c" option.
790 
791 To do this within a program, or if you want different variables to have
792 different levels of deflation, define compression properties when each
793 variable is defined. The function to call is
794 [nc_def_var_deflate](/netcdf-c.html#nc_005fdef_005fvar_005fdeflate)
795 for C programs, [nf90_def_var_deflate](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.html#NF90_005fDEF_005fVAR_005fDEFLATE) for Fortran 90 programs, [NF_DEF_VAR_DEFLATE](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f77.html#NF_005fDEF_005fVAR_005fDEFLATE) for Fortran 77. For C++ programs, the experimental cxx4 API may be used,
796 assuming you have configured with --enable-cxx-4.
797 
798 Although default variable chunking parameters may be adequate,
799 compression can sometimes be improved by choosing good chunking
800 parameters when a variable is first defined. For example, if a 3D field
801 tends to vary a lot with vertical level, but not so much within a
802 horizontal slice corresponding to a single level, then defining chunks
803 to be all or part of a horizontal slice would typically produce better
804 compression than chunks that included multiple horizontal slices. There
805 are other factors in choosing chunk sizes, especially matching how the
806 data will be accessed most frequently. Chunking properties may only be
807 specified when a variable is first defined. The function to call is
808 [nc_def_var_chunking](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c.html#nc_005fdef_005fvar_005f)
809 for C programs,
810 [nf90_def_var_chunking](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.html#NF90_005fDEF_005fVAR_005fCHUNKING)
811 for Fortran 90 programs, and
812 [NF_DEF_VAR_CHUNKING](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f77.html#NF_005fDEF_005fVAR_005fCHUNKING)
813 for Fortran 77 programs. For C++ programs, the experimental cxx4 API may
814 be used, assuming you have configured with --enable-cxx-4.
815 
816 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}
817 -----------------
818 
819 
820 IDL 8.0 ships with support for netCDF-4, including support for OPeNDAP
821 remote access.
822 
823 MATLAB 2012a includes netCDF 4 support with OPeNDAP support turned on,
824 enabling remote access to many kinds of data, as well as use of groups,
825 compression, and chunking. An example is available demonstrating some of
826 the new functions. [NCTOOLBOX](http://nctoolbox.github.io/nctoolbox/),
827 uses netCDF-Java to provide read access to datasets in netCDF-4, GRIB,
828 GRIB2 and other formats through Unidata's Common Data Model.
829 
830 R has the [ncdf4 package](http://cirrus.ucsd.edu/~pierce/ncdf/).
831 
832 Python has the [netcdf4-python package](http://code.google.com/p/netcdf4-python/).
833 
834 ArcGIS 10.0 can read netcdf4 using the Multidimensional Tools in
835 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.
836 
837 What applications are able to deal with *arbitrary* netCDF-4 files? {#What-applications-are-able-to-deal-with-arbitrary-netCDF-4-files}
838 -----------------
839 
840 The netCDF utilities **ncdump**, **ncgen**, and **nccopy**, available in
841 the Unidata C-based netCDF-4 distribution, are able to deal with
842 arbitrary netCDF-4 files (as well as all other kinds of netCDF files).
843 
844 How can I convert netCDF-3 files into netCDF-4 files? {#How-can-I-convert-netCDF-3-files-into-netCDF-4-files}
845 -----------------
846 
847 
848 Every netCDF-3 file can be read or written by a netCDF version 4
849 library, so in that respect netCDF-3 files are already netCDF-4 files
850 and need no conversion. But if you want to convert a classic or 64-bit
851 offset format file into a netCDF-4 format or netCDF-4 classic model
852 format file, the easiest way is to use the **nccopy** utility. For example
853 to convert a classic format file foo3.nc to a netCDF-4 format file
854 foo4.nc, use:
855 
856 ~~~~~~~~~~~~~~~~~~~~~~~~~ {.boldcode}
857  nccopy -k netCDF-4 foo3.nc foo4.nc
858 ~~~~~~~~~~~~~~~~~~~~~~~~~
859 
860 To convert a classic format file foo3.nc to a netCDF-4 classic
861 model format file foo4c.nc, you could use:
862 
863 ~~~~~~~~~~~~~~~~~~~~~~~~~~ {.boldcode}
864  nccopy -k netCDF-4-classic foo3.nc foo4c.nc
865 ~~~~~~~~~~~~~~~~~~~~~~~~~~
866 
867 If you have installed [NCO](http://www.unidata.ucar.edu/software/netcdf/docs/software.html#NCO), the NCO
868 utility "ncks" can be used to accomplish the same task, as follows:
869 
870 ~~~~~~~~~~~~~~~~~~~~~~~~ {.boldcode}
871  ncks -7 foo3.nc foo4c.nc
872 ~~~~~~~~~~~~~~~~~~~~~~~~
873 
874 Another method is available for relatively small files, using the **ncdump**
875 and **ncgen** utilities (built with a netCDF-4 library). Assuming
876 "small3.nc" is a small classic format or 64-bit offset format netCDF
877 file, you can create an equivalent netCDF-4 file named
878 "small4.nc" as follows:
879 
880 ~~~~ {.boldcode}
881  ncdump small3.nc > small.cdl
882  ncgen -o small4.nc -k netCDF-4-classic small.cdl
883 ~~~~
884 
885 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}
886 -----------------
887 
888 
889 NetCDF-4 classic model files that use compression can be smaller than
890 the equivalent netCDF-3 files, so downloads are quicker. If they are
891 then unpacked and converted to the equivalent netCDF-3 files, they can
892 be accessed by applications that haven't yet upgraded to netCDF-4.
893 
894 How can I convert netCDF-4 files into netCDF-3 files? {#How-can-I-convert-netCDF-4-files-into-netCDF-3-files}
895 -----------------
896 
897 
898 In general, you can't, because netCDF-4 files may have features of the
899 netCDF enhanced data model, such as groups, compound types,
900 variable-length types, or multiple unlimited dimensions, for which no
901 netCDF-3 representation is available. However, if you know that a
902 netCDF-4 file conforms to the classic model, either because it was
903 written as a netCDF-4 classic model file, because the program that wrote
904 it was a netCDF-3 program that was merely relinked to a netCDF-4
905 library, or because no features of the enhanced model were used in
906 writing the file, then there are several ways to convert it to a
907 netCDF-3 file.
908 
909 You can use the **nccopy** utility. For
910 example to convert a netCDF-4 classic-model format file foo4c.nc to a
911 classic format file foo3.nc, use:
912 
913 ~~~~~~~~~~~~~~~~~~~~~~~~~ {.boldcode}
914  nccopy -k classic foo4c.nc foo3.nc
915 ~~~~~~~~~~~~~~~~~~~~~~~~~
916 
917 If you have installed [NCO](http://www.unidata.ucar.edu/software/netcdf/docs/software.html#NCO), the NCO utility "ncks" can be used to accomplish the same task, as follows:
918 
919 ~~~~~~~~~~~~~~~~~~~~~~~~~ {.boldcode}
920  ncks -3 foo4c.nc foo3.nc
921 ~~~~~~~~~~~~~~~~~~~~~~~~~
922 
923 For a relatively small netCDF-4 classic model file, "small4c.nc" for
924 example, you can also use the **ncdump** and **ncgen** utilities to create an
925 equivalent netCDF-3 classic format file named "small3.nc" as follows:
926 
927 ~~~~ {.boldcode}
928  ncdump small4c.nc > small4.cdl
929  ncgen -o small3.nc small4.cdl
930 ~~~~
931 
932 How can I convert HDF5 files into netCDF-4 files? {#How-can-I-convert-HDF5-files-into-netCDF-4-files}
933 -----------------
934 
935 
936 NetCDF-4 intentionally supports a simpler data model than HDF5, which
937 means there are HDF5 files that cannot be converted to netCDF-4,
938 including files that make use of features in the following list:
939 
940 - Multidimensional data that doesn't use shared dimensions implemented
941  using HDF5 "dimension scales". (This restriction was eliminated in
942  netCDF 4.1.1, permitting access to HDF5 datasets that don't use
943  dimension scales.)
944 - Non-hierarchical organizations of Groups, in which a Group may have
945  multiple parents or may be both an ancestor and a descendant of
946  another Group, creating cycles in the subgroup graph. In the
947  netCDF-4 data model, Groups form a tree with no cycles, so each
948  Group (except the top-level unnamed Group) has a unique parent.
949 - HDF5 "references" which are like pointers to objects and data
950  regions within a file. The netCDF-4 data model does not support
951  references.
952 - Additional primitive types not included in the netCDF-4 data model,
953  including H5T\_TIME, H5T\_BITFIELD, and user-defined atomic types.
954 - Multiple names for data objects such as variables and groups. The
955  netCDF-4 data model requires that each variable and group have a
956  single distinguished name.
957 - Attributes attached to user-defined types.
958 - Stored property lists
959 - Object names that begin or end with a space
960 
961 If you know that an HDF5 file conforms to the netCDF-4 enhanced data
962 model, either because it was written with netCDF function calls or
963 because it doesn't make use of HDF5 features in the list above, then it
964 can be accessed using netCDF-4, and analyzed, visualized, and
965 manipulated through other applications that can access netCDF-4 files.
966 
967 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:
968 
969 ~~~~ {.boldcode}
970  ncks infile.hdf5 outfile.nc
971 ~~~~
972 
973 Another tool has been developed to convert HDF5-EOS Aura files to
974 netCDF-4 files, and it is currently undergoing testing and documentation
975 before release on the HDF5 web site.
976 
977 How can I convert netCDF-4 files into HDF5 files? {#How-can-I-convert-netCDF-4-files-into-HDF5-files}
978 -----------------
979 
980 
981 Every netCDF-4 or netCDF-4 classic model file can be read or written by
982 the HDF5 library, version 1.8 or later, so in that respect netCDF-4
983 files are already HDF5 files and need no conversion.
984 
985 The way netCDF-4 data objects are represented using HDF5 is described in
986 detail in the User Manual section ["C.3 The NetCDF-4 Format"](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf.html#NetCDF_002d4-Format).
987 
988 Why aren't different extensions used for the different formats, for example ".nc3" and ".nc4"? {#why-arent-different-extensions-used}
989 ------------------
990 
991 The file extension used for netCDF files is purely a convention. The
992 netCDF libraries don't use the file extension. A user can currently
993 create a netCDF file with any extension, even one not consistent with
994 the format of the file.
995 
996 The **ncgen** utility uses ".nc" as a default extension for output, but this
997 can be overridden using the "-o" option to specify the name for the
998 output file. Recent versions of **ncgen** also have a "-k" option to specify
999 what kind of output file is desired, selecting any of the 4 format
1000 variants, using either a numeric code or a text string. Most other
1001 netCDF client software pays no attention to the file extension, so using
1002 more explicit extensions by convention has no significant drawbacks,
1003 except possibly causing confusion about format differences that may not
1004 be important.
1005 
1006 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}
1007 -----------------
1008 
1009 
1010 Until widely used netCDF client software has been adapted or upgraded to
1011 read netCDF-4 data, classic file format is the default for
1012 interoperability with most existing netCDF software.
1013 
1014 Can netCDF-4 read arbitrary HDF5 files? {#Can-netCDF-4-read-arbitrary-HDF5-files}
1015 -----------------
1016 
1017 
1018 No, but it can read many HDF5 files, and more recent versions can access
1019 more HDF5 data. If you want to access HDF5 data through netCDF
1020 interfaces, avoid HDF5 features not included in the netCDF enhanced data
1021 model. For more details see "[How can I convert HDF5 files into netCDF-4 files?](#fv15)", above.
1022 
1023 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}
1024 -----------------
1025 
1026 
1027 The number used for the shared library name is not related to the netCDF
1028 library version number.
1029 
1030 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}
1031 -----------------
1032 
1033 
1034 Earlier versions of the netCDF libraries have always been able to read
1035 data with arbitrary characters in names. The restriction has been on
1036 *creating* files with names that contained "invalid" special characters.
1037 The check for characters used in names occurred when a program tried to
1038 define a new variable, dimension, or attribute, and an error would be
1039 returned if the characters in the names didn't follow the rules.
1040 However, there has never been any such check on reading data, so
1041 arbitrary characters have been permitted in names created through a
1042 different implementation of the netCDF APIs, or through early versions
1043 of netCDF software (before 2.4), which allowed arbitrary names.
1044 
1045 In other words, the expansion to handle UTF-8 encoded Unicode characters
1046 and special characters such as \`:' and \` ' still conforms with
1047 Unidata's commitment to backwards compatibility. All old files are still
1048 readable and writable by the new software, and programs that used to
1049 work will still work when recompiled and relinked with the new
1050 libraries. Files using new characters in names will still be readable
1051 and writable by programs that used older versions of the libraries.
1052 However, programs linked to older library versions will not be able to
1053 create new data objects with the new less-restrictive names.
1054 
1055 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}
1056 -----------------
1057 
1058 
1059 Modifying an application to fully support the new enhanced data model
1060 may be relatively easy or arbitrarily difficult :-), depending on what
1061 your application does and how it is written. Use of recursion is the
1062 easiest way to handle nested groups and nested user-defined types. An
1063 object-oriented architecture is also helpful in dealing with
1064 user-defined types.
1065 
1066 We recommend proceeding incrementally, supporting features that are
1067 easier to implement first. For example, handling the six new primitive
1068 types is relatively straightforward. After that, using recursion (or the
1069 group iterator interface used in **nccopy**) to support Groups is not too
1070 difficult. Providing support for user-defined types is more of a
1071 challenge, especially since they can be nested.
1072 
1073 The utility program **nccopy**, provided in releases 4.1 and later, shows
1074 how this can be done using the C interface. It copies an input netCDF
1075 file in any of the format variants, handling nested groups, strings, and
1076 any user-defined types, including arbitrarily nested compound types,
1077 variable-length types, and data of any valid netCDF-4 type. It also
1078 demonstrates how to handle variables that are too large to fit in memory
1079 by using an iterator interface. Other generic utility programs can make
1080 use of parts of **nccopy** for more complex operations on netCDF data.
1081 
1082 ----------
1083 
1084 Shared Libraries {#Shared-Libraries}
1085 ================
1086 
1087 What are shared libraries? {#What-are-shared-libraries}
1088 -----------------
1089 
1090 
1091 Shared libraries are libraries that can be shared by multiple running
1092 applications at the same time. This **may** improve performance.
1093 
1094 For example, if I have a library that provides function foo(), and I
1095 have two applications that call foo(), then with a shared library, only
1096 one copy of the foo() function will be loaded into memory, and both
1097 programs will use it. With static libraries, each application would have
1098 its own copy of the foo() function.
1099 
1100 More information on shared libraries can be found at the following
1101 external sites:
1102 
1103 - [The Program-Library HowTo](http://www.tldp.org/HOWTO/Program-Library-HOWTO/index.html),
1104  by David Wheeler.
1105 
1106 - [Wikipedia Library Entry](http://en.wikipedia.org/wiki/Library_(computer_science))
1107 
1108 ----------
1109 
1110 Can I build netCDF with shared libraries? {#Can-I-build-netCDF-with-shared-libraries}
1111 -----------------
1112 
1113 
1114 Starting with version 3.6.2, netCDF can build shared libraries on
1115 platforms that support them, but by default netCDF will build static
1116 libraries only. To turn on shared libraries, use the --enable-shared
1117 option to the [netCDF configure script](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/Running-the-configure-Script.html).
1118 
1119 ----------
1120 
1121 How do I use netCDF shared libraries? {#How-do-I-use-netCDF-shared-libraries}
1122 -----------------
1123 
1124 
1125 With netCDF version 3.6.2, shared libraries can be built on platforms
1126 that support them by using the --enable-shared argument to [netCDF configure script](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/Running-the-configure-Script.html).
1127 
1128 Users of earlier versions of netCDF can build shared libraries by
1129 setting flags correctly during builds.
1130 
1131 When you use a static library, the code is copied from the library into
1132 your program when the program is built. The library is only needed at
1133 build time.
1134 
1135 With a shared library the code in the library is not copied into your
1136 executable, so the library is needed every time the program is run.
1137 
1138 If you write a program that uses the netCDF shared library, the
1139 operating system will have to find it every time your program is run. It
1140 will look in these places:
1141 
1142 1. Directories you specified as shared library locations at **build
1143  time**. Unfortunately this is done differently with different
1144  compilers.
1145 
1146 2. Directories specified in the environment variable LD\_RUN\_PATH at
1147  **build time**.
1148 
1149 3. Directories specified in the OS-specific environment variable for
1150  this purpose at **run time**. (LD\_LIBRARY\_PATH on Linux and many
1151  other Unix variants, LOADLIBS on AIX systems, etc.)
1152 
1153 4. A default list of directories that includes /usr/lib (but don't
1154  install software there!), and may or may not contain places you
1155  might install netCDF, like /usr/local/lib.
1156 
1157 5. The directories specified in an OS file such as /etc/ld.conf.
1158 
1159 By default the netCDF library will be installed in /usr/local/lib. (This
1160 can be overridden with the --prefix option to the [netCDF configure script](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/Running-the-configure-Script.html)).
1161 
1162 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.
1163 
1164 For more information about how do to this in Linux users may find it
1165 useful to read this external webpage, some documentation from Caldera, a
1166 Linux distributor: [Specifying directories to be searched by the dynamic linker](http://osr507doc.sco.com/en/tools/ccs_linkedit_dynamic_dirsearch.html).
1167 
1168 ----------
1169 
1170 Large File Support {#Large-File-Support}
1171 ================
1172 
1173 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}
1174 -----------------
1175 
1176 
1177 Yes, but there are significant restrictions on the structure of large
1178 netCDF files that result from the 32-bit relative offsets that are part
1179 of the classic netCDF format. For details, see [NetCDF Classic Format Limitations](http://www.unidata.ucar.edu/software/netcdf/documentation/historic/netcdf/NetCDF-Classic-Format-Limitations.html#NetCDF-Classic-Format-Limitations)
1180 in the User's Guide.
1181 
1182 ----------
1183 
1184 What is Large File Support? {#What-is-Large-File-Support}
1185 -----------------
1186 
1187 
1188 Large File Support (LFS) refers to operating system and C library
1189 facilities to support files larger than 2 GiB. On a few 32-bit platforms
1190 the default size of a file offset is still a 4-byte signed integer,
1191 which limits the maximum size of a file to 2 GiB. Using LFS interfaces
1192 and the 64-bit file offset type, the maximum size of a file may be as
1193 large as 2^63^ bytes, or 8 EiB. For some current platforms, large file
1194 macros or appropriate compiler flags have to be set to build a library
1195 with support for large files. This is handled automatically in netCDF
1196 3.6 and later versions.
1197 
1198 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).
1199 
1200 ----------
1201 
1202 What does Large File Support have to do with netCDF? {#What-does-Large-File-Support-have-to-do-with-netCDF}
1203 -----------------
1204 
1205 
1206 When the netCDF format was created in 1988, 4-byte fields were reserved
1207 for file offsets, specifying where the data for each variable started
1208 relative to the beginning of the file or the start of a record boundary.
1209 
1210 This first netCDF format variant, the only format supported in versions
1211 3.5.1 and earlier, is referred to as the netCDF *classic* format. The
1212 32-bit file offset in the classic format limits the total sizes of all
1213 but the last non-record variables in a file to less than 2 GiB, with a
1214 similar limitation for the data within each record for record variables.
1215 For more information see [Classic Format Limitations](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf/NetCDF-Classic-Format-Limitations.html#NetCDF-Classic-Format-Limitations).
1216 
1217 The netCDF classic format is also identified as *version 1* or *CDF1* in
1218 reference to the format label at the start of a file.
1219 
1220 With netCDF version 3.6 and later, a second variant of netCDF format is
1221 supported in addition to the classic format. The new variant is referred
1222 to as the *64-bit offset* format, *version 2*, or *CDF2*. The primary
1223 difference from the classic format is the use of 64-bit file offsets
1224 instead of 32-bit offsets, but it also supports larger variable and
1225 record sizes.
1226 
1227 ----------
1228 
1229 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}
1230 -----------------
1231 
1232 
1233 No, version 3.6 and later versions of the netCDF C/Fortran library
1234 detect which variant of the format is used for each file when it is
1235 opened for reading or writing, so it is not necessary to know which
1236 variant of the format is used. The version of the format will be
1237 preserved by the library on writing. If you want to modify a classic
1238 format file to use the 64-bit offset format so you can make it much
1239 larger, you will have to create a new file and copy the data to it. The
1240 **nccopy** utility available in version 4.1 can copy a classic file to a
1241 64-bit offset file.
1242 
1243 ----------
1244 
1245 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}
1246 -----------------
1247 
1248 
1249 Yes, the 3.6 library and all planned future versions of the library will
1250 continue to support reading and writing files using the classic (32-bit
1251 offset) format as well as the 64-bit offset format. There is no need to
1252 convert existing archives from the classic to the 64-bit offset format.
1253 Even netCDF-4, which introduces a third variant of the netCDF format
1254 based on HDF5, continues to support accessing classic format netCDF
1255 files as well as 64-bit offset netCDF files. NetCDF-4 HDF5 files have
1256 even fewer restrictions on size than 64-bit offset netCDF files.
1257 
1258 ----------
1259 
1260 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}
1261 -----------------
1262 
1263 
1264 No, we discourage users from making use of the 64-bit offset format
1265 unless they need it for large files. It may be some time until
1266 third-party software that uses the netCDF library is upgraded to 3.6 or
1267 later versions that support the large file facilities, so we advise
1268 continuing to use the classic netCDF format for data that doesn't
1269 require file offsets larger than 32 bits. The library makes this
1270 recommendation easy to follow, since the default for file creation is
1271 the classic format.
1272 
1273 ----------
1274 
1275 How can I tell if a netCDF file uses the classic format or 64-bit offset format? {#How-can-I-tell-if-a-netCDF-file-uses-the-classic-format-or-64-bit-offset-format}
1276 -----------------
1277 
1278 
1279 The short answer is that under most circumstances, you should not care,
1280 if you use version 3.6.0 or later of the netCDF library. But the
1281 difference is indicated in the first four bytes of the file, which are
1282 'C', 'D', 'F', '\\001' for the classic netCDF format and 'C', 'D', 'F',
1283 '\\002' for the 64-bit offset format. On a Unix system, one way to
1284 display the first four bytes of a file, say foo.nc, is to run the
1285 following command:
1286 
1287 ~~~~ {.boldcode}
1288  od -An -c -N4 foo.nc
1289 ~~~~
1290 
1291 which will output
1292 
1293 ~~~~ {.boldcode}
1294  C D F 001
1295 ~~~~
1296 
1297 or
1298 
1299 ~~~~ {.boldcode}
1300  C D F 002
1301 ~~~~
1302 
1303 depending on whether foo.nc is a classic or 64-bit offset netCDF file,
1304 respectively.
1305 
1306 With netCDF version 3.6.2 or later, there is an easier way, using the
1307 "-k" option to **ncdump** to determine the kind of file, for example:
1308 
1309 ~~~~ {.boldcode}
1310  ncdump -k foo.nc
1311  classic
1312 ~~~~
1313 
1314 ----------
1315 
1316 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}
1317 -----------------
1318 
1319 
1320 The application will indicate an error trying to open the file and
1321 present an error message equivalent to "not a netCDF file". This is why
1322 it's a good idea not to create 64-bit offset netCDF files until you
1323 actually need them.
1324 
1325 ----------
1326 
1327 Can I create 64-bit offset files on 32-bit platforms? {#Can-I-create-64-bit-offset-files-on-32-bit-platforms}
1328 -----------------
1329 
1330 
1331 Yes, by specifying the appropriate file creation flag you can create
1332 64-bit offset netCDF files the same way on 32-bit platforms as on 64-bit
1333 platforms. You do not need to compile the C/Fortran libraries as 64-bit
1334 to support access to 64-bit offset netCDF files.
1335 
1336 ----------
1337 
1338 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}
1339 -----------------
1340 
1341 
1342 With netCDF version 3.6.0 or later, use the NC\_64BIT\_OFFSET flag when
1343 you call nc\_create(), as in:
1344 
1345 ~~~~ {.boldcode}
1346  err = nc_create("foo.nc",
1347  NC_NOCLOBBER | NC_64BIT_OFFSET,
1348  &ncid);
1349 ~~~~
1350 
1351 In Fortran-77, use the NF\_64BIT\_OFFSET flag when you call
1352 nf\_create(), as in:
1353 
1354 ~~~~ {.boldcode}
1355  iret = nf_create('foo.nc',
1356  IOR(NF_NOCLOBBER,NF_64BIT_OFFSET),
1357  ncid)
1358 ~~~~
1359 
1360 In Fortran-90, use the NF90\_64BIT\_OFFSET flag when you call
1361 nf90\_create(), as in:
1362 
1363 ~~~~ {.boldcode}
1364  iret = nf90_create(path="foo.nc",
1365  cmode=or(nf90_noclobber,nf90_64bit_offset),
1366  ncid=ncFileID)
1367 ~~~~
1368 
1369 In C++, use the Offset64Bits enum in the NcFile constructor, as in:
1370 
1371 ~~~~ {.boldcode}
1372  NcFile nc("foo.nc",
1373  FileMode=NcFile::New,
1374  FileFormat=NcFile::Offset64Bits);
1375 ~~~~
1376 
1377 In Java, use the setLargeFile() method of the NetcdfFileWritable class.
1378 
1379 ----------
1380 
1381 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}
1382 -----------------
1383 
1384 
1385 A command-line option, '-k', specifies the kind of file format
1386 variant. By default or if '-k classic' is specified, the generated
1387 file will be in netCDF classic format. If '-k 64-bit-offset' is
1388 specified, the generated file will use the 64-bit offset format.
1389 
1390 ----------
1391 
1392 Have all netCDF size limits been eliminated? {#Have-all-netCDF-size-limits-been-eliminated}
1393 -----------------
1394 
1395 
1396 The netCDF-4 HDF5-based format has no practical limits on the size of a
1397 variable.
1398 
1399 However, for the classic and 64-bit offset formats there are still
1400 limits on sizes of netCDF objects. Each fixed-size variable (except the
1401 last, when there are no record variables) and the data for one record's
1402 worth of a single record variable (except the last) are limited in size
1403 to a little less that 4 GiB, which is twice the size limit in versions
1404 earlier than netCDF 3.6.
1405 
1406 The maximum number of records remains 2^32^-1.
1407 
1408 ----------
1409 
1410 Why are variables still limited in size? {#Why-are-variables-still-limited-in-size}
1411 -----------------
1412 
1413 
1414 While most platforms support a 64-bit file offset, many platforms only
1415 support a 32-bit size for allocated memory blocks, array sizes, and
1416 memory pointers. In C developer's jargon, these platforms have a 64-bit
1417 `off_t` type for file offsets, but a 32-bit `size_t` type for size of
1418 arrays. Changing netCDF to assume a 64-bit `size_t` would restrict
1419 netCDF's use to 64-bit platforms.
1420 
1421 ----------
1422 
1423 How can I write variables larger than 4 GiB? {#How-can-I-write-variables-larger-than-4-GiB}
1424 -----------------
1425 
1426 
1427 You can overcome the 4 GiB size barrier by using the netCDF-4 HDF5
1428 format for your data. The only change required to the program that
1429 writes the data is an extra flag to the file creation call, followed by
1430 recompiling and relinking to the netCDF-4 library. Programs that access
1431 the data would also need to be recompiled and relinked to the netCDF-4
1432 library.
1433 
1434 For classic and 64-bit offset netCDF formats, if you change the first
1435 dimension of a variable from a fixed size to an unlimited size instead,
1436 the variable can be much larger. Even though record variables are
1437 restricted to 4 Gib per record, there may be 4 billion records. NetCDF
1438 classic or 64-bit offset files can only have one unlimited dimension, so
1439 this won't work if you are already using a record dimension for other
1440 purposes.
1441 
1442 It is also possible to overcome the 4 GiB variable restriction for a
1443 single fixed size variable, when there are no record variables, by
1444 making it the last variable, as explained in the example in [NetCDF Classic Format Limitations](http://www.unidata.ucar.edu/software/netcdf/documentation/historic/netcdf/NetCDF-Classic-Format-Limitations.html#NetCDF-Classic-Format-Limitations).
1445 
1446 ----------
1447 
1448 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}
1449 -----------------
1450 
1451 
1452 There are several possible reasons why creating a large file can fail
1453 that are not related to the netCDF library:
1454 
1455 - User quotas may prevent you from creating large files. On a Unix
1456  system, you can use the "ulimit" command to report limitations such
1457  as the file-size writing limit.
1458 
1459 - There is insufficient disk space for the file you are trying to
1460  write.
1461 
1462 - The file system in which you are writing may not be configured to
1463  allow large files. On a Unix system, you can test this with a
1464  commands such as
1465 
1466  ~~~~ {.boldcode}
1467  dd if=/dev/zero bs=1000000 count=3000 of=./largefile
1468  ls -l largefile
1469  rm largefile
1470  ~~~~
1471 
1472  which should write a 3 GByte file named "largefile" in the current
1473  directory, verify its size, and remove it.
1474 
1475 If you get the netCDF library error "One or more variable sizes violate
1476 format constraints", you are trying to define a variable larger than
1477 permitted for the file format variant. This error typically occurs when
1478 leaving "define mode" rather than when defining a variable. The error
1479 status cannot be returned when a variable is first defined, because the
1480 last fixed-size variable defined is permitted to be larger than other
1481 fixed-size variables (when there are no record variables).
1482 
1483 Similarly, the last record variable may be larger than other record
1484 variables. This means that subsequently adding a small variable to an
1485 existing file may be invalid, because it makes what was previously the
1486 last variable now in violation of the format size constraints. For
1487 details on the format size constraints, see the Users Guide sections
1488 [NetCDF Classic Format Limitations](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf.html#Classic-Limitations) and [NetCDF 64-bit Offset Format Limitations](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf.html#64-bit-Offset-Limitations).
1489 
1490 If you get the netCDF library error "Invalid dimension size" for a
1491 non-negative size, you are exceeding the size limit of netCDF
1492 dimensions, which must be less than 2,147,483,644 for classic files with
1493 no large file support and otherwise less than 4,294,967,292.
1494 
1495 ----------
1496 
1497 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}
1498 -----------------
1499 
1500 
1501 No, except that 32-bit applications should link with a 32-bit version of
1502 the library and 64-bit applications should link with a 64-bit library,
1503 similarly to use of other libraries that can support either a 32-bit or
1504 64-bit model of computation. But note that a 32-bit version of the
1505 netCDF library fully supports writing and reading 64-bit offset netCDF
1506 files.
1507 
1508 ----------
1509 
1510 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}
1511 ----------------
1512 
1513 No, classic files created with the new library should be compatible with
1514 all older applications, both for reading and writing, with one minor
1515 exception. The exception is due to a correction of a netCDF bug that
1516 prevented creating records larger than 4 GiB in classic netCDF files
1517 with software linked against versions 3.5.1 and earlier. This limitation
1518 in total record size was not a limitation of the classic format, but an
1519 unnecessary restriction due to the use of too small a type in an
1520 internal data structure in the library.
1521 
1522 If you want to always make sure your classic netCDF files are readable
1523 by older applications, make sure you don't exceed 4 GiBytes for the
1524 total size of a record's worth of data. (All records are the same size,
1525 computed by adding the size for a record's worth of each record
1526 variable, with suitable padding to make sure each record begins on a
1527 byte boundary divisible by 4.)
1528 
1529 ----------
1530 
1531 NetCDF and Other Software {#NetCDF-and-Other-Software}
1532 ================
1533 
1534 What other software is available for accessing, displaying, and manipulating netCDF data? {#What-other-software-is-available-for-accessing-displaying-and-manipulating-netCDF-data}
1535 -----------------
1536 
1537 
1538 Utilities available in the current netCDF distribution from Unidata are
1539 **ncdump**, for converting netCDF files to an ASCII human-readable form,
1540 and **ncgen** for converting from the ASCII human-readable form back to
1541 a binary netCDF file or a C or FORTRAN program for generating the netCDF
1542 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.
1543 
1544 ----------
1545 
1546 What other data access interfaces and formats are available for scientific data? {#What-other-data-access-interfaces-and-formats-are-available-for-scientific-data}
1547 -----------------
1548 
1549 
1550 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.
1551 
1552 ----------
1553 
1554 What is the connection between netCDF and CDF? {#What-is-the-connection-between-netCDF-and-CDF}
1555 -----------------
1556 
1557 
1558 [CDF](http://cdf.gsfc.nasa.gov/) was developed at the NASA Space Science
1559 Data Center at Goddard, and is freely available. It was originally a VMS
1560 FORTRAN interface for scientific data access. Unidata reimplemented the
1561 library from scratch to use [XDR](http://www.faqs.org/rfcs/rfc1832.html)
1562 for a machine-independent representation, designed the
1563 [CDL](http://www.unidata.ucar.edu/software/netcdf/documentation/historic/netcdf/CDL-Syntax.htm) (network Common Data form Language) text
1564 representation for netCDF data, and added aggregate data access, a
1565 single-file implementation, named dimensions, and variable-specific
1566 attributes.
1567 
1568 NetCDF and CDF have evolved independently. CDF now supports many of the
1569 same features as netCDF (aggregate data access, XDR representation,
1570 single-file representation, variable-specific attributes), but some
1571 differences remain (netCDF doesn't support native-mode representation,
1572 CDF doesn't support named dimensions). There is no compatibility between
1573 data in CDF and netCDF form, but NASA makes available [some
1574 translators](http://cdf.gsfc.nasa.gov/html/dtws.html) between various
1575 scientific data formats. For a more detailed description of differences
1576 between CDF and netCDF, see the [CDF FAQ](http://cdf.gsfc.nasa.gov/html/FAQ.html).
1577 
1578 ----------
1579 
1580 What is the connection between netCDF and HDF? {#What-is-the-connection-between-netCDF-and-HDF}
1581 -----------------
1582 
1583 
1584 The National Center for Supercomputing Applications (NCSA) originally
1585 developed [HDF4](http://hdf.ncsa.uiuc.edu/) and made it freely
1586 available. HDF4 is an extensible data format for self-describing files
1587 that was developed independently of netCDF. HDF4 supports both C and
1588 Fortran interfaces, and it has been successfully ported to a wide
1589 variety of machine architectures and operating systems. HDF4 emphasizes
1590 a single common format for data, on which many interfaces can be built.
1591 
1592 NCSA implemented software that provided a netCDF-2 interface to HDF4.
1593 With this software, it was possible to use the netCDF calling interface
1594 to place data into an HDF4 file.
1595 
1596 HDF5, developed and supported by The HDF Group, Inc., a non-profit
1597 spin-off from the NCSA group, provides a richer data model, with
1598 emphasis on efficiency of access, parallel I/O, and support for
1599 high-performance computing. The netCDF-4 project has implemented an
1600 enhanced netCDF interface on the HDF5 storage layer to preserve the
1601 desirable common characteristics of netCDF and HDF5 while taking
1602 advantage of their separate strengths: the widespread use and simplicity
1603 of netCDF and the generality and performance of HDF5.
1604 
1605 ----------
1606 
1607 Has anyone implemented client-server access for netCDF data? {#Has-anyone-implemented-client-server-access-for-netCDF-data}
1608 -----------------
1609 
1610 
1611 Yes, as part of the [OPeNDAP](http://www.opendap.org/) framework,
1612 developers have implemented a client-server system for access to remote
1613 data that supports use of the netCDF interface for clients. A reference
1614 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.
1615 
1616 The 4.1 release of netCDF will include OPeNDAP client support; an
1617 experimental version is available now in the snapshot distributions.
1618 
1619 Other clients and servers support access through a netCDF interface to
1620 netCDF and other kinds of data, including clients written using the
1621 [netCDF-Java library](http://www.unidata.ucar.edu/software/netcdf-java/) and servers that use the
1622 [THREDDS Data Server](/software/thredds/current/tds/TDS.html).
1623 
1624 The [GrADS Data Server](http://grads.iges.org/grads/gds/) provides
1625 subsetting and analysis services across the Internet for any
1626 GrADS-readable dataset, including suitable netCDF datasets. The latest
1627 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.
1628 
1629 ----------
1630 
1631 How do I convert between GRIB and netCDF? {#How-do-I-convert-between-GRIB-and-netCDF}
1632 -----------------
1633 
1634 
1635 Several programs and packages have been developed that convert between
1636 [GRIB](http://www.wmo.ch/web/www/DPS/grib-2.html) and netCDF data:
1637 [ncl_convert2nc](http://www.ncl.ucar.edu/Applications/grib2netCDF.shtml),
1638 [degrib](http://www.nws.noaa.gov/mdl/NDFD_GRIB2Decoder/),
1639 [CDAT](software.html#CDAT), [CDO](software.html#CDO),
1640 [GDAL](http://www.gdal.org/), [GrADS](software.html#GrADS), and
1641 [wgrib2](http://www.cpc.noaa.gov/products/wesley/wgrib2/).
1642 
1643 The Unidata [netCDF Java Library](http://www.unidata.ucar.edu/software/netcdf-java/index.html) can
1644 read GRIB1 and GRIB2 data (and many other data formats) through a netCDF
1645 interface. As a command-line example, you could convert *fileIn.grib* to
1646 *fileOut.nc* as follows:
1647 
1648 ~~~~ {.boldcode}
1649  java -Xmx1g -classpath netcdfAll-4.3.jar ucar.nc2.dataset.NetcdfDataset \
1650  -in fileIn.grib -out fileOut.nc [-isLargeFile] [-netcdf4]
1651 ~~~~
1652 
1653 For more details on using netCDF Java, see the CDM man pages for
1654 [nccopy](http://www.unidata.ucar.edu/software/netcdf-java/reference/manPages.html#nccopy).
1655 
1656 ----------
1657 
1658 Problems and Bugs
1659 -----------------
1660 
1661 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}
1662 -----------------
1663 
1664 
1665 _I have some netcdf files which have data in them and were apparently
1666 not properly closed. When I examine them using **ncdump** they report zero
1667 data points, although the size is a few megabytes. Is there a way of
1668 recovering them?_
1669 
1670 If the files are in classic format or 64-bit offset format (if they were
1671 created by netCDF version 3.6.3 or earlier, for example), then you can
1672 use an editor that allows you to change binary files, such as emacs, to
1673 correct the four-byte number of records field in the file. This is a
1674 bigendian 4 byte integer that begins at the 4th byte in the file.
1675 
1676 This is what the first eight bytes would look like for classic format if
1677 you had zero records, where printable characters are specified as
1678 US-ASCII characters within single-quotes and non-printable bytes are
1679 denoted using a hexadecimal number with the notation '\\xDD', where each
1680 D is a hexadecimal digit:
1681 
1682 ~~~~ {.boldcode}
1683  'C' 'D' 'F' \x01 \x00 \x00 \x00 \x00
1684 ~~~~
1685 
1686 or
1687 
1688 ~~~~ {.boldcode}
1689  'C' 'D' 'F' \x02 \x00 \x00 \x00 \x00
1690 ~~~~
1691 
1692 for 64-bit-offset format.
1693 
1694 And this is what the first eight bytes should look like for classic
1695 format if you had 500 records (500 is 01F4 in hexadecimal)
1696 
1697 ~~~~ {.boldcode}
1698  'C' 'D' 'F' \x01 \x00 \x01 \x0f \x04
1699 ~~~~
1700 
1701 or
1702 
1703 ~~~~ {.boldcode}
1704  'C' 'D' 'F' \x02 \x00 \x01 \x0f \x04
1705 ~~~~
1706 
1707 for 64-bit-offset format.
1708 
1709 So if you can compute how many records should be in the file, you can
1710 edit the second four bytes to fix this. You can find out how many
1711 records should be in the file from the size of the file and from the
1712 variable types and their shapes. See the [description of the netCDF format](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf.html#File-Format)
1713 for classic and 64-bit offset files for how to figure out how large the
1714 file should be for fixed sized variables of particular shapes and for a
1715 specified number of record variables of particular shapes.
1716 
1717 Note that if you neglected to call the appropriate netCDF close function
1718 on a file, data in the last record written but not flushed to the disk
1719 may also be lost, but correcting the record count should allow recovery
1720 of the other records.
1721 
1722 ----------
1723 
1724 Is there a list of reported problems and workarounds? {#Is-there-a-list-of-reported-problems-and-workarounds}
1725 -----------------
1726 
1727 
1728 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.
1729 
1730 ----------
1731 
1732 How do I make a bug report? {#How-do-I-make-a-bug-report}
1733 -----------------
1734 
1735 
1736 If you find a bug, send a description to
1737 support-netcdf@unidata.ucar.edu. This is also the address to use for
1738 questions or discussions about netCDF that are not appropriate for the
1739 entire netcdfgroup mailing list.
1740 
1741 ----------
1742 
1743 How do I search through past problem reports? {#How-do-I-search-through-past-problem-reports}
1744 -----------------
1745 
1746 
1747 A search link is available at the bottom of the [netCDF homepage](http://www.unidata.ucar.edu/software/netcdf/), providing a full-text search of the
1748 support questions and answers about netCDF provided by Unidata support
1749 staff.
1750 
1751 ----------
1752 
1753 Programming with NetCDF {#Programming-with-NetCDF}
1754 ================
1755 
1756 Which programming languages have netCDF interfaces? {#Which-programming-languages-have-netCDF-interfaces}
1757 -----------------
1758 
1759 The netCDF distribution comes with interfaces for C, Fortran77,
1760 Fortran90, and C++. Other languages for which interfaces are available
1761 separately include:
1762 
1763 - [Ada](http://freshmeat.net/projects/adanetcdf/)
1764 - [IDL](software.html#IDL)
1765 - [Java](software.html#Java%20interface)
1766 - [MATLAB](software.html#MATLAB)
1767 - [Perl](software.html#Perl)
1768 - [Python](software.html#Python)
1769 - [R](software.html#R)
1770 - [Ruby](software.html#Ruby)
1771 - [Tcl/Tk](software.html#Tcl/Tk)
1772 
1773 ----------
1774 
1775 Are the netCDF libraries thread-safe? {#Are-the-netCDF-libraries-thread-safe}
1776 -----------------
1777 
1778 The C-based libraries are *not* thread-safe. C-based libraries are those
1779 that depend on the C library, which currently include all language
1780 interfaces except for the Java interface. The Java interface is
1781 thread-safe when a few simple rules are followed, such as each thread
1782 getting their handle to a file.
1783 
1784 ----------
1785 
1786 How does the C++ interface differ from the C interface? {#How-does-the-Cpp-interface-differ-from-the-C-interface}
1787 -----------------
1788 
1789 It provides all the functionality of the C interface (except for the
1790 generalized mapped access of ncvarputg() and ncvargetg()) and is
1791 somewhat simpler to use than the C interface. With the C++ interface, no
1792 IDs are needed for netCDF components, there is no need to specify types
1793 when creating attributes, and less indirection is required for dealing
1794 with dimensions. However, the C++ interface is less mature and
1795 less-widely used than the C interface, and the documentation for the C++
1796 interface is less extensive, assuming a familiarity with the netCDF data
1797 model and the C interface. Recently development of the C++ interface has
1798 languished as resources have been redirected to enhancing the Java
1799 interface.
1800 
1801 ----------
1802 
1803 How does the Fortran interface differ from the C interface? {#How-does-the-Fortran-interface-differ-from-the-C-interface}
1804 -----------------
1805 
1806 It provides all the functionality of the C interface. The Fortran
1807 interface uses Fortran conventions for array indices, subscript order,
1808 and strings. There is no difference in the on-disk format for data
1809 written from the different language interfaces. Data written by a C
1810 language program may be read from a Fortran program and vice-versa. The
1811 Fortran-90 interface is much smaller than the FORTRAN 77 interface as a
1812 result of using optional arguments and overloaded functions wherever
1813 possible.
1814 
1815 ----------
1816 
1817 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}
1818 -----------------
1819 
1820 They provide all the functionality of the C interface, using appropriate
1821 language conventions. There is no difference in the on-disk format for
1822 data written from the different language interfaces. Data written by a C
1823 language program may be read from programs that use other language
1824 interfaces, and vice-versa.
1825 
1826 ----------
1827 
1828 How do I handle errors in C? {#How-do-I-handle-errors-in-C}
1829 -----------------
1830 
1831 For clarity, the NetCDF C Interface Guide contains examples which use a
1832 function called handle\_err() to handle potential errors like this:
1833 
1834 ~~~~ {.boldcode}
1835  status = nc_create("foo.nc", NC_NOCLOBBER, &ncid);
1836  if (status != NC_NOERR) handle_error(status);
1837 ~~~~
1838 
1839 Most developers use some sort of macro to invoke netCDF functions and
1840 test the status returned in the calling context without a function call,
1841 but using such a macro in the User's Guides arguably makes the examples
1842 needlessly complex. For example, some really excellent developers define
1843 an "ERR" macro and write code like this:
1844 
1845 ~~~~ {.boldcode}
1846  if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
1847 ~~~~
1848 
1849 where Err is defined in a header file:
1850 
1851 ~~~~ {.boldcode}
1852 /* This macro prints an error message with line number and name of
1853  * test program. */
1854 #define ERR do { \
1855 fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
1856 err++; \
1857 fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
1858  __FILE__, __LINE__); \
1859 } while (0)
1860 ~~~~
1861 
1862 Ultimately, error handling depends on the application which is calling
1863 netCDF functions. However we strongly suggest that some form of error
1864 checking be used for all netCDF function calls.
1865 
1866 ----------
1867 
1868 
1869 CMake {#cmake_faq}
1870 ==============================================
1871 
1872 Below are a list of commonly-asked questions regarding NetCDF and CMake.
1873 
1874 How can I see the options available to CMake? {#listoptions}
1875 ---------------------------------------------
1876 
1877  $ cmake [path to source tree] -L - This will show the basic options.
1878  $ cmake [path to source tree] -LA - This will show the basic and advanced options.
1879 
1880 
1881 How do I specify how to build a shared or static library? {#sharedstatic}
1882 --------------------------------------------------------
1883 
1884  This is controlled with the internal `cmake` option, `BUILD_SHARED_LIBS`.
1885 
1886  $ cmake [Source Directory] -DBUILD_SHARED_LIBS=[ON/OFF]
1887 
1888 
1889 Can I build both shared and static libraries at the same time with cmake? {#sharedstaticboth}
1890 -------------------------------------------------------------------------
1891 
1892 Not at this time; it is required to instead build first one version, and then the other, if you need both.
1893 
1894 How can I specify linking against a particular library? {#partlib}
1895 -------------------------------------------------------
1896 
1897 It depends on the library. To specify a custom `ZLib`, for example, you would do the following:
1898 
1899  $ cmake [Source Directory] -DZLIB_LIBRARY=/path/to/my/zlib.lib
1900 
1901 
1902 `HDF5` is more complex, since it requires both the `hdf5` and `hdf5_hl` libraries. You would specify custom `HDF5` libraries as follows:
1903 
1904  $ cmake [Source Directory] -DHDF5_LIB=/path/to/hdf5.lib \
1905  -DHDF5_HL_LIB=/path/to/hdf5_hl.lib \
1906  -DHDF5_INCLUDE_DIR=/path/to/hdf5/include
1907 
1908 
1909 Alternatively, you may specify:
1910 
1911  $ cmake [Source Directory] \
1912  -DHDF5_LIBRARIES="/path/to/hdf5.lib;/path/to/hdf5_hl.lib" \
1913  -DHDF5_INCLUDE_DIRS=/path/to/hdf5/include/
1914 
1915 
1916 What if I want to link against multiple libraries in a non-standard location {#nonstdloc}
1917 ----------------------------------------------------------------------------
1918 
1919  You can specify the path to search when looking for dependencies and header files using the `CMAKE_PREFIX_PATH` variable:
1920 
1921 * Windows:
1922 
1923  $ cmake [Source Directory] -DCMAKE_PREFIX_PATH=c:\shared\libs\
1924 
1925 
1926 * Linux/Unix/OSX:
1927 
1928  $ cmake [Source Directory] -DCMAKE_PREFIX_PATH=/usr/custom_library_locations/
1929 
1930 How can I specify a Parallel Build using HDF5 {#parallelhdf}
1931 ----------------------------------------------
1932 
1933 If cmake is having problems finding the parallel `HDF5` install, you can specify the location manually:
1934 
1935 
1936  $ cmake [Source Directory] -DENABLE_PARALLEL=ON \
1937  -DHDF5_LIB=/usr/lib64/openmpi/lib/libhdf5.so \
1938  -DHDF5_HL_LIB=/usr/lib64/openmpi/lib/libhdf5.hl.so \
1939  -DHDF5_INCLUDE_DIR=/usr/include/openmpi-x86_64 \
1940 
1941 You will, of course, need to use the location of the libraries specific to your development environment.
1942 
1943 ----------------
1944 
1945 Plans {#Plans}
1946 ================
1947 
1948 What other future work on netCDF is planned? {#What-other-future-work-on-netCDF-is-planned}
1949 -----------------
1950 
1951 Issues, bugs, and plans for netCDF are maintained in the Unidata issue
1952 tracker sites for
1953 [netCDF-C](https://www.unidata.ucar.edu/jira/browse/NCF), [Common Data Model / NetCDF-Java](https://www.unidata.ucar.edu/jira/browse/CDM),
1954 [netCDF-Fortran](https://www.unidata.ucar.edu/jira/browse/NCFORTRAN),
1955 and [netCDF-CXX4](https://www.unidata.ucar.edu/jira/browse/NCXXF), and
1956 [old netCDF-C++
1957 (deprecated)](https://www.unidata.ucar.edu/jira/browse/NCCPP).

Return to the Main Unidata NetCDF page.
Generated on Thu Oct 26 2017 08:14:39 for NetCDF. NetCDF is a Unidata library.