Skip to content

Comments

Unit Conversion Error (NGWPC-7604)#40

Closed
mkarim-rtx wants to merge 3 commits intodevelopmentfrom
Unit_Conversion_Mohammed
Closed

Unit Conversion Error (NGWPC-7604)#40
mkarim-rtx wants to merge 3 commits intodevelopmentfrom
Unit_Conversion_Mohammed

Conversation

@mkarim-rtx
Copy link

@mkarim-rtx mkarim-rtx commented Sep 17, 2025

The UDUNITS package can’t parse "none", which caused warnings like “Unable to parse out_units value none.” Normalizing to "1" matches ngen's convention and avoids spurious conversion errors. This ensures variables defined with “no-units” in realization metadata are recorded as dimensionless from the start, preventing downstream unit-conversion attempts and warnings.

Changes

src/realizations/catchment/Bmi_Module_Formulation.cpp: Normalize “no-units” to dimensionless.
Before requesting data from a provider, Bmi_Module_Formulation::set_model_inputs_prior_to_update now canonicalizes consumer units: any of "", "none", "unitless", "dimensionless", or "-" → "1". This prevents UDUNITS from trying to parse "none" and eliminates mm → 1-type failures.

include/realizations/catchment/Bmi_Multi_Formulation.hpp: Don’t ask providers to convert to “1”.
When the consumer’s units are dimensionless ("1"), the selector passes empty units "" to the provider. This signals “give me native units” and avoids impossible conversions (e.g., m → 1) inside the provider.

Richer, de-duplicated diagnostics.
On conversion failure, the code now throws/propagates a unit_conversion_exception that includes the producer model name, producer BMI var, and producer units. The consumer catches it, logs a single warning per unique producer/consumer/variable pair (using data_access::unit_errors_reported), and falls back to using the unconverted value(s) instead of aborting.

Testing

  1. Not seeing conversion error anymore

@mkarim-rtx mkarim-rtx marked this pull request as draft September 17, 2025 20:23
@yuqiong77
Copy link

Nothing jumps out but my limited c/c++ knowledge does not allow me to fully understand the code changes in this PR so will defer to other reviewers

…in UnitsHelper; have multi pass "" (not "1") for outputs; switch to shared unit-error dedupe; and soft-fail nested-provider paths—eliminating UDUNITS (“mm→1”) and recursion crashes.
@cmaynard-ngwpc cmaynard-ngwpc force-pushed the Unit_Conversion_Mohammed branch from 4bf3cae to 18d4867 Compare September 23, 2025 00:40
@cmaynard-ngwpc
Copy link

@mkarim-rtx
Please update the Description section by moving parts to their appropriate sections, make sure you describe any additions, removals or changes. Remove any sections not being used.

@cmaynard-ngwpc cmaynard-ngwpc changed the title NGWPC-7604: NGEN Unit Conversion Error Unit Conversion Error (NGWPC-7604) Sep 26, 2025
@cmaynard-ngwpc cmaynard-ngwpc changed the base branch from release-candidate to development September 26, 2025 13:25
@cmaynard-ngwpc
Copy link

This has been merged into development in PR 52. This PR is no longer necessary.

@cmaynard-ngwpc cmaynard-ngwpc deleted the Unit_Conversion_Mohammed branch February 13, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants