Unidata / netcdf-c

Official GitHub repository for netCDF-C libraries and utilities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

changing values/updating a variable in a netcdf file

jbensabat opened this issue · 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.

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.

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

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?