Incorrect (or confusing?) indexing in "if ( any(fert_cft(begg:endg,cft_ub+1:)" in surfrdUtilsMod.F90
- 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
Assessment
This issue has not been assessed yet.