Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.

[netcdfgroup] Subsetting data with C++ API calls

Hello,

I'm attempting to read only certain parts (specific indices of specific
variable arrays), remotely, from a MERRA HDFEOS file.

I've recently upgraded to NetCDF 4.2.1.1, using Lynton's C++ library. At
first, I was using trying to subset the data directly from an OPeNDAP URL
supplied to NcFile, but it's been suggested to me, by an earlier post in
the OPeNDAP 
forums<https://groups.google.com/a/opendap.org/forum/?fromgroups=#!topic/opendap-tech/n7f2j0SRPL0>,
that this is not a good way to go. Instead, I should use NetCDF API calls.

I have carefully read through the C++ interface guide, including this
example:

http://www.unidata.ucar.edu/software/netcdf/docs/cxx4/test_var_8cpp-example.html

but am struggling to understand how to do this. A push in the right
direction would be very appreciated. The example (I don't fully understand
it, but was trying to emulate some of the example that I linked above)

#include <iostream>
#include <netcdf>
int main() {
NcFile dataFile("
http://goldsmr2.sci.gsfc.nasa.gov/opendap/hyrax/MERRA/MAT1NXSLV.5.2.0/1991/01/MERRA100.prod.assim.tavg1_2d_slv_Nx.19910101.hdf";,
NcFile::read);
NcGroup grouptest(dataFile.addGroup("Dataset"));
}

gives me the error:

terminate called after throwing an instance of
'netCDF::exceptions::NcNotNc4'
  what():  NcNotNc4: Attempting netcdf-4 operation on netcdf-3 file.
file: ncGroup.cpp  line:265
Aborted

This is not surprising, since the file is not a NetCDF-3 file.

Thank you in advance.
Taylor

-- 
Taylor Binnington
e. tbinnington@xxxxxxxxx
  • 2013 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: