ESCOMP / ESCOMP/CAM

COSP/RTTOV inputs copied over 1:pver instead of reduced domain ktop:pver in cospsimulator_intr.F90

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

Description

## Summary

Several COSP/RTTOV input fields in `cospsimulator_intr.F90` are copied over the full column `1:pver` instead of the reduced COSP domain `ktop:pver` used by their neighbors, producing vertically shifted profiles (or out-of-bounds access) in high-top configurations.

## Location

`src/physics/cam/cospsimulator_intr.F90:2327-2378`

```fortran
cospstateIN%at = state%t(:ncol,ktop:pver) ! correct pattern
cospstateIN%tca = cld(1:ncol,1:pver) ! wrong: full column
cospstateIN%co2 = co2(1:ncol,1:pver) ! wrong
...
cospstateIN%DeffIce(1:ncol,1:pver) = dei(1:ncol,1:pver) ! out-of-bounds write
```

## Problem

COSP runs on `nlay = pver - ktop + 1` levels and most fields are correctly subset `ktop:pver`. But the fields added in the RTTOV / COSP-2.2.1 integration (`tca`, `co2`, `ch4`, `n2o`, `cloudIce`, `cloudLiq`, `DeffLiq`, `DeffIce`) use `1:pver`. When `ktop > 1` (any high-top configuration, e.g. WACCM):

- Whole-array assignments silently **reallocate** the derived-type components to the wrong size, so profiles are vertically shifted by `ktop−1` layers relative to the correctly-subset T/q/p.
- The `Deff*` lines are non-conforming / out-of-bounds reads and writes.

## Impact

All RTTOV radiances and `tca`-dependent COSP diagnostics are misaligned (or memory is corrupted) in high-top runs. **No effect in default low-top CAM where `ktop = 1`.** Diagnostics only.

## Suggested fix

Subset all of these fields `ktop:pver` to match their neighbors.

---
_Found via a systematic line-by-line scientific code review of `src/physics/cam/` at commit `21a78294` (≈cam6_4_180). 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.