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.
I was able to convert, but i had to rename the file. likely the shell doesnt like the "+" in the filename. $ java -Xmx1g -classpath netcdfAll-4.3.jar ucar.nc2.dataset.NetcdfDataset -in nick.grib -out outfile.netcdf this was with version 4.4.0. If you still have a problem, i need to know exactly what version; you can find that inside the jar file in the META-INF directory. john > Hi I am using netcdfall 4.3, input file is attached. > > Many thanks > ---------- Forwarded message ---------- > From: "nick robinson" <address@hidden> > Date: 13 Sep 2013 13:05 > Subject: Re: [netCDFJava #CJU-478813]: gribtonc replacement > To: <address@hidden> > Cc: > > Hi > > Sorry to bug you again. I managed to get to grips with NcML thanks very > much for that. > I am having a technical problem with converting grib2 to netcdf > > If I run this command > java -Xmx1g -classpath netcdfAll-4.3.jar ucar.nc2.dataset.NetcdfDataset -in > T+06_0600.grib2 -out outfile.netcdf > > I get this error > > Sep 13, 2013 12:54:58 PM ucar.nc2.util.DiskCache2 setRootDirectory > INFO: DiskCache2 create directory /root/.unidata/cache/ > Sep 13, 2013 12:54:58 PM ucar.nc2.grib.grib2.Grib2CollectionBuilder > readOrCreateIndex > INFO: T+06_0600_2: createIndex /home/nick/Downloads/netcdf/T+06_0600_2.ncx > Exception in thread "main" java.io.IOException: > java.lang.StringIndexOutOfBoundsException: String index out of range: -16 > at ucar.nc2.NetcdfFile.open(NetcdfFile.java:425) > at > ucar.nc2.dataset.NetcdfDataset.openOrAcquireFile(NetcdfDataset.java:699) > at ucar.nc2.dataset.NetcdfDataset.openFile(NetcdfDataset.java:560) > at ucar.nc2.dataset.NetcdfDataset.main(NetcdfDataset.java:1910) > Caused by: java.lang.StringIndexOutOfBoundsException: String index out of > range: -16 > at java.lang.String.substring(String.java:1875) > at > ucar.nc2.grib.GribCollectionBuilder.makeFiles(GribCollectionBuilder.java:39) > at > ucar.nc2.grib.grib2.Grib2CollectionBuilder.createIndex(Grib2CollectionBuilder.java:610) > at > ucar.nc2.grib.grib2.Grib2CollectionBuilder.createIndex(Grib2CollectionBuilder.java:435) > at > ucar.nc2.grib.grib2.Grib2CollectionBuilder.readOrCreateIndex(Grib2CollectionBuilder.java:148) > at > ucar.nc2.grib.grib2.Grib2CollectionBuilder.readOrCreateIndexFromSingleFile(Grib2CollectionBuilder.java:76) > at > ucar.nc2.grib.GribIndex.makeGribCollectionFromSingleFile(GribIndex.java:122) > at ucar.nc2.grib.grib2.Grib2Iosp.open(Grib2Iosp.java:311) > at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1521) > at ucar.nc2.NetcdfFile.open(NetcdfFile.java:813) > at ucar.nc2.NetcdfFile.open(NetcdfFile.java:422) > ... 3 more > > > > If I start up netCDFtools.jnlp and open the grib2 file in there then it > opens fine. After I have done that I can run the java command again > > java -Xmx1g -classpath netcdfAll-4.3.jar ucar.nc2.dataset.NetcdfDataset -in > T+06_0600.grib2 -out outfile.netcdf > > and it will give this output with the resulting outfile > > Sep 13, 2013 12:59:38 PM ucar.nc2.util.DiskCache2 setRootDirectory > INFO: DiskCache2 create directory /root/.unidata/cache/ > NetcdfDatataset read from T+06_0600.grib2 write to outfile.netcdf > finished=false > > > I am assuming netCDFtools is managing to create the gbx9 and ncx files more > successfully. > Is there anything you can recommend for me to try to get the java command > working without needing to open netCDFtools? > > many thanks > > > > address@hidden> wrote: > > > No problem, just ask if you get stuck. Grib is tricky, and we sometimes > > run into problems. > > > > -Lansing > > > > Ticket Details > > =================== > > Ticket ID: CJU-478813 > > Department: Support netCDF Java > > Priority: Normal > > Status: Open > > > > > > Ticket Details =================== Ticket ID: CJU-478813 Department: Support netCDF Java Priority: Normal Status: Closed