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

[netCDFJava #YBE-781445]: Redefine mode working for netcdf-java?



I looked at our test cases and see that setRedefineMode is used
in a number of them. So I speculate that your code is doing something
non-standard.

> Directly using the jna is probably a bad idea since other parts of
> netcdf-Java may not see the changes you make.
> 
> A couple of points.
> 1. the netcdf-3 format does not actually have a string type: only character.
> this means that strings are faked as arrays of character, and that means
> that they are fixed size. If you change one without first setting
> redef mode, then any string you pass in will be truncated to fit in the
> existing array of characters.
> 2. I more concerned about the failure of NetcdfWriter.setRedefineMode.
> If you set define mode, then writing a longer string should have worked.
> This needs investigation. By any chance do you have a simple
> java program that illustrates this failure?
> 3. The jna api is missing a number of things we did not anticipate using;
> apparently including redef.
> 4. netcdf-3 files are read and written using pure-java code; the jna is not 
> involved. So, it has internally the functional equivalent of redef. The 
> netcdf-4 library (in C) is more forgiving about doing an automatic redef
> when certain actions are attempted, so explicit redef is not often
> required.
> 
> > I'm writing a java application that updates values of global attributes
> > but have encountered multiple issues while attempting to implement.
> >
> > First I tried using the ucar.nc2.NetcdfWriter but it wasn't capable of
> > updating the attributes to values that exceeded a particular length and
> > ended up truncating the string value.
> >
> > Errors were also thrown when I tried to use the
> > NetcdfWriter.setRedefineMode that was ultimately caused by a Native
> > Windows Filesystem call.  I tested on Linux and a similar error was
> > thrown.
> >
> > Those errors led me to believe that the Netcdf3 writing capabilities
> > weren't working properly for netcdf-java so I attempted to use Netcdf4.
> > I discovered that unlike Netcdf3, netcdf-java doesn't have Netcdf4
> > processing implementation built-in so depends on the Native C Library
> > that must be installed to be accessed via JNA.  After installing the
> > Netcdf4 C Library, the attribute values were still being truncated.
> > After debugging the functions I d iscovered that the Netcdf3 functions
> > were still being used.
> >
> > I didn't find any way to force netcdf files to be processed using netcdf4
> > via the Java API so I decided to attempt just using the underlying JNA
> > native calls (e.g. nc_put_att_text).  I have already successfully tested
> > updating the attribute values using a c program which doesn't truncate
> > the values.  However, I'm unable to do the same thing in Java because
> > the nc_redef function isn't included in the Nc4prototypes class so the
> > attribute values nev er change.
> >
> > Was nc_redef accidentally left out or was the exclusion intentional?
> > Or is there an equivalent of that function that alluded me?
> >
> >
> 
> =Dennis Heimbigner
> Unidata
> 

=Dennis Heimbigner
  Unidata


Ticket Details
===================
Ticket ID: YBE-781445
Department: Support netCDF Java
Priority: Critical
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.