NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: Is this a bug in the NetCDF library?

Brian Etheridge wrote:

Hi,
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?

Thanks
Brian

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


  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: