NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
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?
netcdfgroup
archives: