Re: Java netcdf error

Hi Christopher:

the problem is the _FillValue attribute empty string:

   char staticIds(maxStaticIds, totalIdLen);
    :_FillValue = "";

I made this fix to ucar.netcdf.Attribute ~line 531:

        getNumericValue(int index)
          if (index >= data.length())
            return new Integer(0);
            return new Integer(data.charAt(index));

can you patch the source yourself (or modify file)? i will add fix to next 

Christopher Golden wrote:

Hello!  You had written to Darien Davis in response to her query
about a netcdf/Java problem we're seeing at FSL.

You wrote:

 > it may be a bug that's been fixed. what is date of jar file? send me
 > netcdf file and i'll check it with latest.

I tried the following versions of the netcdf/Java libraries:

    version 1:           Worked perfectly with our files.

    version 2:           Threw an exception when creating
                         an instance of NetcdfFile.

    version 2.1 beta:    Same as with version 2.

The JAR file I used for version 2 is dated 8/22/02:

and the one I used for version 2.1 is dated 10/25/02:

I've included one of the netcdf files that cause the
following exception to be thrown at construction time:

  java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(Unknown Source)
        at ucar.netcdf.StringAttrVal.getNumericValue(
        at ucar.netcdf.StringAttrVal.getNumericValue(
        at ucar.netcdf.Attribute.getNumericValue(
        at ucar.netcdf.NetcdfFile$V1CharacterIo.fill(
        at ucar.netcdf.NetcdfFile$V1Io.initFillValue(
        at ucar.netcdf.NetcdfFile$V1Io.initFillValue(
        at ucar.netcdf.NetcdfFile$V1Io.<init>(
at ucar.netcdf.NetcdfFile$V1CharacterIo.<init>(
        at ucar.netcdf.NetcdfFile.V1IoFactory(
        at ucar.netcdf.NetcdfFile.readV1VarArray(
        at ucar.netcdf.NetcdfFile.readV1(
        at ucar.netcdf.NetcdfFile.<init>(
        at ucar.netcdf.NetcdfFile.<init>(
        at ucar.nc2.NetcdfFile.<init>(
        at NetcdfConverter.main(

This is from Java 1.3 (build 1.3.1_04-b02) for Windows XP,
but I get the same error when running on a Linux machine.

Does this help at all?  We'd prefer to use version 2.x of
the netcdf/Java library if possible, as the interface seems
easier to work with, so we're hoping that we can get it
working with our netcdf files.

Christopher Golden

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