[netcdf-java] Problem with Fortran syntax and OpenDAP files

John,

Using certain fortran type syntax to read data from OpenDAP files
is resulting in 'NullPointer Exception'.

For example, when I call the 'read' method on variable and supply the 'range' to read 'all' data for a particular dimension using colon ":" syntax, it gives null pointer, otherwise it works fine.
>>>
String range = ":,50,100";
..........
varID=ncid.findVariable(var);
data = varID.read(range);
........
<<<<<
Test file: 'http://stellwagen.er.usgs.gov/cgi-bin/nph-dods/models/vs/vs012/his/ocean_his_0001.nc'

With little debugging, I found out that the method "public static List parseSpec(String sectionSpec)" in "ucar.ma2.Range" assigns "null" for colon syntax ":" while parsing the string. Later, before the actual data is being read, the 'null' assignment in the range list never gets changed to actual dimension size, thus resulting in exception.

For quick solution (till you find a better one) I have found that modifying the method 'public Array read(String sectionSpec)'
in 'ucar.nc2.Variable' with code below works fine.

public Array read(String sectionSpec) throws IOException, InvalidRangeException {
   List section = Range.parseSpec(sectionSpec);

  //Update ----start ----
// If any 'nulls' in the range list, try and change with actual size of the dimension.
   Variable vs = new Variable( this);
   Range.setDefaults( section, vs.shape);
 //---end

   return read( section);
 }


Is this really a problem with API, or I am doing something wrong while reading data using Fortran type syntax ?

btw, if I use toolsUI GUI to read data (for test purpose) using the range ':,50,100', it works fine. I think it's using 'Ncdump' class to read data which may be handling the ':' syntax differently.
Just my guess.

thanks..

Sachin.


--
Sachin Kumar Bhate, Software Engineer
MSU-High Performance Computing Collaboratory, NGI
John C. Stennis Space Center, MS 39529
Ph: (601) 466-9692





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