esmf-org / esmf

The Earth System Modeling Framework (ESMF) is a suite of software tools for developing high-performance, multi-component Earth science modeling applications.
https://earthsystemmodeling.org/
Other
156 stars 75 forks source link

Bug in ESMF_HConfigLayer - misdiagnosis of string as bool (Norway problem) #222

Closed tclune closed 2 months ago

tclune commented 8 months ago

If HConfig is given a quoted string like "no", it is still saying that this string is a boolean as if it was just no. Probably not a major problem in user code, where the intended type is known. But in implementing MAPL_HConfigMatch() it indicates those two hconfigs match and I don't see a good way to disambiguate from outside.

Not urgent, but ... needs to be fixed.

tclune commented 8 months ago

I now realize the problem is likely broader than what I wrote above. Match should return false for the following pairs:

I also realize that my implementation of match has a bit of the opposite problem as it will presumably say that the following do not match: 1 vs +1. So I need to convert each scalar to the right type and then compare values. Comparing strings just handles the usual cases.

theurich commented 4 months ago

Hi Tom (@tclune), I made some progress on this issue. The current status is per branch https://github.com/esmf-org/esmf/tree/feature/hconfig-extras. There is now a discussion about the additional Boolean values and the "Norway problem" under section https://earthsystemmodeling.org/docs/nightly/feature/hconfig-extras/ESMF_refdoc/node6.html#SECTION0601031200000000000000 (see section 48.3.12.8).

A few notes here:

  1. There was indeed an issue in the way that HConfigCreate() from content did not preserve quotes in the string. Actually HConfig was doing everything right (at least the way I see it), but the yaml-cpp backend did not preserve the quotes for this case. This behavior was different from how yaml-cpp treats the same case (quotes around a string) when reading from file. So I "fixed" this inside of the yaml-cpp version we keep internal to ESMF.
  2. While yaml-cpp was ingesting the quotes correctly when reading from a file, when written out, and back in, it was loosing that information. This also affected the new ESMF_HConfigLog() and ESMF_HConfigMatch() methods I implemented. So I fixed this issue, making quoted string treatment consistent regardless of how it was ingested (from file or from a content string). Either way now a quoted string is marked via tag:yaml.org,2002:str.
tclune commented 4 months ago

Excellent. Am looking forward to understanding the approach to the Norway problem given that my understanding is that hconfig keeps everything as strings internally …

From: Gerhard Theurich @.> Date: Monday, May 20, 2024 at 7:20 PM To: esmf-org/esmf @.> Cc: Clune, Thomas L. (GSFC-6101) @.>, Mention @.> Subject: [EXTERNAL] [BULK] Re: [esmf-org/esmf] Bug in ESMF_HConfigLayer - misdiagnosis of string as bool (Norway problem) (Issue #222) CAUTION: This email originated from outside of NASA. Please take care when clicking links or opening attachments. Use the "Report Message" button to report suspicious messages to the NASA SOC.

Hi Tom @.***https://github.com/tclune), I made some progress on this issue. The current status is per branch https://github.com/esmf-org/esmf/tree/feature/hconfig-extras. There is now a discussion about the additional Boolean values and the "Norway problem" under section https://earthsystemmodeling.org/docs/nightly/feature/hconfig-extras/ESMF_refdoc/node6.html#SECTION0601031200000000000000 (see section 48.3.12.8).

A few notes here:

  1. There was indeed an issue in the way that HConfigCreate() from content did not preserve quotes in the string. Actually HConfig was doing everything right (at least the way I see it), but the yaml-cpp backend did not preserve the quotes for this case. This behavior was different from how yaml-cpp treats the same case (quotes around a string) when reading from file. So I "fixed" this inside of the yaml-cpp version we keep internal to ESMF.
  2. While yaml-cpp was ingesting the quotes correctly when reading from a file, when written out, and back in, it was loosing that information. This also affected the new ESMF_HConfigLog() and ESMF_HConfigMatch() methods I implemented. So I fixed this issue, making quoted string treatment consistent regardless of how it was ingested (from file or from a content string). Either way now a quoted string is marked via tag:yaml.org,2002:str.

— Reply to this email directly, view it on GitHubhttps://github.com/esmf-org/esmf/issues/222#issuecomment-2121378068, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPP7YD4STLJOQWNZQTBXJLZDKAMHAVCNFSM6AAAAABCW5ZZXSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRRGM3TQMBWHA. You are receiving this because you were mentioned.Message ID: @.***>

theurich commented 2 months ago

No further user response. All of the recent HConfig code improvements have been merged into the develop branch for the 8.7 release.