-
Notifications
You must be signed in to change notification settings - Fork 267
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
patch related to Issue258 #319
Conversation
…utes in CDF-2 file format
…les in CDF-2 file format
…utes/variables in CDF-2 file format
…utes in CDF-2 file format
…utes/variables in CDF-2 file format (no NC_ERANGE check)
Seeing some failures on 32-bit ARM. |
I don't understand the issue of arm. Wei-keng On Oct 6, 2016, at 1:38 PM, Ward Fisher wrote:
|
I don't think that this has anything to do with issue #159, or char being unsigned by default. In the link I provided to the test failures here, I'm seeing the following:
I have not had any time to investigate this and the error will likely be easy enough to resolve. I was simply making a note here of the failure on a platform which isn't part of the travis-ci checks, so that I didn't merge before resolving the issue. |
In master branch, the definition of ncx_getn_text in ncx.m4 is Wei-keng On Oct 6, 2016, at 2:33 PM, Ward Fisher wrote:
|
Ok, that does indeed tie it back to #159, thanks; I hadn't started poking into it yet. I'll have to refer back to my notes. The |
Hi, Ward, I noticed your comments on Dec 23, 2015. You indicates the cause of problem is "on ARM, the cast results in a value of 0"
When *tp < 0, the if condition above has already detected NC_ERANGE. So, the question is "why did it not stop there to break the loop to If it goes ahead with the assignment, then the outcome of this assignment I may not fully understand the ARM issue, but I feel the issue is more in Wei-keng On Oct 6, 2016, at 2:41 PM, Ward Fisher wrote:
|
…ption fro CDF-5 format
… and add nc_err_code_name
As I recall the ERANGE error is different, in that if it occurs, the data will still be copied, but the error will be returned. These were the rules built into netCDF-3. |
Here is my analysis. |
One question. Is the following setting from nc_test/tests.h intended?
I assume on ARM, SCHAR_MIN is -128 which makes X_CHAR_MIN negative. |
As I recall from a conversation with Russ, NC_ECHAR is returned, but the conversion is still attempted, at least in the netcdf library. Regarding nc_test, it was written long before my involvement, and I have not had the resources to go through and do any serious revisions to it yet. Perhaps that will change soon!
That is my conclusion as well. I haven't had a chance to come back to this issue yet, but I will try to do some more debugging later today or tomorrow. When this issue was last observed, it was the result of casting from a double to an unsigned char; undefined behavior which, on ARM, results in a '0'. |
If you check netcdf-3.6.1/src/libsrc/putget.c, NC_ECHAR is thrown right after a call to NC_lookupvar() for both put and get APIs, and the API returns immediately. (This also leads to the issue of ERANGE_FILL I raised earlier in this discussion thread.) As for type casting from a double to an unsigned char on ARM, The same casting is done for both master and ghpull-319-arm branches (I checked that part of codes and they are the same). I am puzzled why casting 128 results in '\0' on ghpull-319-arm but "\200" on master. Only a printf can confirm the case. |
…on, may need byte-swap when retrieved to a memory buffer (internal representation)
I just found a serious bug that needs to be fixed. Sorry to break the promise not to touch branch issue258. |
Merged patch into local branches, continuing to debug. |
Step one (things compile and run across platforms) nearly complete; dealing with some visual studio related issues right now. Then the next step will be to take a step back and evaluate what is going on, adjust tests as need be, and look at the broader scope of the pull request. |
Hi, Ward |
…or write at first place
Thanks for your help debugging this. Hope to have the issues resolved today, then will review functionality and hopefully be able to resolve the pull request and move on to the full release! |
FYI. Tested it on a Redhat box and your raspberry pi without errors.
|
Seeing a build failure under Visual Studio/Windows with the ghpull-319-arm branch from @wkliao but at a glance it looks straight forward to fix. Will address and hopefully put this to bed by early next week. Confirmed tests work on ARM and Linux and OSX. |
Can you point me to the build outputs on the Visual Studio/Windows? |
Can you open a new pull request based on your new branch and I will evaluate as soon as I can, as well as get the visual studio output posted somewhere. |
Done. The new pull request is #375 |
Dennis and I have discussed this (in terms of pull request #375 and we are going to accept it with the following caveats), based on the summary in this comment:
@wkliao a quick question; while we were going back through the issues you reference, it appears that the relaxed coordinate bounds option is specific to pnetcdf related use cases. Is there any reason you can think of not to make this option conditional on pnetcdf support? I.e., this option is not available if you aren't linking against pnetcdf? Thanks again for your patience and help with this; once this is done we can start looking at additional pull requests; we really appreciate the series of smaller pull requests you've been issuing, it makes things much faster on our end with our limited resources :). |
FYI, if a user is building netCDF using PnetCDF with erange-fill enabled, then netCDF will automatically enable it (I believe I added that in configure.ac and CMakeList.txt).
I believe RELAX_COORD_BOUND feature is also available for netCDF when built without PnetCDF. Try "git grep RELAX_COORD_BOUND". You will see it is used in libsrc and libsrc4. |
Merged upstream, see #375 comments for more info. |
This patch addresses the special case when calling _uchar APIs to access NC_BYTE attributes or variables in CDF-1 and CDF-2 files.
The special case description can be found in http://www.unidata.ucar.edu/software/netcdf/docs_rc/data_type.html#type_conversion
Quoted here: "In netcdf-3, we treat NC_BYTE as signed for the purposes of conversion to short, int, long, float, or double. (Of course, no conversion takes place when the internal type is signed char.) In the _uchar functions, we treat NC_BYTE as if it were unsigned. Thus, no NC_ERANGE error can occur converting between NC_BYTE and unsigned char."
In other words, if called from signed APIs, NC_BYTE variables are treated as signed. If called from unsigned APIs (i.e. _uchar APIs, the only unsigned APIs in netCDF-3) they are unsigned. NetCDF-3 specifically makes an exception to skip NC_ERANGE check when calling _uchar APIs to access NC_BYTE variables.
However, in netCDF-4 and CDF-5, because of the introduction of the new data type NC_UBYTE, an unsigned 8-bit integer, which makes NC_BYTE an signed 8-bit integer and thus renders the above exception less sense. In this patch, regular NC_ERANGE check is performed in all APIs that access NC_BYTE variables for CDF-5 files.
On the other hand, it still honors the above exception for CDF-1 and 2 files.
Note PnetCDF 1.7.0 does not handle this exception completely. The fix will appear in the next release 1.7.1. If netCDF decides to incorporated this patch in its next release, please suggest users to use PnetCDF 1.7.1.