Skip to content

Commit

Permalink
Fix an error with O31D exceeding vertical dimension kte (#1803)
Browse files Browse the repository at this point in the history
TYPE: bug fix

KEYWORDS: O3 output, o3input=0, RRTMG-LW

SOURCE: Reported by Samm Elliott, fixed internally

DESCRIPTION OF CHANGES:
Problem:
In 4.4, we introduced ozone output o3rad when o3input = 0, that is to use ozone profile provided by the RRTMG code. But the use of output array accessed memory with the vertical dimension > kte. This can cause segmentation fault on some systems.

Solution:
The array is now limited to use only when vertical dimension is less than kte.

LIST OF MODIFIED FILES: 
M     phys/module_ra_rrtmg_lw.F

TESTS CONDUCTED: 
1. Yes
2. Are the Jenkins tests all passing?

RELEASE NOTE: Fixed a memory access error when filling output array o3rad for o3input = 0. No impact on results, but the error could potentially cause the model to abort.
  • Loading branch information
weiwangncar authored Jan 26, 2023
1 parent 0b7ea4c commit 32f8afc
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions phys/module_ra_rrtmg_lw.F
Original file line number Diff line number Diff line change
Expand Up @@ -11647,10 +11647,9 @@ SUBROUTINE RRTMG_LWRAD( &
INTENT(IN ) :: XLAND, &
XICE, &
SNOW
!ccc Added for time-varying trace gases.
! Added for time-varying trace gases.
INTEGER, INTENT(IN ) :: yr
REAL, INTENT(IN ) :: julian
!ccc

!
! Optional
Expand Down Expand Up @@ -11962,7 +11961,7 @@ SUBROUTINE RRTMG_LWRAD( &
! Pressures are in mb
!

!ccc Read time-varying trace gases concentrations and interpolate them to run date.
! Read time-varying trace gases concentrations and interpolate them to run date.
!
IF ( GHG_INPUT .EQ. 1 ) THEN
CALL read_CAMgases(yr,julian,.false.,"RRTMG",co2,n2o,ch4,cfc11,cfc12)
Expand All @@ -11983,8 +11982,6 @@ SUBROUTINE RRTMG_LWRAD( &
cfc12 = 0.538e-9
END IF

!ccc

! latitude loop
j_loop: do j = jts,jte

Expand Down Expand Up @@ -12414,7 +12411,7 @@ SUBROUTINE RRTMG_LWRAD( &
else
do k = kts, nlayers
o3vmr(ncol,k) = o3mmr(k) * amdo
o31d(k) = o3vmr(ncol,k)
if (k.le.kte) o31d(k) = o3vmr(ncol,k)
enddo
endif

Expand Down

0 comments on commit 32f8afc

Please sign in to comment.