Opened 9 years ago

Closed 6 years ago

#2379 closed enhancement (fixed)

GDAL with NetCDF4 - Adjustment to recognize netCDF4

Reported by: maartenplieger Owned by: etourigny
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords: netcdf, netcdf4
Cc: Kyle Shannon, maartenplieger

Description

Adjustment to the netCDF driver to recognize the netCDF4 files. In 'netCDFdataset.cpp' at line 1308: I added " && !((nc_inq_libvers()[0]=='4')&&EQUALN((const char *)poOpenInfo->pabyHeader+1,"HDF",3))) ". This line checks for the netCDF4 library ('4') and for a 'HDF' header. This makes sure that in case of the netCDF4 library, HDF files are also picked up by this driver. (NetCDF4 uses the HDF5 file format, see: http://www.unidata.ucar.edu/software/netcdf/netcdf-4/)

Attachments (5)

patch-ncfiletype.txt (4.2 KB) - added by etiennesky 6 years ago.
tmp4.nc (246.7 KB) - added by etiennesky 6 years ago.
tmp4.nc2 (232.9 KB) - added by etiennesky 6 years ago.
tmp4.nc4 (244.1 KB) - added by etiennesky 6 years ago.
h5ex_d_alloc.h5 (2.3 KB) - added by etiennesky 6 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 9 years ago by maartenplieger

Milestone: 1.5.2

Adjustment to the netCDF driver to recognize the netCDF4 files. In 'netCDFdataset.cpp' at line 1308: I added:

&& !(poOpenInfo->nHeaderBytes < 5
((nc_inq_libvers()[0]=='4')&&EQUALN((const char*)poOpenInfo->pabyHeader+1,"HDF",3))))

This line checks for the netCDF4 library ('4') and for a 'HDF' header. This makes sure that in case of the netCDF4 library, HDF files are also picked up by this driver. (NetCDF4 uses the HDF5 file format, see: http://www.unidata.ucar.edu/software/netcdf/netcdf-4/)

comment:2 Changed 9 years ago by maartenplieger

Milestone: 1.5.2
Version: unspecified1.5.0

comment:3 Changed 7 years ago by Kyle Shannon

Keywords: netcdf netcdf4 added; NetCDF4 removed

comment:4 Changed 6 years ago by Kyle Shannon

Cc: Kyle Shannon added

Changed 6 years ago by etiennesky

Attachment: patch-ncfiletype.txt added

Changed 6 years ago by etiennesky

Attachment: tmp4.nc added

Changed 6 years ago by etiennesky

Attachment: tmp4.nc2 added

Changed 6 years ago by etiennesky

Attachment: tmp4.nc4 added

Changed 6 years ago by etiennesky

Attachment: h5ex_d_alloc.h5 added

comment:5 Changed 6 years ago by etiennesky

Version: 1.5.0svn-trunk

Attached a proposed fix for this issue and also #3890 (for nc2 64-bit files). Also a few files for testing.

The proposal is to add a nFiletype variable , #defines for the various NetCDF file types and a new Identify() function. If need be I can also provide a simpler patch which only does the file checking and doesn't mess with the class definition.

If HDF5 is installed in GDAL but NetCDF has not been compiled with NetCDF-4 (and HDF5), the HDF5 GDAL driver is used instead. Also tested a non-netcdf HDF5 file, and the NetCDF driver does not interfere.

comment:6 Changed 6 years ago by etourigny

Owner: changed from warmerdam to etourigny
Status: newassigned

Fixed in trunk.

r23081 adds support for nc2 and nc4 in netcdfdataset.cpp r23080 adds autotests and 3 test files to see if nc2 and nc4 are supported, and also makes sure that hdf5 files (that are not netcdf) are opened by the hdf5 driver.

If someone that has netcdf4 installed can test the fix, I will close the bug.

comment:7 Changed 6 years ago by etourigny

Cc: maartenplieger added
Resolution: fixed
Status: assignedclosed

Please refer to ticket #3890 for fixes and information related to this bug.

Closing this bug as it works for me. Unfortunately, I cannot test in Windows.

Note: See TracTickets for help on using tickets.