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.
Hellp,I agree with the comments made in this email conversation. However, it may be useful to understand the motivation for implementing a specific C++ API. These are essentially that the use of it in a C++ code should appear simpler and be more robust than the C API. This is achieved by
(i) use of parametric polymorphisms (C++ templates functions) (ii) encapsulation (existence of private data).(iii) error handling: the presence of an error automatically "throws" an error. There is extensive consistency checking within the API. (iv) inheritance (this relates classes with similiar "traits", eg NcFile and NcGroup; also NcType, NcVLen, Nc EnumType etc).
The use of complicated user-defined types in the exisiting C-API can be difficult, particularly if you do not know the sizes of elements at compile time. This is because you need to deal with offsets and alignment issues of the data components. I have implemented a C++ API that can handle this for user-defined types of arbitrary complexity. I intended to release this 15months ago, but unfortunately
it has been delayed due to a a bug, we think in the HDF5 layer. Lynton Appel On 03/04/2013 12:18 AM, Lynnes, Christopher S. (GSFC-6102) wrote:
Taylor, I can't help thinking that the C++ library you are using seems a little more brittle than the C route at this phase in its evolution. Have you considered making calls to the C API from your C++ call? THe methods for extracting subsets of variables are quite clear in the C API... On Mar 3, 2013, at 4:34 PM, Taylor Binnington<tbinnington@xxxxxxxxx> wrote: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, 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 _______________________________________________ netcdfgroup mailing list netcdfgroup@xxxxxxxxxxxxxxxx For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/-- Dr. Christopher Lynnes, NASA/GSFC, ph: 301-614-5185 _______________________________________________ netcdfgroup mailing list netcdfgroup@xxxxxxxxxxxxxxxx For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/
netcdfgroup
archives: