Fix bug for ocean vector pairs#173
Conversation
aerorahul
left a comment
There was a problem hiding this comment.
Tag @DeniseWorthen for a review on this code as she is the author of this utility.
|
This will take me some time to untangle. |
|
I don't understand the setup in |
Thanks for noticing! I've run another test with the 1/4 deg source dimensions and 1deg output: /scratch4/NCEPDEV/ovp/Karina.Asmar/ocnpost_v2 |
|
It appears this PR will revert the change to the 3d packing that was committed in #117. I think (?) I understand the git history to know what happened and why reversion of that fix is the right action. The initial commit of this code contained a bug in the pack3d routine gfs-utils/src/ocnicepost.fd/utils_mod.F90 Line 123 in 3457e53 Here, The loop should have been over As part of #117, the number of maxvars was increased I'm guessing that now caused the original bug of looping (incorrectly) over 40 vertical levels to break the code. A modification was made to change the packing to resolve this, but for the wrong reason. |
The bug fix from PR #117 was for the packarrays2d function. In the original line where the vecpairs were allocated, there was no corresponding deallocation. During initial testing, when there were 2 or more vector pairs of the same 2d remapping method (bilinear or conserve), this code crashed because the vecpair array was already allocated. By reverting back to the original code, the method works because we trimmed recently the ocean_sfs.csv file and now there is only one vector pair for each dimension and remapping method. In the future, if a csv file is given with more than one vector pair of the same 2d remapping method, this code could crash again. However, the current SFS netcdf ocean ouputs only produce the variables for the current ocean_sfs.csv file (one vector pair for each 2d remapping method), so I cannot test a more robust bug fix for that issue. |
|
@KarinaAsmar-NOAA Thanks. I realized I had a muddled interpretation of the fix #117. The problem is that apparently whatever triggered the error that prompted #117 has now been resolved because you have trimmed the variable lists. I'm a little confused as to whether your original fix was required because of ocean fields or ice. In the ocean.csv that was committed with your #117, I don't see any variables in the ocean list that would have created more than 1 vector pair with the same mapping. I do see such variables in the ice.csv, where both the 2d ocean and atm velocites were being mapped bilinearly. It should be possible to know how many vector pairs are going to be used for a given dimensionality and a given mapping type. The vectorpairs can then have an additional dimension to track each pair and loaded into the flds array. Since this is clearly a bug which could arise in the future, I think an issue should be created that the fix PR you are making here will lead to failure when more than 1 vector pair for a given mapping type is requested. |
@DeniseWorthen I agree. I'll create the issue in this repository and link it to this PR and #117 . If one of the models using the ocnicepost tool generates history files with more than 1 vector pair for a mapping type, that can be used to create a fix for this bug. |
|
@KarinaAsmar-NOAA Sounds good. I'm also going to create an issue to add some hardening to the code. For example, it is setup to write out the min/max of the original source grid fields, those fields packed, and those fields mapped. All of those min/max values should be w/in tolerances of each other (the packed field min/maxs should actually be identical to the original field min/max). The code should fail if any of the steps produces non-sensical values. It shouldn't require eyes on the output; since this code is being used as a black box, it should simply fail if a change has been made such that |
|
@DeniseWorthen Please see #174. I was able to reproduce the bug with the ice_sfs.csv list. At this time, we are not using the ocnicepost tool for SFS ice products so this bug is not affecting global-workflow SFS runs. |
|
@DeniseWorthen Would you please confirm whether the fix for the vector pair bug is acceptable? Test results are in /scratch4/NCEPDEV/ovp/Karina.Asmar/vecpairbug. Both ice and ocean vector pairs have non-zero values now. There are no errors now when processing more than one vector pair with the same remapping method. Please see Issue #174 for reference. |
|
@KarinaAsmar-NOAA Thanks. Have you confirmed that both vector pairs (with your current fix) are B4B with the case where you have only one vector pair with the change in #117 reverted? In other words, we know if you revert your changes in #117, the mapping of a single vector pair is correct. If your new fix is indeed correct, I think each of those vector pairs should be B4B with what reversion of #117 gives you. |
What is B4B? |
|
B4B is bit-identical comparison. You can use nccmp for example If they are not identical, you will get identifying information for what is not identical. |
I ran this command and got no warnings: [Karina.Asmar@ufe04 grads]$ nccmp -d -S -q -f -B --Attribute=checksum --warn=format ocean.1p00.nc fix172.ocean.1p00.nc ocean.1p00.nc - bug fix from #174 (works for more than one vector pair) Visual comparisons are included here |
Cleaner comparison: [Karina.Asmar@ufe04 Karina.Asmar]$ nccmp -d -S -q -f -B --Attribute=checksum --warn=format vecpairbug/ocean.1p00.nc ocnpost_v2/ocean.1p00.nc where ocnpost_v2/ocean.1p00.nc is the file with reverted #117 changes and vecpair/ocean.1p00.nc is the most recent file with the bug fix for more than one vector |
|
@KarinaAsmar-NOAA The fix for more than one vector pair with a given mapping type does seem to be working now. I'm going to approve. I still think the code needs hardening, but that is of course a separate issue. |
|
@DavidHuber-NOAA @TravisElless-NOAA Can this PR be merged? |
DavidHuber-NOAA
left a comment
There was a problem hiding this comment.
Changes look good to me, though I do not have the expertise to comment on the science.
Description
This PR fixes a bug found in the ocnicepost tool affecting vector pairs. 2d vectors in the 'Cv' grid were coming out with zero values. The bug has been fixed and results confirmed by EMC. Please see note regarding bug fix.
Resolves #172 and #174
-->
Type of change
Change characteristics
How has this been tested?
-->
Checklist