Published: Nov 25, 2021 by Peter Hill
Project info
NetCDF is a popular file format in the plasma community, as its labelled coordinate data and self-descriptive hierarchical format makes it a great choice for scientific data. It has bindings in all of the popular languages used in research software, including Fortran, which is heavily used in plasma science.
I help maintain several Fortran packages that use netCDF, and I often find myself a little frustrated with how verbose the API (application programming interface) can be, especially for common, basic tasks like writing a variable to file. This is usually compounded by netCDF defaulting to the “classic” file format, rather than the more modern netCDF-4 format, which has more features, is backed by HDF5 (another popular file format, with an even more verbose API!), and is generally easier to use.
I had already written some wrappers to make my life easier for the gyrokinetic solver GS2, so I decided to write to tidy them up and pull them out into a standalone package: neasy-f. Neasy-f is not a complete replacement for the netCDF-Fortran API, but is designed to be almost a “drop-in” replacement for sets of function calls while cutting down on the amount of boilerplate required.
Neasy-f is still in alpha (meaning it’s currently subject to backwards incompatible changes at any point), but already I’ve managed to cut out 300 lines from an existing project. If you use netCDF in a Fortran code, try out neasy-f and see if can help improve the sustainability of your software!