[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #YEI-230852]: adding attributes after data with nc_redef



I attempted to duplicate your problem and could not duplicate it.
It is possible that the length argument to nc_put_att_string
is incorrect. Remember, it is the # of strings to write, not the
length of a string.

> Yes, correct, I was trying to overwrite the value in data mode after the
> value has been previously created in define mode. According to
> documentation, oi should be possible without re-entering the define mode
> as long as the new value has  the length smaller or equal to the length
> of the previous value. It worked well for all other type, except for the
> NC_STRING.
> 
> On 9/11/2018 5:33 PM, Unidata netCDF Support wrote:
> > Yes, since this is apparently a netcdf-4 file, I would expect
> > overwriting an attribute of type NC_STRING should work.
> > However, that -38 error is NC_ENOTINDEFINE, which mean that
> > when you tried to write the attribute, the file was not in define
> > mode, which mean, apparently, that you did not call nc_redef before
> > attempting the attribute write. Does seem like a possibility?
> >
> >> to update the attribute values, I have attempted to overwrite them in
> >> data mode. It worked fine except for NC_STRING type, for which I have
> >> received "code -38".  Would you expect it to work for NC_STRING type?
> >>
> >> Thanks,
> >>
> >> Alex
> >>
> >>
> >> On 9/7/2018 11:35 PM, Unidata netCDF Support wrote:
> >>> If the file is in netcdf-4 format, then the performance consequences
> >>> should be very small -- only the cost of writing the new attributes.
> >>>
> >>> If the file is in netcdf-3 format, then
> >>> basically what is going to happen is that the existing file data
> >>> will be moved in the file to make room for the new metadata
> >>> (i.e. the new attributes in this case). So the cost will be proportional
> >>> to the amount of data. Also, the new metadata will need to be re-written
> >>> to the file, and the cost to do that will depend on the amount of
> >>> metadata.
> >>> At a guess, the total cost will be about the same as
> >>> reading and writing the file once.
> >>> There is an exception to this. If you are not writing new attributes
> >>> and the new values you give to existing attributes is no larget
> >>> than the original size, then the only cost is to write the attribute.
> >>> The metadata and data will not be re-written.
> >>>
> >>>> On your website one can read with regard to "nc_enddef" the following:
> >>>> "This call may involve copying data under some circumstances." Could you
> >>>> please tell me what performance implications it may have and under which
> >>>> circumstances? Or more specifically, could you please tell whether there
> >>>> are any performance or otherwise possible complications with re-entering
> >>>> the define mode and adding attributes after the file has been already
> >>>> populated with (big) data?
> >>>>
> >>>> Thanks,
> >>>>
> >>>> Alex
> >>>>
> >>>>
> >>>>
> >>> =Dennis Heimbigner
> >>>     Unidata
> >>>
> >>>
> >>> Ticket Details
> >>> ===================
> >>> Ticket ID: YEI-230852
> >>> Department: Support netCDF
> >>> Priority: Normal
> >>> Status: Open
> >>> ===================
> >>> NOTE: All email exchanges with Unidata User Support are recorded in the 
> >>> Unidata inquiry tracking system and then made publicly available through 
> >>> the web.  If you do not want to have your interactions made available in 
> >>> this way, you must let us know in each email you send to us.
> >>>
> >>>
> >>
> > =Dennis Heimbigner
> >    Unidata
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: YEI-230852
> > Department: Support netCDF
> > Priority: Normal
> > Status: Open
> > ===================
> > NOTE: All email exchanges with Unidata User Support are recorded in the 
> > Unidata inquiry tracking system and then made publicly available through 
> > the web.  If you do not want to have your interactions made available in 
> > this way, you must let us know in each email you send to us.
> >
> >
> 
> 

=Dennis Heimbigner
  Unidata


Ticket Details
===================
Ticket ID: YEI-230852
Department: Support netCDF
Priority: Normal
Status: Open
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.