Re: Is this a bug in the NetCDF library?

Brian Etheridge wrote:

I have recently started using the ucar java class library and have come across what I think might be a bug. I hope this list is the correct one for questions of this type and has some users or developers of this package who can help me.

I am using version 2.2 of the Java library and during testing had a problem with the* ucar.nc2.Variable* class. In the following method:

        Array read(int [] origin, int [] shape)

The following line calculates the last index in the required range. I think it is doing this incorrectly when the statring point (first) is anything other than the first element (0). The routine then crashes a line or two later:

        int last = (shape==null) ? getShape()[i] : first + shape[i] - 1;

I had to change the line to:

        int last = (shape==null) ? getShape()[i] : shape[i] - 1;

This seems to make more sense since it appears that the 'last' variable should contain the index of the last element in the array, rather than a count of the number of elements to be read, which is what the original line of code would suggest it is trying to do (even then I think the code would need some attention). On the other hand this seems like a piece of bread and butter code which is constantly used, so I am worried that I am doing else wrong.

Has anyone come across this problem? Is there a NetCDF developer who can help me?


Hi Brian:

The line above is correct. Its calculating the last requested index, inclusive. Not sure why youre getting a crash, but the origin/shape parameters are often a source of error.

the correct list for this is netcdf-java@xxxxxxxxxxxxxxxx