netcdf-c icon indicating copy to clipboard operation
netcdf-c copied to clipboard

changing values/updating a variable in a netcdf file

Open jbensabat opened this issue 1 year ago • 3 comments

Hello I am trying to update a variable that has 4 dimensions (one of them NC_UNLIM) using the c version. I get the values into a array (values) then make changes to the to the array when I try to write back the variable values to the netcdf file I get an error -101 Is it a limitation of netcdf or an error that I am making ? thanks jac

To report a non-security related issue, please provide:

  • the version of the software with which you are encountering an issue
  • environmental information (i.e. Operating System, compiler info, java version, python version, etc.)
  • a description of the issue with the steps needed to reproduce it

If you have a general question about the software, please view our Suggested Support Process.

jbensabat avatar Feb 01 '24 06:02 jbensabat

Error -101 indicates an error at the HDF5 layer; it's not more specific, because it reflects an issue where libhdf5 has only told us "something went wrong" without additional detail. Can you provide a snippet of the code you're using? Perhaps something will stick out, because you should be able to do what you have described.

WardF avatar Feb 01 '24 19:02 WardF

Hi I found the cause of the problem. In order to update a variable I need to open the nc file NC_WRITE mode. I won't do this error again but would it be possible to check this when attempting to write to an nc file (checking if the file was open in the correct mode) best jac

jbensabat avatar Feb 02 '24 06:02 jbensabat

It seems like it should be a thing we can do. @DennisHeimbigner am I overlooking something simple, or a reason why we aren't doing this already?

WardF avatar Feb 13 '24 22:02 WardF