netcdfpp
Header-only NetCDF C++ wrapper
Loading...
Searching...
No Matches
Copying

Groups, variables, dimensions, attributes, and user-defined types can be copied between files and groups.

netCDF::File in("input.nc", 'r');
netCDF::File out("output.nc", 'w');
out.copy_from(in, true);
NetCDF file handle and root group.
Definition netcdfpp.h:797

The second argument controls whether variable values are copied. Metadata is copied first. When copying user-defined types between groups, netcdfpp resolves the matching type in the destination group before copying variables or attributes that use it.

Copying variable values checks type size, dimension count, and dimension sizes before reading and writing the raw data. A mismatch throws netCDF::Exception.