This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Tom, > The software seems to have a problem with scalar (dimensionless) > variables. In the file netcdf/JiNcSource.java, the code allocates > memory for an array of Dimension classes (line 300). However, if the > variable has no dimensions, this code will not do anything. On line > 306, the code tries to access the first member of that dimension > array. With no memory allocated, this line produces an exception and > the code halts. Here's a patch for JiNcSource.java that I believe will make it work for scalar variables (at least the Test now works for a file containing a scalar variable): cvs diff: Diffing . Index: JiNcSource.java =================================================================== RCS file: /upc/share/CVS/rmicdf/netcdf/JiNcSource.java,v retrieving revision 1.2 diff -c -r1.2 JiNcSource.java *** 1.2 1996/08/08 16:04:36 --- JiNcSource.java 1996/08/08 16:35:07 *************** *** 288,294 **** if (type == 0 && nelems == 0) return; if (type != NcVariable) ! throw new IOException("Bad file -- expected netCDF global atts"); mVarArray = new JiNcVar[nelems]; for (int i=0; i < nelems; i++){ mVarArray[i] = readVar(in); --- 288,294 ---- if (type == 0 && nelems == 0) return; if (type != NcVariable) ! throw new IOException("Bad file -- expected netCDF variable"); mVarArray = new JiNcVar[nelems]; for (int i=0; i < nelems; i++){ mVarArray[i] = readVar(in); *************** *** 305,311 **** dims[i] = (JiDim)mDimArray[dimid].clone(); } boolean isRecord = false; ! if (dims[0].mCount == 0){ isRecord = true; dims[0].mCount = getNumRecords(); } --- 305,311 ---- dims[i] = (JiDim)mDimArray[dimid].clone(); } boolean isRecord = false; ! if (nelems > 0 && dims[0].mCount == 0){ isRecord = true; dims[0].mCount = getNumRecords(); } --Russ