Re: java-netcdf2.2v10, offset on reading nc files

Heiko Klein wrote:

Hi John,

thanks for your feedback concerning grib/BUFR. Reading your argument about the netcdf-library being able to read grib-data, I don't think it will be a problem for us when the collaboration will decide for grib, though I still will prefer the netcdf-library.

Today, I ran into another problem with reading netcdf-files with 2.2.09 and 2.2.10 . At first I got a EOFException: at ucar.unidata.io.RandomAccessFile.readInt(RandomAccessFile.java:835) at ucar.unidata.io.RandomAccessFile.readFloat(RandomAccessFile.java:945)
        at ucar.nc2.N3raf.readData(N3raf.java:81)
        at ucar.nc2.N3iosp.readData(N3iosp.java:111)
        at ucar.nc2.NetcdfFile.readData(NetcdfFile.java:965)
        at ucar.nc2.Variable._read(Variable.java:758)
        at ucar.nc2.Variable.read(Variable.java:524)
        at international.emep.io.NetcdfUtils.copy(NetcdfUtils.java:57)
at international.emep.io.GDVtoCF1_0converter.<init>(GDVtoCF1_0converter.java:76) at international.emep.io.GDVtoCF1_0converter.main(GDVtoCF1_0converter.java:169)

(linenumbers might not be exactly the same as yours, since I included up to 4 println statements.)

The error occurs when reading the last variable from the file with var.read():

        variables = ncIn.getVariables();
        for (Variable var : variables) {
            try {
                System.err.println("Writing variable: "+var.getName());
                ncOut.write(var.getName(), var.read());
                System.err.println("finished");
            } catch (InvalidRangeException ire) {
throw new IOException("InvalidRangeException: "+ire.toString());
            }
        }


Looking at the copied file with ncview, I see that all data looks misplaced. With the println I got for the last variable:
Writing variable: WDEP_RDN
Trying to read 14652 floats
Fetching 58608 starting at 4138964, but filesize is just: 4194340

Can you send me the file or a URL to it? How was the file written? From the java library or the c library?



BTW: I've seen that unidata has a netcdf mailing list. Do you prefer me to send such messages to the list, or directly to you?

Ive cc'ed it to netcdf-java, which is a good place to send all such problems, so that others can "follow along" if they wish.



Best regards,

Heiko

thanks for your help debugging.