C-VSM: Final layer not added to DEPTH
As noted in post #43050, the subroutine CVSP_INIT_GAIA has a bug where in building up the DEPTH variable with the thickness of each layer, the last layer is skipped. In the BUILDING SECTIONS section, Lines 101-102 read:
DO M=1,NLAYER%I(J) - 1
DEPTH = DEPTH + ES(J,M)
This has the unfortunate effect of skipping the final layer in adding up DEPTH. Thus, in the FINAL CHECKS section, when BOTTOM – NOEROD is checked against DEPTH, there is a discrepancy corresponding to the final layer thickness.
My solution is to add a line after Line 113 (end of the loop):
DEPTH = DEPTH + ES(J,NLAYER%I(J))
This makes sure the final layer is accounted for, without disturbing any of the logic in the DO loop above it. However, I don't know if this subtly breaks something somewhere else.