Closed brhillman closed 2 years ago
@brhillman thanks for reporting this, I think this is indeed a bug. I haven't had the time to look into this properly, but I think that level 1 of hgt_matrix_half is actually not needed. If that's the case, then we could dimension hgt_matrix_half with nlevels, dropping the TOA. If that's not the case (level 1 is indeed needed somewhere), then the slice in the calls to cosp_change_vertical_grid needs to be changed.
The array
cospstateIN%hgt_matrix_half
appears to be used inconsistently in the interface code and in calls to simulators andcosp_change_vertical_grid
. This array is allocated to have size(npoints,nlevels+1)
, which would imply that it should hold the heights of model level interfaces, but is used like this in calls tocosp_change_vertical_grid
:cosp_change_vertical_grid
expectszlev_half
to have shape(npoints,nlevels)
, and to hold the heights of the bottom of each level. But, if a model were to populatehgt_matrix_half
with the full interface levels (from levels 1 tonlevels+1
, from TOA to surface), then the slicingnlevels:1:-1
would be taking the firstnlevels
heights, which would be the heights of the interface tops, not bottoms. In E3SM, we appear to implement the hacky fix to populate levels(1,nlevels)
ofcospstateIN%hgt_matrix_half
with the heights of the level bottoms, and then populate levelnlevels+1
ofhgt_matrix_half
with a dummy value of 0. Is this expected behavior?