Skip to content

Commit

Permalink
Merge pull request #395 from mpaiao/mpaiao-pr-thvavg
Browse files Browse the repository at this point in the history
Revised calculation of canopy air space pressure
  • Loading branch information
mpaiao committed Jul 24, 2024
2 parents caf4a9e + 29e1879 commit 5130f4f
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 19 deletions.
20 changes: 18 additions & 2 deletions BRAMS/src/lib/therm_lib.f90
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ module therm_lib
!=======================================================================================!




!=======================================================================================!
!=======================================================================================!
! Weighting factor for atmospheric ThetaV (as opposed to canopy air space ThetaV). !
!---------------------------------------------------------------------------------------!
real(kind=4), parameter :: fthva_rp = 0.5
!=======================================================================================!
!=======================================================================================!


contains


Expand Down Expand Up @@ -2501,14 +2512,19 @@ real(kind=4) function reducedpress(pres,thetaref,shvref,zref,thetacan,shvcan,zca
real(kind=4), intent(in) :: zcan ! Height at canopy level [ m]
!------Local variables. -------------------------------------------------------------!
real(kind=4) :: pinc ! Pressure increment [ Pa^R/cp]
real(kind=4) :: thvref ! Reference virtual pot. temperature [ K]
real(kind=4) :: thvcan ! CAS virtual pot. temperature [ K]
real(kind=4) :: thvbar ! Average virtual pot. temperature [ K]
!------------------------------------------------------------------------------------!

!------------------------------------------------------------------------------------!
! First we compute the average virtual potential temperature between the canopy !
! top and the reference level. !
! top and the reference level. Because of the equation below, we average the !
! inverse of the potential temperature. !
!------------------------------------------------------------------------------------!
thvbar = 0.5 * (thetaref * (1. + epim1 * shvref) + thetacan * (1. + epim1 * shvcan))
thvref = thetaref * (1.0 + epim1 * shvref)
thvcan = thetacan * (1.0 + epim1 * shvcan)
thvbar = thvref * thvcan / ( ( 1.0 - fthva_rp ) * thvref + fthva_rp * thvcan )
!------------------------------------------------------------------------------------!


Expand Down
28 changes: 23 additions & 5 deletions BRAMS/src/lib/therm_lib8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ module therm_lib8
, maxfpo4 => maxfpo & ! intent(in)
, maxit4 => maxit & ! intent(in)
, maxlev4 => maxlev & ! intent(in)
, newthermo4 => newthermo ! ! intent(in)

, newthermo4 => newthermo & ! intent(in)
, fthva_rp4 => fthva_rp ! ! intent(in)

!---------------------------------------------------------------------------------------!
! Relative tolerance for iterative methods. The smaller the value, the more !
! accurate the result, but it will slow down the run. Notice that we are using the !
Expand Down Expand Up @@ -116,6 +117,17 @@ module therm_lib8
!=======================================================================================!




!=======================================================================================!
!=======================================================================================!
! Weighting factor for atmospheric ThetaV (as opposed to canopy air space ThetaV). !
!---------------------------------------------------------------------------------------!
real(kind=4), parameter :: fthva_rp8 = dble(fthva_rp4)
!=======================================================================================!
!=======================================================================================!


contains


Expand Down Expand Up @@ -2505,15 +2517,21 @@ real(kind=8) function reducedpress8(pres,thetaref,shvref,zref,thetacan,shvcan,zc
real(kind=8), intent(in) :: zcan ! Height at canopy level [ m]
!------Local variables. -------------------------------------------------------------!
real(kind=8) :: pinc ! Pressure increment [ Pa^R/cp]
real(kind=8) :: thvref ! Reference virtual pot. temperature [ K]
real(kind=8) :: thvcan ! CAS virtual pot. temperature [ K]
real(kind=8) :: thvbar ! Average virtual pot. temperature [ K]
!------------------------------------------------------------------------------------!



!------------------------------------------------------------------------------------!
! First we compute the average virtual potential temperature between the canopy !
! top and the reference level. !
! top and the reference level. Because of the equation below, we average the !
! inverse of the potential temperature. !
!------------------------------------------------------------------------------------!
thvbar = 5.d-1 * ( thetaref * (1.d0 + epim18 * shvref) &
+ thetacan * (1.d0 + epim18 * shvcan) )
thvref = thetaref * (1.d0 + epim18 * shvref)
thvcan = thetacan * (1.d0 + epim18 * shvcan)
thvbar = thvref * thvcan / ( ( 1.d0 - fthva_rp8 ) * thvref + fthva_rp8 * thvcan )
!------------------------------------------------------------------------------------!


Expand Down
28 changes: 22 additions & 6 deletions ED/src/utils/therm_lib.f90
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ module therm_lib
!=======================================================================================!




!=======================================================================================!
!=======================================================================================!
! Weighting factor for atmospheric ThetaV (as opposed to canopy air space ThetaV). !
!---------------------------------------------------------------------------------------!
real(kind=4), parameter :: fthva_rp = 0.5
!=======================================================================================!
!=======================================================================================!


contains


Expand Down Expand Up @@ -2497,22 +2508,27 @@ real(kind=4) function reducedpress(pres,thetaref,shvref,zref,thetacan,shvcan,zca
implicit none
!----- Arguments --------------------------------------------------------------------!
real(kind=4), intent(in) :: pres ! Pressure [ Pa]
real(kind=4), intent(in) :: thetaref ! Potential temperature [ K]
real(kind=4), intent(in) :: shvref ! Vapour specific mass [ kg/kg]
real(kind=4), intent(in) :: thetaref ! Ref. Potential temperature [ K]
real(kind=4), intent(in) :: shvref ! Ref. Vapour specific mass [ kg/kg]
real(kind=4), intent(in) :: zref ! Height at reference level [ m]
real(kind=4), intent(in) :: thetacan ! Potential temperature [ K]
real(kind=4), intent(in) :: shvcan ! Vapour specific mass [ kg/kg]
real(kind=4), intent(in) :: thetacan ! CAS Potential temperature [ K]
real(kind=4), intent(in) :: shvcan ! CAS Vapour specific mass [ kg/kg]
real(kind=4), intent(in) :: zcan ! Height at canopy level [ m]
!------Local variables. -------------------------------------------------------------!
real(kind=4) :: pinc ! Pressure increment [ Pa^R/cp]
real(kind=4) :: thvref ! Reference virtual pot. temperature [ K]
real(kind=4) :: thvcan ! CAS virtual pot. temperature [ K]
real(kind=4) :: thvbar ! Average virtual pot. temperature [ K]
!------------------------------------------------------------------------------------!

!------------------------------------------------------------------------------------!
! First we compute the average virtual potential temperature between the canopy !
! top and the reference level. !
! top and the reference level. Because of the equation below, we average the !
! inverse of the potential temperature. !
!------------------------------------------------------------------------------------!
thvbar = 0.5 * (thetaref * (1. + epim1 * shvref) + thetacan * (1. + epim1 * shvcan))
thvref = thetaref * (1.0 + epim1 * shvref)
thvcan = thetacan * (1.0 + epim1 * shvcan)
thvbar = thvref * thvcan / ( ( 1.0 - fthva_rp ) * thvref + fthva_rp * thvcan )
!------------------------------------------------------------------------------------!


Expand Down
29 changes: 23 additions & 6 deletions ED/src/utils/therm_lib8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ module therm_lib8
, level4 => level & ! intent(in)
, vapour_on4 => vapour_on & ! intent(in)
, cloud_on4 => cloud_on & ! intent(in)
, bulk_on4 => bulk_on ! ! intent(in)
, bulk_on4 => bulk_on & ! intent(in)
, fthva_rp4 => fthva_rp ! ! intent(in)

!---------------------------------------------------------------------------------------!
! Relative tolerance for iterative methods. The smaller the value, the more !
Expand Down Expand Up @@ -126,6 +127,17 @@ module therm_lib8
!=======================================================================================!




!=======================================================================================!
!=======================================================================================!
! Weighting factor for atmospheric ThetaV (as opposed to canopy air space ThetaV). !
!---------------------------------------------------------------------------------------!
real(kind=4), parameter :: fthva_rp8 = dble(fthva_rp4)
!=======================================================================================!
!=======================================================================================!


contains


Expand Down Expand Up @@ -2510,20 +2522,25 @@ real(kind=8) function reducedpress8(pres,thetaref,shvref,zref,thetacan,shvcan,zc
real(kind=8), intent(in) :: thetaref ! Potential temperature [ K]
real(kind=8), intent(in) :: shvref ! Vapour specific mass [ kg/kg]
real(kind=8), intent(in) :: zref ! Height at reference level [ m]
real(kind=8), intent(in) :: thetacan ! Potential temperature [ K]
real(kind=8), intent(in) :: shvcan ! Vapour specific mass [ kg/kg]
real(kind=8), intent(in) :: thetacan ! CAS Potential temperature [ K]
real(kind=8), intent(in) :: shvcan ! CAS Vapour specific mass [ kg/kg]
real(kind=8), intent(in) :: zcan ! Height at canopy level [ m]
!------Local variables. -------------------------------------------------------------!
real(kind=8) :: pinc ! Pressure increment [ Pa^R/cp]
real(kind=8) :: thvref ! Reference virtual pot. temperature [ K]
real(kind=8) :: thvcan ! CAS virtual pot. temperature [ K]
real(kind=8) :: thvbar ! Average virtual pot. temperature [ K]
!------------------------------------------------------------------------------------!


!------------------------------------------------------------------------------------!
! First we compute the average virtual potential temperature between the canopy !
! top and the reference level. !
! top and the reference level. Because of the equation below, we average the !
! inverse of the potential temperature. !
!------------------------------------------------------------------------------------!
thvbar = 5.d-1 * ( thetaref * (1.d0 + epim18 * shvref) &
+ thetacan * (1.d0 + epim18 * shvcan) )
thvref = thetaref * (1.d0 + epim18 * shvref)
thvcan = thetacan * (1.d0 + epim18 * shvcan)
thvbar = thvref * thvcan / ( ( 1.d0 - fthva_rp8 ) * thvref + fthva_rp8 * thvcan )
!------------------------------------------------------------------------------------!


Expand Down

0 comments on commit 5130f4f

Please sign in to comment.