-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NetCDF-CXX4 Fails a Unit Test #30
Comments
I've traced this to the NetCDF package. Consider the code::
This produces error = -45 (unknown NetCDF type). It works if myID=NC_INT. Here's my current software stack, I'm going to try different versions of NetCDF or HDF5:
|
This is a bit peculiar, the test on my end clearly fails but returns a success code anyways. I will investigate this and see if I can figure out what is going on. |
I've opened an issue over at the C library and am investigating this now. |
Ward, Does this mean that you were able to replicate the failure with your Thank you, On Mon, Mar 28, 2016 at 12:41 PM, Ward Fisher [email protected]
|
Hi Elizabeth, yes, this error is in the library and not at all related to anything you are doing wrong, so don't worry about that. I appreciate very much your work figuring out that this is in the C library, it saved me time and gave me a good starting point. On the C library, I'm working now in a branch |
My mistake, the branch for netcdf-c is |
I also made a little test, but it hasn't turned up anything. The code:
The output:
On Mon, Mar 28, 2016 at 2:54 PM, Ward Fisher [email protected]
|
I looked at the test on branch gh240. I would expect it to fail on My best guess at this point is the problem lies in netcdf-cxx4, somewhere -- Elizabeth On Mon, Mar 28, 2016 at 2:54 PM, Ward Fisher [email protected]
|
I've made a little bit of progress, and it looks like one of two things is going on. Either we had an oversight when we implemented CDF5, so that data types that are now supported are throwing an error when they shouldn't, or we are querying a file which doesn't support 64-bit int, e.g. a netCDF3 file. I need to poke around more to see what the expected behavior is, but I have tracked down the issue into NC3_inq_type. I've just run another quick test using The test you inserted above, where you pass in the ncid; do you see an issue if you pass in either an ncid generated by a call to nc_open() where you've specifed either a type The test I've created can be viewed at https://github.com/Unidata/netcdf-c/blob/gh240/nc_test/tst_inq_type.c, although I'm playing around with it locally. |
@citibeth I agree; I'm looking more closely at the C++ test now to try to determine where things are going off the rail. |
I extended my test, now it tries stuff with the C++ API as well:
The output:
So... the file was created correctly with the C++ API, but then somehow nc_inq_type() got confused when called form C++. Now supposing I create in the C++ API using NcFile::classic instead of NcFile::nc4. The output is the same, except for the following section:
Conclusion: the problem is not in the creation of the file. Creating files works as it should in C and C++ APIs. |
I have more clues. Consider the code:
Its output is:
Something is different when calling addVar(ncInt64) vs. addVar("int64"). When using symbols, it seems to kick into NetCDF-3 restricted mode. |
Ok, I think the issue is this: when NcType:getName is called, it is passed an invalid ncid, e.g. one not associated with an open file. Why it needs an open file to operate is a question I can't answer, but for now I'll trust that it was designed that way for a reason. Without a valid ncid value, there is a fallback function (in libnetcdf) that will work for all types valid in netCDF3, but not valid for anything else. NC_UBYTE et. al. are falling into this logic block, which is explicitely returning I need to think about how to best address this; whether the fix is to change how the C++ test works, or whether the fall-back function in libnetcdf should be modified to return information for a broader set of data types. |
Thanks, it sounds like you got it.
Because the correct result of nc_inq_type() changes depending on whether the file you opened allows NetCDF-4 types. Changing the function in libnetcdf might fix the C++ problem at hand, but would seem to be a step in the wrong direction. And could break someone else.
This is not just a problem with the tests, the library needs to be fixed. Right now, I cannot create variables of type ncInt64. I guess things work with "int64" string because it does a fresh lookup of types from the open NetCDF file. I will see if I can change my code to use that API and move on. On the larger scale... I'm not sure what having classes (and then singleton instances ) for each netCDF data type buys us. I would have just kept them as a set of enumerations, as in the C API. Maybe the fix would be to do away with NcType and all its subclasses. |
@citibeth Thanks, that is good to know. I'll have to write some broader tests for creating files and data types, so that these sorts of issues 1) show up on our testing dashboard and 2) offer a toe-hold for debugging. While I'm well versed with C++, the current C++ interface was broadly contributed to us, as we were fairly resourced constrained (and have grown moreso). I agree with you that this definitely needs to be fixed so that you can create things with the "int64" string. I'm juggling a few things but will make this a priority. I'm surprised we haven't had any other reports about it, however. |
I am working around this bug, so there is no need to fix it in a rushed manner. The main place I call
I will change the signature of my function to:
I will then call the all-string version of Meanwhile... I will change all calls to get_or_add_var() to use string constants instead of I think that will do the job for now. Please tell me if you see any pitfalls in the plan. I appreciate the time you've put into this issue today. |
Actually... if netcdf is going to be changed, I think the RIGHT thing to do Then re-design the C++ API around that reality. -- Elizabeth On Mon, Mar 28, 2016 at 3:43 PM, Ward Fisher [email protected]
|
My 2c worth.
For number one, IMO, we should do this for all known atomic types #2 is harder: in effect, we need to know the type of the actual file (CLASSIC, CDF5, NETCDF4, etc) |
For now, I'm going to fix this as follows. At the root of the issue is the fact that the C++ interface did not adhere to the C library standard, e.g. a valid Note that ncType.getName() and ncType.getSize() don't actually change anything with the ncid they are passed; they just perform a check to validate the ncid and gate off the type of file it correspond to. |
Ward, The use of a global ncid worries me. What if I do (pardon my loose C++): NcFile nc1('file1.nc', nc4); I expect that the problem I'm encountering will re-appear then. Maybe an alternative: hardcode the values of NcInt64::getName(), etc to (and similarly for all other types in NetCDF-4 but not NetCDF-3) This would be roughly equivalent to the original idea to change the C API. -- Elizabeth On Tue, Mar 29, 2016 at 2:57 PM, Ward Fisher [email protected]
|
@citibeth You are correct that there will remain circumstances in which this fix is insufficient, and I'm not happy about that; it may just be the best of a bad situation, at the moment. I originally went down the hardcoded @DennisHeimbigner just came in to my office to discuss this issue, and I think we are in agreement for a broader fix. Ultimately, the fix is going to be to loosen up the For the short term, at least, this will provide a fix that will work for what seems to be the majority of our users, and will let me get the C++ release out the door without having to wait on another C library release cycle. |
I've opened #32 to ensure that this does not fall off the radar. |
\Brief Release notes file for the netcdf-cxx4 package. This file contains a high-level description of this package's evolution. Releases are in reverse chronological order (most recent first). Note that this file was created and maintained starting with the `netcdf-cxx4 4.3.0 release`. ## netCDF-CXX4 4.3.2 TBD ## netCDF-CXX4 v4.3.1 September 11, 2019 ### Requirements * netCDF-C 4.6.0 or greater ### Changes * [Enhancement] Added cmake support to distribution files created by `make dist`. * [Bug Fix] Added `ncFile::create()`, also added a new `open` function and constructor to allow for more flexibility when opening a file. See [GitHub #55](Unidata/netcdf-cxx4#55) for more information. * [Enhancement] Addressed an issue reported with `Intel Compilers 17.0.0`. See [GitHub #41](Unidata/netcdf-cxx4#41) for more information. * [Enhancement] Updated how `configure` determines information about the existing netCDF-C install. See [GitHub pull request #39](Unidata/netcdf-cxx4#39) for more information. * Corrected an issue where cmake-based builds weren't generating `ncxx4-config`. See [GitHub pull request #37](Unidata/netcdf-cxx4#37) for more information. ## netcdf-cxx4 v4.3.0 released May 13, 2016 * Fixed an issue where the tests were failing silently, and the underlying `NcType` class could not properly determine the type name or type size reliably. See [GitHub issue #30](Unidata/netcdf-cxx4#30) for more information. * Changed `NCXX_ENABLE_DOXYGEN` option to an easier-to-remember `ENABLE_DOXYGEN`. * Added `--enable-doxygen`, `-DNCXX_ENABLE_DOXYGEN=ON` options to allow generation of netCDF-CXX4 documentation via doxygen using either `configure` or `cmake`, respectively. * Added `netcdf-cxx4` to the [Coverity Scan Dashboard](https://scan.coverity.com/projects/unidata-netcdf-cxx4?tab=overview). * Added `open` and `close` methods for NcFile. See [Github Pull Request #18](Unidata/netcdf-cxx4#18) for more information. * Added `netcdf-cxx4` to travis-ci.org. See [https://travis-ci.org/Unidata/netcdf-cxx4](https://travis-ci.org/Unidata/netcdf-cxx4) for more details. * Added `NcCompoundType` methods `getMemberName` and `getMemberIndex`. See [Pull Request #19](Unidata/netcdf-cxx4#19) for more details. * Added `cmake` support to `netcdf-cxx4`, which will allow us to create a `CDash` continuous integration dashboard similar to those created for the `netcdf-c` and `netcdf-fortran` projects. * Added a `travis-ci` configuration file, `.travis.yml`. * Created `RELEASE_NOTES.md`.
Closes Unidata#30 Fixes Unidata#32 Global file ID is no longer needed now that `nc_inq_type` can take a group ID (valid since netCDF-C 4.4.1)
The unit test cxx4_test_type is failing, I believe on the type ncInt64. I've build things here with HDF5 enabled. As you can see below in the examples, this NetCDF had no problem writing nc4 files.
In real life (outside of unit tests), I'm not able to create any int64 variables with netcdf-cxx4. (I AM able to do so via ncgen, or via the Python interface).
Attached are build logs for netcdf and netcdf-cxx4.
netcdf-build.txt
netcdf-cxx4-build.txt
Help... any ideas?
Thank you,
-- Elizabeth
The text was updated successfully, but these errors were encountered: