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.
Wei, It looks like the assertion violation you see only occurs if the netCDF-C library is built with the HDF5 library but without the HDF4 library. I just tested with netCDF-4.3.2 built with --enable-hdf4 and with an HDF5 library, and it worked fine, with ncdump treating it as a normal netCDF-4 file. If I try a version of netCDF-4.3.2 built with neither the HDF4 or HDF5 library (so it only supports netCDF-3 API), it returns an error code indicating it's an unknown file format. Dennis is working on a fix. --Russ > I have put that file on a ftp site. > to get it: > > ftp ftp.cgd.ucar.edu > > Name(...): anonymous > Password: your-email > ftp> cd incoming > ftp> get avhrr.hdf > ftp> quit > > Certainly this file is NOT a netcdf file. > So, we do not expect to open it properly, > but expect to return an error code. > > Here is a short C code to reproduce the issue: > > #include <stdio.h> > #include <string.h> > #include <netcdf.h> > > #define FILE_NAME "avhrr.hdf" > > /* Macro for error handling */ > #define BAIL(e) do { \ > printf("Bailing out in file %s, line %d, error:%s.\n", \ > __FILE__, __LINE__, nc_strerror(e)); \ > return e; \ > } while (0) > > int main() > { > int ncid; > int res; > size_t ChunkSizeHint = 1024; > > printf("open file: %s\n", FILE_NAME); > if((res = nc__open(FILE_NAME, NC_NOWRITE, &ChunkSizeHint, &ncid))) > BAIL(res); > > printf("ncid = %d\n", ncid); > > /* Close the file. */ > res = nc_close(ncid); > > return 0; > } > > > Thanks for checking this issue. > > Wei > > > > > ================================================ > 1850 Table Mesa Dr. > Boulder, CO 80307 > Phone: 303-497-8924 > > address@hidden> wrote: > > > [Dennis Heimbigner intruding on this conversation] > > > > I do not understand how this can occur. The file type should > > have been checked in libdispatch/dfile.c#NC_check_file_type. > > We can fix the the assert, but I really would like to know > > how this seemingly impossible case can occur. > > Is there any chance of us getting a copy of that file. > > I am guessing, that it looks like an hdf5 or hdf4 file, > > but really isnt. > > > > =Dennis Heimbigner > > Unidata > > > > > > Ticket Details > > =================== > > Ticket ID: UDG-681606 > > Department: Support netCDF > > Priority: Normal > > Status: Closed > > > > > > Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: UDG-681606 Department: Support netCDF Priority: Normal Status: Closed