Re: [netcdfgroup] NcType problems on Ubuntu 16.04

Hi Elizabeth,


Thank-you for your help and suggestion.


I have tried using NcGroup::getType(), but I still get exceptions when I used 
non-netCDF3 types.  e.g.:


    netCDF::NcFile ncFile("test.nc", netCDF::NcFile::replace, 
netCDF::NcFile::nc4);

    // works
    auto ncFloat = ncFile.getType("float",netCDF::NcGroup::ParentsAndCurrent);
    std::cout << "ncFloat.getName() = " << ncFloat.getName() << std::endl;

    // throws NcBadType
    auto ncString = ncFile.getType("string",netCDF::NcGroup::ParentsAndCurrent);
    std::cout << "ncString.getName() = " << ncString.getName() << std::endl;

    // throws NcBadType
    auto ncUint = ncFile.getType("uint",netCDF::NcGroup::ParentsAndCurrent);
    std::cout << "ncUint.getName() = " << ncUint.getName() << std::endl;


Again, this works on Ubuntu 14.04 with netCDF 4.1.3 but not on Ubuntu 16.04 
with netCDF 4.4.0.  As far as I can tell, this means I cannot make variables of 
type string, uint etc?


Best regards,

Daniel


________________________________
From: Elizabeth A. Fischer <elizabeth.fischer@xxxxxxxxxxxx>
Sent: Friday, 2 December 2016 5:07 PM
To: Potter, Daniel (Energy, Newcastle)
Cc: netcdfgroup@xxxxxxxxxxxxxxxx
Subject: Re: [netcdfgroup] NcType problems on Ubuntu 16.04

Daniel,

I believe you're using the "new" (NetCDF4) C++ interface?

It has known problems with NcType, specifically for any types not in the 
NetCDF3 data model.  I solved them by using strings instead of the symbolic 
enums; some of the API functions take strings.  If I need a NcType object, I 
use the following function to get one:

inline netCDF::NcType nc_type(netCDF::NcVar ncvar, std::string sntype)
    { return ncvar.getParentGroup().getType(sntype, 
netCDF::NcGroup::ParentsAndCurrent); }

-- Elizabeth
  • 2016 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: