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

[netCDF #HEV-388573]: NetCDF C library question



Good question. Is it possible to create a .cdl file to show what you are 
doing?

On 5/19/2017 9:39 AM, James Gallagher wrote:
> New Client Reply: NetCDF C library question
> 
> Dennis,
> 
> I probably should have replied directly to youâ
> 
> However I was thinking about this and hereâs my question/thought: Could it 
> be that the attribute is âtextâ (a 1D array of chars) while the variable 
> is a 2d array of char? That is, the variable in question _is_ a 2d array of 
> char - itâs an array of strings, but in netcdf3 (or netcdf4 classic) 
> thatâs a 2d array of char, correct? So maybe thatâs the nature of the 
> type mismatch?
> 
> If so, how do I handle this? The data are originally in/from a HDF4 file (or 
> maybe HDF5).
> 
> Thanks,
> James
> 
>> On May 17, 2017, at 17:06, James Gallagher <address@hidden> wrote:
>>
>>>
>>> On May 17, 2017, at 15:57, Unidata netCDF Support <address@hidden 
>>> <mailto:address@hidden>> wrote:
>>>
>>> nc_put_att_text should work. s/uchar fails because they
>>> are in effect conversions from int8/uint8 respectively.
>>> and number->char conversions are disallowed.
>>> I am surprised that nc_put_att_text failed.
>>> Any hope of providing a small fragment of code showing the failure?
>>
>> OK. When I sent my first message I was trying to use nc_put_att_uchar(). 
>> Iâve switched back to nc_put_att_text() and now I get different error 
>> messages for nc3 and nc4:
>>
>> nc3: NetCDF: Not a valid data type or _FillValue type mismatch
>>
>> nc4: NetCDF: Invalid argument
>>
>> Hereâs the code (itâs somewhat tortured at this point because Iâm 
>> hacking it and running it in the debugger, â):
>>
>>          if (new_name == "_FillValue") {
>>              nc_type xtype;
>>              stax = nc_inq_vartype(ncid, varid, &xtype);
>>              if (stax != NC_NOERR) {
>>                  FONcUtils::handle_error(stax,
>>                      string("File out netcdf, failed to get variable type 
>> while processing attribute ").append(new_name),
>>                      __FILE__, __LINE__);
>>              }
>>              cerr << "Variable type: " << xtype << endl;
>>              // NC_CHAR is 2
>>              // NC_STRING is 12
>>
>>              stax = nc_put_att_text(ncid, varid, new_name.c_str(), 
>> val.length(), val.c_str());
>>          }
>>
>> The output to cerr is â2â.
>>
>> The variable is made using:
>>
>> int stax = nc_def_var(ncid, _varname.c_str(), d_array_type, d_ndims, 
>> &d_dim_ids[0], &_varid);
>>
>> where, in this case, d_array_type is NC_CHAR and d_ndims is 2.
>>
>> The variable in question is an array of strings, so the code makes a 2D 
>> array of char.
>>
>> Note that for nc4 Iâm testing the case where the file is created using the 
>> âclassicâ model.
>>
>> Thanks,
>> James
>>
>> PS. I think Ted H told me that you were using THGâs hdf5 (and hdf4?) C 
>> libraries. Is that true?
>>
>>> =Dennis Heimbigner
>>>   Unidata
>>>
>>>
>>> Ticket Details
>>> ===================
>>> Ticket ID: HEV-388573
>>> 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.
>>>
>>>
>>
>> --
>> James Gallagher
>> address@hidden <mailto:address@hidden>
> --
> James Gallagher
> address@hidden
> 
> 
> 
> 
> 
> 
> 
> Ticket Details
> ===================
> Ticket ID: HEV-388573
> Department: Support netCDF
> Priority: Normal
> Status: Open
> Link:  
> https://andy.unidata.ucar.edu/esupport/staff/index.php?_m=tickets&_a=viewticket&ticketid=28290
> 



Ticket Details
===================
Ticket ID: HEV-388573
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.



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.