[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #PXO-118189]: Segmentation fault C++



Ok, I can see at least one major problem. When you read a 2-D variable,
it is read as a 1-D variable of size dimX*dimY. So, you need to declare
data in as float* not float** and you need to do a single datain = new 
float[nx*ny].


> I am using netcdf-cxx-4.2.
> When I try to read the data with allocated arrays, then the data is not read 
> completely (in simple_xy.nc there are numbers from 0 to 71 and every 11 
> numbers 4 numbers are missing in dataIn). In the internet people say that one 
> should use vectors instead of this allocating thing, but I guess it is not 
> working with the get() function?
> 
> In this case I get the "double free or corruption error". I have also these 
> programs with the "normal" arrays and segmentation fault. I can send them to 
> you, too, if I really can't use dynamic arrays.
> ________________________________________
> Von: Unidata netCDF Support [address@hidden]
> Gesendet: Mittwoch, 13. Dezember 2017 22:48
> An: Mittelstädt, Lisa
> Cc: address@hidden
> Betreff: [netCDF #PXO-118189]: Segmentation fault C++
> 
> A couple of questions.
> 1. Are you using netcdf-3 or netcdf4?
> 2. Can you post your program here as an email attachment?
> 
> >
> > I am using netCDF in C++. With relative small arrays everything works
> > fine.  But when I try to use an 4D array with 7*10^6 floats (it is also
> > failing with a 1D array), I get segmentation fault error in that line,
> > where I declared my array. I would like to allocate the array in the
> > heap, but the function for writing the netcdf data in the array (e.g.,
> > data->get(&dataIn[0][0], NX, NY) as in simple_xy_rd.cpp) is only working
> > with "normal" arrays. Is there any way to do this with allocated arrays?
> >
> > Best regards,
> > Lisa Mittelstaedt
> >
> >
> 
> =Dennis Heimbigner
> Unidata
> 
> 
> Ticket Details
> ===================
> Ticket ID: PXO-118189
> Department: Support netCDF
> Priority: Normal
> Status: Open
> ===================
> NOTE: All email exchanges with Unidata User Support are recorded in the 
> Unidata inquiry tracking system and then made publicly available through the 
> web.  If you do not want to have your interactions made available in this 
> way, you must let us know in each email you send to us.
> 
> 
> 
> 

=Dennis Heimbigner
  Unidata


Ticket Details
===================
Ticket ID: PXO-118189
Department: Support netCDF
Priority: Normal
Status: Open
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.