Opened 18 years ago

Last modified 17 years ago

#1176 closed defect

NetCDF Driver picks up zero length files — at Version 7

Reported by: kyngchaos@… Owned by: warmerdam
Priority: high Milestone: 1.4.1
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords:
Cc:

Description (last modified by warmerdam)

When NetCDF support is built into GDAL, the Idrisi driver can't write RST files. Reading works. When using gdal_translate to write an Idrisi file (or in the gdalautotest), it gives an assertion error:

gdal_translate -of RST rgbsmall.tif asdf.rst
Input file size is 50, 50
0posixio.c:396: failed assertion `extent != 0'
Abort trap

I thought it may have something to do with OS X threads (from the posicio.c reference), but disabling threads in gdal didn't help - same error.

Change History (6)

comment:1 by warmerdam, 17 years ago

I have tried to reproduce this on linux with FWTools 1.1.2 unsuccessfully.
The same translation works fine. 

I will test on MacOS X...

comment:2 by warmerdam, 17 years ago

I was able to reproduce the problem on MacOS X, though I think it is only 
occuring there because the asserts() are compiled in. 

I think the problem is that ncopen() is called on a zero length file. 

I think the appropriate solution is to modify netcdfdataset::Open() to only
try and open files with the magic code "CDF\001" at the beginning.  


comment:3 by warmerdam, 17 years ago

This change will be a bit involved, so I am deferring it for now.

comment:4 by kyngchaos@…, 17 years ago

A workaround I found is to reorder the loading of formats in GDALAllRegister() so that netcdf is loaded AFTER idrisi.  This only works when both are built into GDAL, instead of my practice of having netcdf as a plugin.

comment:6 by kyngchaos, 17 years ago

Any chance of some fix making it into 1.4.1? At least the reordering in GDALAllRegister?

comment:7 by warmerdam, 17 years ago

Description: modified (diff)
Milestone: 1.4.1
Summary: new Idrisi support doesn't work with NetCDF enabledNetCDF Driver picks up zero length files

I have added the following check in netCDFDataset::Open() which I think will do the trick. Currently the change is only in trunk, but I'll move it into the 1.4 branch once I have a chance to add a test suite entry for netcdf.

/* -------------------------------------------------------------------- */ /* Does this appear to be a netcdf file? */ /* -------------------------------------------------------------------- */

if( !EQUALN(poOpenInfo->pszFilename,"NETCDF:",7)

&& ( poOpenInfo->nHeaderBytes < 5

!EQUALN((const char *) (poOpenInfo->pabyHeader),"CDF\001",5)))

return NULL;

Note: See TracTickets for help on using tickets.