Skip to content

Commit

Permalink
Merge PR #392 (Fix bug in advection when using raw GMAO met files)
Browse files Browse the repository at this point in the history
This merge brings PR #392 (Fix bug in advection when using raw GMAO
meteorology files, by @lizziel) into the GCHP "no-diff-to-benchmark"
development stream.

This PR flips makes sure to index the specific humidity met field (SPHU)
from the top-down when computing the pressure at level edges, if
using GMAO raw meteorology inputs.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Mar 14, 2024
2 parents 8a63e4c + 23444e1 commit 9100a1d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added
- Now print container name being read by ExtData when `CAP.EXTDATA` is set to `DEBUG` in `logging.yml`

### Fixed
- Fixed bug where SPHU used to construct PLE for advection was vertically inverted if using raw GMAO meteorology files

## [14.3.0] - 2024-02-07
### Added
- Added capability for TOMAS simulations in GCHP
Expand Down
84 changes: 63 additions & 21 deletions src/GCHP_GridComp/GCHPctmEnv_GridComp/GCHPctmEnv_GridCompMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,21 @@ subroutine prepare_ple_exports(IMPORT, EXPORT, PLE, RC)
! Also compute dry pressures if using dry pressure in advection
if ( use_total_air_pressure_in_advection < 1 ) then

call calculate_ple(PS1_IMPORT, DryPLE0_EXPORT, SPHU1_IMPORT )
call calculate_ple( &
PS=PS1_IMPORT, &
PLE=DryPLE0_EXPORT, &
SPHU=SPHU1_IMPORT, &
topDownMet=meteorology_vertical_index_is_top_down )

DryPLE0_EXPORT = 100.0d0 * DryPLE0_EXPORT
DryPLE0_EXPORT = DryPLE0_EXPORT(:,:,LM:0:-1)

call calculate_ple(PS2_IMPORT, DryPLE1_EXPORT, SPHU2_IMPORT )
call calculate_ple( &
PS=PS2_IMPORT, &
PLE=DryPLE1_EXPORT, &
SPHU=SPHU2_IMPORT, &
topDownMet=meteorology_vertical_index_is_top_down )

DryPLE1_EXPORT = 100.0d0 * DryPLE1_EXPORT
DryPLE1_EXPORT = DryPLE1_EXPORT(:,:,LM:0:-1)

Expand Down Expand Up @@ -973,12 +983,13 @@ end subroutine prepare_massflux_exports
!
! !INTERFACE:
!
subroutine calculate_ple(PS, PLE, SPHU)
subroutine calculate_ple(PS, PLE, SPHU, topDownMet )
!
! !INPUT PARAMETERS:
!
real(r4), intent(in) :: PS(:,:) ! Surface pressure [hPa]
real(r4), intent(in), OPTIONAL :: SPHU(:,:,:) ! Specific humidity [kg/kg]
logical, intent(in), OPTIONAL :: topDownMet ! True if meteorology level 1 is TOA
!
! !INPUT PARAMETERS:
!
Expand Down Expand Up @@ -1070,26 +1081,57 @@ subroutine calculate_ple(PS, PLE, SPHU)
js = lbound(PS,2)
je = ubound(PS,2)
LM = size (SPHU,3)
do J=js,je
do I=is,ie

! Start with TOA pressure
PSDry = AP(LM+1)

! Stack up dry delta-P to get surface dry pressure
do L=1,LM
PEdge_Bot = AP(L ) + ( BP(L ) * dble(PS(I,J)) )
PEdge_Top = AP(L+1) + ( BP(L+1) * dble(PS(I,J)) )
PSDry = PSDry &
+ ( ( PEdge_Bot - Pedge_Top ) * ( 1.d0 - SPHU(I,J,L) ) )
enddo

! Work back up from the surface to get dry level edges
do L=1,LM+1
PLE(I,J,L) = AP(L) + ( BP(L) * dble(PSDry) )
if ( topDownMet ) then

do J=js,je
do I=is,ie

! Start with TOA pressure
PSDry = AP(LM+1)

! Stack up dry delta-P to get surface dry pressure
! Vertically flip humidity if using top-down meteorology (raw GMAO files)
do L=1,LM
PEdge_Bot = AP(L ) + ( BP(L ) * dble(PS(I,J)) )
PEdge_Top = AP(L+1) + ( BP(L+1) * dble(PS(I,J)) )
PSDry = PSDry &
+ ( ( PEdge_Bot - Pedge_Top ) * ( 1.d0 - SPHU(I,J,LM-L+1) ) )
enddo

! Work back up from the surface to get dry level edges
do L=1,LM+1
PLE(I,J,L) = AP(L) + ( BP(L) * dble(PSDry) )
enddo

enddo
enddo

else

do J=js,je
do I=is,ie

! Start with TOA pressure
PSDry = AP(LM+1)

! Stack up dry delta-P to get surface dry pressure
do L=1,LM
PEdge_Bot = AP(L ) + ( BP(L ) * dble(PS(I,J)) )
PEdge_Top = AP(L+1) + ( BP(L+1) * dble(PS(I,J)) )
PSDry = PSDry &
+ ( ( PEdge_Bot - Pedge_Top ) * ( 1.d0 - SPHU(I,J,L) ) )
enddo

! Work back up from the surface to get dry level edges
do L=1,LM+1
PLE(I,J,L) = AP(L) + ( BP(L) * dble(PSDry) )
enddo
enddo
enddo
enddo
enddo

endif

endif


Expand Down

0 comments on commit 9100a1d

Please sign in to comment.