[netcdfgroup] NC_STRING and NC_CHAR ... How to read strings?

I have a very basic question -- how to read "string" variable in C or
C++ 

The ncdump tells me the variable type is "string".  When I try to read
it using

 void getVar(char* dataValues) const;

function of class NcVar of netcdf-cxx4 I am hitting a segmentation
fault. I am not sure why it is a segmentation fault, but it comes from 

...
   /* No NC_CHAR conversions, you pervert! */
  if (var->type_info->nc_typeid != *mem_nc_type &&
      (var->type_info->nc_typeid == NC_CHAR || *mem_nc_type == NC_CHAR))
    return NC_ECHAR;
...

code in check_for_vara() function in nc4hdf.c .
 The var->type_info->nc_typeid is NC_STRING (12) and this check should
just fail (the reading of the variable should just fail, but it "throws
an exception" ... causes a segmentation fault for some reason).

The stack is;
check_for_vara nc4hdf.c:477
nc4_get_vara nc4hdf.c:905
nc4_get_vara_tc nc4var.c:1379
NC4_get_vara nc4var.c:1396
NC_get_vara dvarget.c:101
NC_get_var dvarget.c:117
nc_get_var_text dvarget.c:1020
netCDF::NcVar::getVar ncVar.cpp:1340
main cfradial_rd.cpp:47
__libc_start_main 0x00007ffff485a413
_start 0x00000000004021ee

The C++ code is calling C function nc_get_var_text() to read this
string which should have been normal.  

What am I doing wrong and what is the right way of reading "string"
variables?

PS. Does anyone else dislike the official C++ library API or it is just
me?  
 
  • 2019 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: