[netcdf-java] Multi-threading and gridsets - help

Hello,

I’m having trouble with threading and using GridDataSets. I was wondering what 
I am doing wrong.

Using the tutorial I initially create the file cache as such

NetcdfDataset.initNetcdfFileCache(...)

Then I’m opening the grid data set using the open command, which uses the 
NetcdfDataset.aquire… to use the file cache

GridDataset gds = ucar.nc2.dt.grid.GridDataset.open(location);

Then when I want to read the data from a grid I use:

Array data  = grid.readDataSlice(0, 0, xy[1], xy[0])

However, when running this code with threads, it throws out this exception 
(works fine with one thread). It appears to access 
ucar.unidata.io.RandomAccessFile.read, which I thought the cache prevented it 
from using?

java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 131006
at ucar.nc2.dt.grid.GeoGrid.readDataSlice(GeoGrid.java:609)
at ucar.nc2.dt.grid.GeoGrid.readDataSlice(GeoGrid.java:517)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 131006
at ucar.unidata.io.RandomAccessFile.read(RandomAccessFile.java:643)
at ucar.unidata.io.RandomAccessFile.readShort(RandomAccessFile.java:1115)
at ucar.unidata.io.RandomAccessFile.readShort(RandomAccessFile.java:1137)
at ucar.nc2.iosp.IospHelper.readData(IospHelper.java:123)
at ucar.nc2.iosp.IospHelper.readDataFill(IospHelper.java:79)
at ucar.nc2.iosp.netcdf3.N3raf.readData(N3raf.java:63)
at ucar.nc2.iosp.netcdf3.N3iosp.readData(N3iosp.java:484)
at ucar.nc2.NetcdfFile.readData(NetcdfFile.java:2020)
at ucar.nc2.Variable.reallyRead(Variable.java:913)
at ucar.nc2.Variable._read(Variable.java:898)
at ucar.nc2.Variable.read(Variable.java:709)
at ucar.nc2.dataset.VariableDS.reallyRead(VariableDS.java:557)
at ucar.nc2.dataset.VariableDS._read(VariableDS.java:537)
at ucar.nc2.SectionReader.reallyRead(SectionReader.java:75)
at ucar.nc2.dataset.VariableDS._read(VariableDS.java:537)
at ucar.nc2.Variable.read(Variable.java:709)
at ucar.nc2.Variable.read(Variable.java:655)
at ucar.nc2.dt.grid.GeoGrid.readDataSlice(GeoGrid.java:606)
at ucar.nc2.dt.grid.GeoGrid.readDataSlice(GeoGrid.java:517)

Is there something I am missing?
STEVE HAWES | PhD Candidate
Coastal & Marine Ecosystems Group (CMEG) | School of Life & Environmental 
Sciences (SOLES) | Faculty of Science
THE UNIVERSITY OF SYDNEY
Rm 114, Edgeworth-David Bldg A11 | The University of Sydney | NSW | 2006
M +61 439 881 324
E steven.hawes@xxxxxxxxxxxxx<mailto:firstname.surname@xxxxxxxxxxxxx>  | W 
sydney.edu.au<http://sydney.edu.au>
Tweets @stevehawes
INSPIRED – the Campaign to support the University of Sydney

sydney.edu.au/inspired<http://inspired.sydney.edu.au/>
CRICOS 00026A
This email plus any attachments to it are confidential. Any unauthorised use is 
strictly prohibited. If you receive this email in error, please delete it and 
any attachments.

Please think of our environment and only print this e-mail if necessary.

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