ESCOMP / ESCOMP/CAM

CLUBB rain-evaporation turbulence enhancement reads a stale level index (k_cam) in clubb_intr.F90

Open
#1,587 5 comments 0 reactions 1 assignee Claimed by @jtruesdal View on GitHub
Must have CESM3
Dominant language
No language data
Stars
91
Forks
183
Avg merge
6d 2m
Merged PRs (30d)
9

Description

## Summary

In `clubb_intr.F90`, the loop that feeds CLUBB's rain-evaporation turbulence enhancement reads the rain-evaporation rate at a stale level index `k_cam` that is never updated inside the loop.

## Location

`src/physics/cam/clubb_intr.F90:3966-3971`

```fortran
do k = 1, nzt_clubb
do i = 1, ncol
rvm(i,k) = rtm(i,k) - rcm(i,k)
pre(i,k) = prer_evap_pbuf(i,k_cam)
end do
end do
```

## Problem

`k_cam` is never assigned inside this loop, whereas every other CAM↔CLUBB level loop in the routine sets `k_cam = top_lev - 1 + k`. It therefore retains its value from the last loop that set it — `pver`, or `pverp` when `do_clubb_mf = .true.` (the latter is an out-of-bounds read of a `(pcols,pver)` pbuf field). Git history shows the pre-refactor code did a proper per-level flip (`pre_in(i,k) = prer_evap(i,pverp-k+1)`), so this is a refactoring regression.

## Impact

With `clubb_rainevap_turb = .true.`, the rain-evaporation enhancement of CLUBB's turbulence moments (`rtp2`, `thlp2`, `wprtp`, `wpthlp`) is driven by the **bottom-level** evaporation rate (or garbage memory) at **every** level — physically wrong turbulence variances throughout the column. Affects prognostic state.

## Suggested fix

```fortran
pre(i,k) = prer_evap_pbuf(i, top_lev - 1 + k)
```

---
_Found via a systematic line-by-line scientific code review of `src/physics/cam/` at commit `21a78294` (≈cam6_4_180), cross-checked against git history and the pre-refactor code. This is a candidate bug identified by code inspection; it has not yet been confirmed by a model run. An issue-tracker search on 2026-06-11 found no existing report._

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.