[netcdfgroup] netCDF C++ Library : Different Data type

Hello guys,

I have a problem with netCDF C++ Library.

I am using the "molloc" to assign the memory like below.
*float **snow_we;
snow_we = FloatMatrix(tcount,npix); -> this is to assign the memory using
"molloc".
*
And, save the data into snow_we like below.
*for (int j = 0; j < npix; j++) {
   snow_we[count-1][j] = we_val[j];
}
*

Then, using the netCDF c++ library, create the netCDF file.
However, the data does not saved properly, because I think the
"snow_we[0][0]" in the red line is made by "molloc".
If I use "float snow[100][100]" instead of "molloc" when I was assigning teh
memory, it is saved properly. But, I must use "molloc" because of lots of
iteration.
So, do you guys know how can I solve this problem?

*NcFile dataFile("netcdfname", NcFile::Replace);
if (!dataFile.is_valid()) {
   cout << "Could not open the netcdf file ! \n " << endl;
}

NcDim* xDim = dataFile.add_dim("x",tcount);
NcDim* yDim = dataFile.add_dim("y",npix);
NcVar *data = dataFile.add_var("data",ncFloat,xDim,yDim);
data->put(&snow_we[0][0],tcount,npix);

FreeFloatMatrix(snow_we,tcount);
*
Thanks,
  • 2010 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: