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

[netCDF #XUI-152530]: NetCDF

Hi Cevahir,

The problem is that you are allocating the array u10 in a way that makes its 
non-contiguous in memory:

> float ***const u10 = new float** [NT];
> for(int i = 0; i < NT; ++i) {
>       u10[i] = new float* [NY];
> }
> for(int i = 0; i < NT; ++i) {
>       for(int j = 0; j < NY; ++j) {
>           u10[i][j] = new float [NX];
>       }
> }

Addresses of arrays provided as arguments to netCDF functions must point to 
values in memory.  There must not be gaps between successive values of the 
arrays.  Such 
gaps are almost assured if you use "new" to allocate each row of a three 
dimensional array 

For the invocation of the "put" method in

> NcVar *idU10 = dataFile.add_var("U10", ncFloat, dimT, dimY, dimX);
> idU10->put(&u10[0][0][0], NT, NY, NX);

the address &u10[0][0][0] must point to a single block of floats.

Your program should work as intended if you allocate all the values at once.


Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu

Ticket Details
Ticket ID: XUI-152530
Department: Support netCDF
Priority: Urgent
Status: Closed

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.