Skip to content

Soil layer bug#32

Open
mpaiao wants to merge 1 commit into
monanadmin:feature/monan_2.0.0from
mpaiao:mpaiao-pr-nsoil-hotfix
Open

Soil layer bug#32
mpaiao wants to merge 1 commit into
monanadmin:feature/monan_2.0.0from
mpaiao:mpaiao-pr-nsoil-hotfix

Conversation

@mpaiao
Copy link
Copy Markdown

@mpaiao mpaiao commented May 26, 2026

Pull Request Description

This is a rather cryptic bug, that only occurs when the number of soil layers is not the default (4 layers) for Noah-MP, which results in the model not conserving water.

1. Soil layer indexing bug. Noah-MP uses positive indices for soil layers, and negative indices for snowpack layers. In sub-routine lsm_noahmp_toMPAS, the code copies the depths from Noah-MP to a local structure (zsnsoxy) that assumes indices going from 1 to the number of combined snowpack and soil layers. However, the original code had one error in the conversion logic, which coincidentally worked for the specific case in which the number of soil layers is exactly the number of snowpack ayers plus 1. The proposed change is used elsewhere in the code and ensures the conversion always works.

2. Hardcoded number of soil plus snow levels. File Registry_noahmp.xml originally defines dimension nzSnowLevels (total number of soil plus snowpack layers) as 7. This works when using the default number of soil layers, but causes segmentation violations otherwise.

This is a quick hot fix, which will be followed by a subsequent pull request that allows for a more flexible definition of soil levels for Noah and Noah-MP.

Type of Change

  • Bug fix
  • Hot fix
  • New feature
  • Improvement to existing functionality
  • Code refactoring
  • Code optimization
  • Other: ______

Testing and Quality

  • Code was written following MONAN’s DTN-01 (Coding Standard)
  • Compilation and execution tests of the model were executed
  • Test with the debug flag was executed
  • Results are reproducible with the default configuration

Scientific Impact

Bug fix. This will not impact simulations using the default number of layers, but it will allow generalising the solution for soils with more layers.

…o run with more than

four soil layers. The logic in mpas_atmphys_driver_lsm_noahmp.F can be simplified to a
single loop that will always work. Likewise, Registry_noahmp.xml does not need to have the
combined number of soil plus snow levels (nzSoilLevels) hardcoded, it can be written as the
sum of the levels so it always works.
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.

1 participant