Next: , Previous: nc_rename_var, Up: Variables


6.35 Copy a Variable from One File to Another: nc_copy_var

This function will copy a variable from one file to another.

It works even if the files are different formats, (i.e. classic vs. netCDF-4/HDF5.)

If you're copying into a netCDF-3 file, from a netCDF-4 file, you must be copying a var of one of the six netCDF-3 types. Similarly for the attributes.

For large netCDF-3 files, this can be a very inefficient way to copy data from one file to another, because adding a new variable to the target file may require more space in the header and thus result in moving data for other variables in the target file. This is not a problem for netCDF-4 files, which support efficient addition of variables without moving data for other variables.

Usage

     nc_copy_var(int ncid_in, int varid_in, int ncid_out)

Return Codes

Example