-
Notifications
You must be signed in to change notification settings - Fork 79
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
Merge of megan namelist item from CAM and CTSM is failing even though there are only whitespace differences #509
Comments
@jedwards4b @billsacks this is a potential fix that does get it to work. But, I'm not sure it's the right thing to do. It simply removes the space character from the comparison. diff --git a/cime_config/buildnml b/cime_config/buildnml
index 44116d98..91cb4f41 100755
--- a/cime_config/buildnml
+++ b/cime_config/buildnml
@@ -605,7 +605,7 @@ def compare_drv_flds_in(first, second, infile1, infile2):
###############################################################################
sharedKeys = set(first.keys()).intersection(second.keys())
for key in sharedKeys:
- if first[key] != second[key]:
+ if first[key].replace(" ", "") != second[key].replace(" ", ""):
print(
"Key: {}, \n Value 1: {}, \n Value 2: {}".format(
key, first[key], second[key] The big caveat to this is that it also modifies the internal content of the strings. |
I'm not very familiar with the details of this, but the diff you give looks reasonable to me. |
@ekluzek I'm not sure I like this - whitespace should already be removed in buildnml lines 534 and 535:
Why is it needed again? |
I see it's needed because in this case the extra space is in the middle of the string. I think that your fix is fine. |
Please submit a PR with the change. |
As discussed with @ekluzek - One step more robust might be to limit the replacement to spaces after a comma; something like this: first_key = re.sub(r', +', ',', first[key])
second_key = re.sub(r', +', ',', second[key])
if first_key != second_key: But as @ekluzek and I discussed, it's going to be very hard to get things totally robust in this check, and it probably isn't worth the time to do that (at least right now), and so we should get something decent and add a comment about its deficiencies. |
To comment on why my proposed fix is an incomplete hack is that it will fail for different scenarios.
In "1" it could fail to recognize that the merge is identical, and will abort needlessly. In "2" it could allow an important difference between the two. However, right now the only character arrays for drv_flds_in are ones where that isn't a problem. It doesn't show up for non-arrays, nor for non-string arrays. Riffing off of Jim's example the strip statement on 535 could be changed to the substitute I have above. Although I think it might need something outside of the if statement as well. |
I have a case that's failing in the merge of the CAM and CTSM namelist for drv_flds_in in preview_namaelists even though the difference is only in whitespace. It's comparing a character array of strings. It's not recognizing that whitespace differences in the list of strings is valid in FORTRAN. This is in cmeps1_0_20 the latest version right now...
Here is the error I'm getting:
How to replicate this case:
The text was updated successfully, but these errors were encountered: