diff --git a/sorc/ncep_post.fd/MDL2SIGMA.f b/sorc/ncep_post.fd/MDL2SIGMA.f index e2fd97a36..6dcb2654e 100644 --- a/sorc/ncep_post.fd/MDL2SIGMA.f +++ b/sorc/ncep_post.fd/MDL2SIGMA.f @@ -21,6 +21,7 @@ !! 20-03-25 J MENG - remove grib1 !! 21-03-11 B Cui - change local arrays to dimension (im,jsta:jend) !! 21-10-14 J MENG - 2D DECOMPOSITION +!! 2022-09-01 S Trahan - fixed bugs where extreme atmospheric conditions can cause out-of-bounds access !! !! USAGE: CALL MDL2P !! INPUT ARGUMENT LIST: @@ -277,8 +278,9 @@ SUBROUTINE MDL2SIGMA AHF =D00 FAC =D00 DONEFSL1=.TRUE. - ELSEIF(T(I,J,NL1XF(I,J))0) THEN @@ -2118,7 +2118,7 @@ SUBROUTINE MISCLN ENDIF ! ! END OF ETA BOUNDARY LAYER LOOP. - 20 CONTINUE + END DO boundary_layer_loop deallocate(OMGBND,PWTBND,QCNVBND) ! ! BEST LIFTED INDEX FROM BOUNDARY LAYER FIELDS. @@ -2208,7 +2208,7 @@ SUBROUTINE MISCLN ENDDO ENDDO ! - DO 80 LBND = 1,NBND + loop_80: DO LBND = 1,NBND CALL CALTHTE(PBND(ista,jsta,LBND),TBND(ista,jsta,LBND), & QBND(ista,jsta,LBND),EGRID1) !$omp parallel do private(i,j) @@ -2223,7 +2223,7 @@ SUBROUTINE MISCLN ENDIF ENDDO ENDDO - 80 CONTINUE + ENDDO loop_80 ! DPBND = 0. CALL CALCAPE(ITYPE,DPBND,P1D,T1D,Q1D,LB2,EGRID1, & diff --git a/sorc/ncep_post.fd/UPP_PHYSICS.f b/sorc/ncep_post.fd/UPP_PHYSICS.f index cc6bd7c5e..cb059ba1f 100644 --- a/sorc/ncep_post.fd/UPP_PHYSICS.f +++ b/sorc/ncep_post.fd/UPP_PHYSICS.f @@ -999,6 +999,7 @@ END SUBROUTINE CALCAPE !> 2021-09-03 | J Meng | Modified to add 0-3km CAPE/CINS, LFC, effective helicity, downdraft CAPE, dendritic growth layer depth, ESP !> 2021-09-01 | E Colon | Equivalent level height index for RTMA !> 2022-08-27 | S Trahan | Fixed bug in CALCAPE2 where extreme atmospheric conditions cause an out-of-bounds access +!> 2022-09-01 | S Trahan | Fixed another bug in CALCAPE2 where extreme atmospheric conditions cause an out-of-bounds access !> !> @author Russ Treadon W/NP2 @date 1993-02-10 SUBROUTINE CALCAPE2(ITYPE,DPBND,P1D,T1D,Q1D,L1D, & @@ -1320,6 +1321,9 @@ SUBROUTINE CALCAPE2(ITYPE,DPBND,P1D,T1D,Q1D,L1D, & THUNDER(I,J) = .FALSE. ENDIF ENDIF + + ! Limit LCL to prevent out-of-bounds accesses later + LCL(I,J) = max(min(LCL(I,J),LM-1),1) ENDDO ENDDO !-----------------------------------------------------------------------