Make a temp directory and get a GRIB2 file, such as:
mkdir -p ~/temp && cd ~/temp
wget "http://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2014071900/gfs.t00z.master.grbf00.10m.uv.grib2"
Make a simple class to open this file with a relative path:
public final class Driver {
public static void main(String[] args) throws Exception {
ucar.nc2.NetcdfFile.open("gfs.t00z.master.grbf00.10m.uv.grib2");
}
}
Run this tool from the temp directory (~/temp).
RESULT:
Caused by: java.lang.NullPointerException
at ucar.nc2.util.DiskCache2.canWrite(DiskCache2.java:256)
at ucar.nc2.util.DiskCache2.getFile(DiskCache2.java:236)
at ucar.nc2.grib.collection.GribCollection.getFileInCache(GribCollection.java:203)
at ucar.nc2.grib.grib2.Grib2Index.readIndex(Grib2Index.java:119)
at ucar.nc2.grib.GribIndex.readOrCreateIndexFromSingleFile(GribIndex.java:100)
at ucar.nc2.grib.collection.Grib2CollectionBuilder.makeGroups(Grib2CollectionBuilder.java:115)
at ucar.nc2.grib.collection.GribCollectionBuilder.createIndex(GribCollectionBuilder.java:117)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromDataFile(GribCdmIndex.java:632)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromDataFile(GribCdmIndex.java:616)
at ucar.nc2.grib.collection.GribCdmIndex.makeGribCollectionFromRaf(GribCdmIndex.java:585)
at ucar.nc2.grib.collection.GribIosp.open(GribIosp.java:181)
at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1527)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:819)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:427)
... 4 more
To workaround this bug, use an absolute path to open the file:
(using netcdf4-4.5.1)
REPRO:
~/temp
).RESULT:
To workaround this bug, use an absolute path to open the file: