[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: toArray() problem



> I'm getting a java.lang.NullPointerException when invoking the
> toArray() (no arguments) method on a scalar byte.
>
> Here's the stack trace:
>
>     main[1] where
>       [1] ucar.netcdf.NetcdfFile$V1Io.iocount (NetcdfFile$V1Io:740)
>       [2] ucar.netcdf.NetcdfFile$V1Io.toArray (NetcdfFile$V1Io:862)
>       [3] ucar.netcdf.NetcdfFile$V1Io.toArray (NetcdfFile$V1Io:838)
>       [4] ucar.netcdf.Variable.toArray (Variable:278)
>       [5] visad.data.netcdf.newin.Util.toArray (Util:945)
>       [6] visad.data.netcdf.newin.VirtualScalar.getDoubles
(VirtualScalar:215)
>       [7] visad.data.netcdf.newin.VirtualScalar.getData (VirtualScalar:173)
>       [8] visad.data.netcdf.newin.VirtualTuple.getData (VirtualTuple:228)
>       [9] visad.data.netcdf.newin.VirtualData.getData (VirtualData:48)
>       [10] visad.data.netcdf.newin.DefaultConsolidator.getData
(DefaultConsolidator:235)
>       [11] visad.data.netcdf.newin.NetcdfAdapter.getData (NetcdfAdapter:97)
>       [12] visad.data.netcdf.newin.NetcdfAdapter.main (NetcdfAdapter:166)
>
> Here's where the exception occurs:
>
>     main[1] list
>     736                     int product = 1;
>     737                     int minIndex = 0;
>     738                     if(isUnlimited)
>     739                             minIndex = 1;
>     740     =>              for(int ii = shape.length -1; ii >= minIndex;
ii--)
>     741                     {
>     742                             final int si = shape[ii];
>     743                             product *= si;
>     744                             if(origin[ii] != 0 || si < lengths[ii] )
>
> The variable "shape" is nil:
>
>     main[1] print shape
>     shape = null
>
> Is Variable.toArray() for non-scalars only?

This problem is also reported by "Michael McCarrick" <address@hidden>

" I found a second problem in NetcdfFile.java.  The toArray() method fails
" because shape is null.  I think line 862 should be
"
"       final int contig = iocount(origin, shp);

" rather than
"
"       final int contig = iocount(origin, shape);

-glenn