17 releases

0.8.3 Oct 8, 2023
0.8.1 Apr 1, 2023
0.8.0 Feb 17, 2023
0.7.0 Jan 28, 2022
0.1.0 Jun 27, 2015

#124 in Encoding

Download history 219/week @ 2023-08-14 247/week @ 2023-08-21 236/week @ 2023-08-28 446/week @ 2023-09-04 398/week @ 2023-09-11 375/week @ 2023-09-18 348/week @ 2023-09-25 366/week @ 2023-10-02 297/week @ 2023-10-09 395/week @ 2023-10-16 352/week @ 2023-10-23 327/week @ 2023-10-30 492/week @ 2023-11-06 612/week @ 2023-11-13 602/week @ 2023-11-20 849/week @ 2023-11-27

2,585 downloads per month
Used in 10 crates (5 directly)


7.5K SLoC


Docs Build Status Crates.io codecov Crates.io

Medium-level netCDF bindings for Rust, allowing easy reading and writing of array-like structures to a file. netCDF can read and write hdf5 files, which is a commonly used file format in scientific computing.



  • Variables
  • Normal Dimensions
  • Attributes
  • Subgroups
  • Open/Append/Create modes
  • Reading from memory (read only for now)
  • Unlimited dimensions
  • string variables
  • user defined types (variable length, enum, compound, opaque)

Not (yet) supported:

  • some exotic user defined types

All variable data is read into a contiguous buffer, or into an ndarray if the ndarray feature is activated.


This crate depends on libnetcdf, but a static build from source is also supported, which can be enabled using the static feature.

The crate is built on several platforms using github actions, and is currently known to build form from source on all major platforms (linux, macos, windows (gnu+msvc)), and through the package installers conda and apt.


Some examples of usage can be found in the tests/lib.rs file. The documentation can also be generated using cargo doc.

Thread safety

The netcdf-c library is not threadsafe. To render a safe interface, a global mutex is used to serialize access to the underlying library. If performance is needed, consider using a non threadsafe version of hdf5, so double locking is avoided.

Use of netcdf-sys is not thread-safe. Users of this library must take care that calls do not interfere with simultaneous use of e.g. netcdf. Using the hdf5-sys library could also pose a problem, as this library is used throughout netCDF-c and internal state may be disrupted.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~244K SLoC