Skip to content

Commit

Permalink
Added bounding to temperature at layer-interface used by RRTMGP.
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinswales committed Apr 6, 2022
1 parent 2cf6a38 commit 4407989
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions physics/GFS_rrtmgp_pre.F90
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ subroutine GFS_rrtmgp_pre_run(me, nCol, nLev, nTracers, i_o3, lsswr, lslwr, fhsw
gas_concentrations ! RRTMGP DDT: gas volumne mixing ratios

! Local variables
integer :: i, j, iCol, iBand, iLay
integer :: i, j, iCol, iBand, iLay, iLev, iSFC_ilev
real(kind_phys),dimension(nCol,nLev) :: vmr_o3, vmr_h2o
real(kind_phys) :: es, tem1, tem2, pfac
real(kind_phys), dimension(nLev+1) :: hgtb
Expand All @@ -202,9 +202,11 @@ subroutine GFS_rrtmgp_pre_run(me, nCol, nLev, nTracers, i_o3, lsswr, lslwr, fhsw
if (top_at_1) then
iSFC = nLev
iTOA = 1
iSFC_ilev = iSFC + 1
else
iSFC = 1
iTOA = nLev
iSFC_ilev = 1
endif

! #######################################################################################
Expand Down Expand Up @@ -244,6 +246,12 @@ subroutine GFS_rrtmgp_pre_run(me, nCol, nLev, nTracers, i_o3, lsswr, lslwr, fhsw

! Temperature at layer-interfaces
call cmp_tlev(nCol,nLev,minGPpres,p_lay,t_lay,p_lev,tsfc,t_lev)
do iCol=1,nCol

This comment has been minimized.

Copy link
@ChunxiZhang-NOAA

ChunxiZhang-NOAA Apr 6, 2022

Collaborator

FORTRAN arrays are stored in column-major order. So it should be:
do iLev=1,nlev+1
do iCol=1,nCol
....
end do
end do

This comment has been minimized.

Copy link
@climbfuji

climbfuji Apr 6, 2022

Collaborator

99.99% guarantee that the compiler will swap those do loops automatically.

This comment has been minimized.

Copy link
@dustinswales

dustinswales Apr 6, 2022

Author Collaborator

I agree, but I swapped them anyways

do iLev=1,nLev+1
if (t_lev(iCol,iLev) .le. minGPtemp) t_lev(iCol,iLev) = minGPtemp + epsilon(minGPtemp)
if (t_lev(iCol,iLev) .ge. maxGPtemp) t_lev(iCol,iLev) = maxGPtemp - epsilon(maxGPtemp)
enddo
enddo

! Save surface temperature at radiation time-step, used for LW flux adjustment betwen
! radiation calls.
Expand Down Expand Up @@ -361,7 +369,7 @@ subroutine GFS_rrtmgp_pre_run(me, nCol, nLev, nTracers, i_o3, lsswr, lslwr, fhsw
! #######################################################################################
! Setup surface ground temperature and ground/air skin temperature if required.
! #######################################################################################
tsfg(1:NCOL) = tsfc(1:NCOL)
tsfg(1:NCOL) = t_lev(1:NCOL,iSFC_ilev)
tsfa(1:NCOL) = t_lay(1:NCOL,iSFC)

! #######################################################################################
Expand Down

0 comments on commit 4407989

Please sign in to comment.