ESCOMP / ESCOMP/CTSM

Incorrect (or confusing?) indexing in "if ( any(fert_cft(begg:endg,cft_ub+1:)" in surfrdUtilsMod.F90

Open
#3,032 6 comments 0 reactions 1 assignee Claimed by @slevis-lmwg View on GitHub
code health priority: low
Dominant language
Fortran
Stars
352
Forks
361
Avg merge
6d 6h
Merged PRs (30d)
8

Description

### Brief summary of bug

@swensosc brought to my attention the following incorrect use of cft_ub in surfrdUtilsMod.F90
```
if ( any(wt_cft(begg:endg,cft_ub+1:)
...
if ( any(fert_cft(begg:endg,cft_ub+1:)
```
These variables are dimensioned and later asserted as
```
real(r8), intent(inout) :: wt_cft(begg:, cft_lb:)
real(r8), intent(inout) :: fert_cft(begg:, cft_lb:)
...
SHR_ASSERT_ALL_FL((ubound(wt_cft) == (/endg, cft_lb+cftsize-1/)), sourcefile, __LINE__)
SHR_ASSERT_ALL_FL((ubound(fert_cft) == (/endg, cft_lb+cftsize-1/)), sourcefile, __LINE__)
```
so in the if statements we likely need to replace `cft_ub+1` with `npcropmin`, though testing will tell us more.

### General bug information

**CTSM version you are using:** ctsm5.3 but this goes back to ctsm5.1

**Does this bug cause significantly incorrect results in the model's science?**
This bug makes the above if statements useless and their error checks null. This means that users could have been running with .not. use_crop and non-zero prognostic crop amounts inadvertently.

**Configurations affected:** .not. use_crop

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.