Closed SamuelTrahanNOAA closed 8 months ago
Describe the bug
You will find this around line 790 or so in module_diag_hailcast.F90:
DO k=1,nz ... more stuff ... IF ((cwitot .ge. 1.E-12) .and. (k .lt. KBAS)) THEN KBAS = k ENDIF ENDDO
It can set KBAS=1 when the loop reaches k=1.
KBAS=1
k=1
Later:
ELSE IF ((k.ge.KBAS+1).AND.(RWA_adiabat(k).ge.1.E-12)) THEN RWA_new(k) = RWA_adiabat(k)*(h1d(k)-h1d(k-1)) - RWA_new(k-1) IF (RWA_new(k).LT.0) RWA_new(k) = 0. ENDIF ... DO k=KBAS,nz RWA_new(k) = RWA_new(k) / (h1d(k)-h1d(k-1)) ENDDO
If KBAS=1, then the first step of this loop will access h1d(k-1)
To Reproduce See https://github.com/ufs-community/ufs-weather-model/issues/2065 for a test case.
Expected behavior Don't read out-of-bounds
System Environment WCOSS2 Dogwood.
Additional context Test case fails on WCOSS2 dogwood but passes on Hera.
The changes look good to me.
Describe the bug
You will find this around line 790 or so in module_diag_hailcast.F90:
It can set
KBAS=1
when the loop reachesk=1
.Later:
If KBAS=1, then the first step of this loop will access h1d(k-1)
To Reproduce See https://github.com/ufs-community/ufs-weather-model/issues/2065 for a test case.
Expected behavior Don't read out-of-bounds
System Environment WCOSS2 Dogwood.
Additional context Test case fails on WCOSS2 dogwood but passes on Hera.