NCAR / DART

Data Assimilation Research Testbed
https://dart.ucar.edu/
Apache License 2.0
187 stars 140 forks source link

bug: when localizing in height, the mpas_atm model_mod may compute an incorrect vertical location #524

Open nancycollins opened 1 year ago

nancycollins commented 1 year ago

Describe the bug

In reviewing the mpas_atm model_mod code, the subroutine find_vert_indices() calls find_vert_level() which calls find_height_bounds(). find_height_bounds uses either the zGridCenter array or the zGridEdge for vertical locations. it returns the lower and upper model level numbers that enclose that vertical location, along with the fraction of the level.

in convert_vert_distrib() if the requested outgoing vertical is VERTISHEIGHT, after computing the level numbers based on cell centers, it indexes into the zGridFace array for the heights instead of zGridCenter or zGridEdge.

this seems wrong and needs to be tested - possibly with a version of model_mod_check which includes a call to convert_vert.

note that if W interpolation is added, this code will need to distinguish between cell centered data in the vertical and data on the cell faces, where the existing code might be correct for the new case.

To reproduce/test the bug

set the namelist so it will localize in the vertical on height. test a location of a variable located on the cell center (T, Q) in the vertical on a known level (VERTISLEVEL) look at the location after vertical conversion. the height should match the height of the cell center, not the cell face.

Error Message

This will not provoke any error messages, but would increase the distances used in localization by half a vertical cell.

Which model(s) are you working with?

mpas_atm

Version of DART

This code is in the main branch

Have you modified the DART code?

there is a modified version that includes other changes which is not in the dart repo.

Build information

This was discovered by inspecting the code. The tests can be run anyplace but based on the size of the mpas test cases, it probably needs to be run on cheyenne.

hkershaw-brown commented 1 year ago

@nancycollins are these the lines with the bug?

https://github.com/NCAR/DART/blob/f996f261152d9f3fd395683dd7e51a5e183378f4/models/mpas_atm/model_mod.f90#L4689-L4690

If not can you give a link to the lines: Screen Shot 2023-08-02 at 4 52 58 PM

nancycollins commented 1 year ago

yep, those are them.

nancycollins commented 1 year ago

i'm sorry i didn't make this clear in the bug report. i am intending to do the test once cheyenne comes back up (all the test case code is there).