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: 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:

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

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


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:

   ftp://ftp.unidata.ucar.edu/pub/netcdf-java/netcdf2All.jar

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

   ftp://ftp.unidata.ucar.edu/pub/netcdf-java/v2.1/netcdf2All.jar

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(Attribute.java:534)
        at ucar.netcdf.StringAttrVal.getNumericValue(Attribute.java:539)
        at ucar.netcdf.Attribute.getNumericValue(Attribute.java:248)
        at ucar.netcdf.NetcdfFile$V1CharacterIo.fill(NetcdfFile.java:1236)
        at ucar.netcdf.NetcdfFile$V1Io.initFillValue(NetcdfFile.java:1042)
        at ucar.netcdf.NetcdfFile$V1Io.initFillValue(NetcdfFile.java:1054)
        at ucar.netcdf.NetcdfFile$V1Io.<init>(NetcdfFile.java:797)
at ucar.netcdf.NetcdfFile$V1CharacterIo.<init>(NetcdfFile.java:1174)
        at ucar.netcdf.NetcdfFile.V1IoFactory(NetcdfFile.java:1540)
        at ucar.netcdf.NetcdfFile.readV1VarArray(NetcdfFile.java:1618)
        at ucar.netcdf.NetcdfFile.readV1(NetcdfFile.java:1707)
        at ucar.netcdf.NetcdfFile.<init>(NetcdfFile.java:130)
        at ucar.netcdf.NetcdfFile.<init>(NetcdfFile.java:148)
        at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:56)
        at NetcdfConverter.main(NetcdfConverter.java:16)

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.

Thanks!
Christopher Golden
golden@xxxxxxxxxxxx



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