Tom,
The nccopy utility reads an input netCDF file using only the netCDF C
API and writes a copy using the netCDF API. It can detect problems in
the file metadata and data, such as might be caused by inadvertently
overwriting part of the file or truncating it. If you just want to
detect whether the entire file is readable through the netCDF API, you
can use nccopy to read it and copy it to a temporary file.
--Russ
On 3/2/2012 8:05 PM, Tom Roche wrote:
> Is there a tool to verify the correctness of the structure of a netCDF file,
> à la what `tidy` does for HTML? Why I ask:
>
> I'm using NCO and R to manipulate and display my netCDF files (actually IOAPI
> files, to be completely correct). Most of my group uses Fortran and the
> display tool `verdi`. (We're all on linux.) I have a file on which I've used
> R (up-to-date, with package=ncdf4) and NCO (also up-to-date), which are both
> happy with it. However, when I try to open it as a dataset with verdi, I get
>
>> java.lang.NullPointerException
>> at
>> ucar.nc2.dataset.conv.M3IOConvention.makeZCoordAxis(M3IOConvention.java:180)
>> at
>> ucar.nc2.dataset.conv.M3IOConvention.constructCoordAxes(M3IOConvention.java:143)
>> at
>> ucar.nc2.dataset.conv.M3IOConvention.augmentDataset(M3IOConvention.java:85)
>> at ucar.nc2.dataset.NetcdfDataset.enhance(NetcdfDataset.java:465)
>> at ucar.nc2.dataset.NetcdfDataset.<init>(NetcdfDataset.java:1165)
>> at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:440)
>> at
>> ucar.nc2.dataset.NetcdfDataset.acquireDataset(NetcdfDataset.java:527)
>> at ucar.nc2.dt.grid.GridDataset.open(GridDataset.java:103)
>> at ucar.nc2.dt.grid.GridDataset.open(GridDataset.java:89)
>> at
>> anl.verdi.loaders.NetcdfDatasetFactory.openDataset(NetcdfDatasetFactory.java:185)
>> at
>> anl.verdi.loaders.NetcdfDatasetFactory.createModels3Datasets(NetcdfDatasetFactory.java:81)
>> at
>> anl.verdi.loaders.Models3Loader.createDatasets(Models3Loader.java:82)
>> at anl.verdi.data.DataManager.createDatasets(DataManager.java:99)
>> at
>> anl.verdi.core.VerdiApplication.loadDataset(VerdiApplication.java:556)
>> at
>> anl.verdi.core.VerdiApplication.addDataset(VerdiApplication.java:609)
>> at
>> anl.verdi.core.VerdiAppConfigurator$1.actionPerformed(VerdiAppConfigurator.java:63)
> (Before that is all AWT.) I suspect verdi is choking because, while the data
> is 4D, one of the dimensions is non-spatial (the "layers" correspond to
> different crops on the surface, not vertical layers), and that verdi doesn't
> handle that gracefully. But I'd like to verify the correctness of my file
> before I engage their bugtracker. Is there a way to do that?
>
> TIA, Tom Roche<Tom_Roche@xxxxxxxxx>