Skip to content

Commit

Permalink
Do not subtract dynbal baselines from begwb and endwb
Browse files Browse the repository at this point in the history
Ideally, we would keep begwb and endwb consistent with liq1, liq2, ice1
and ice2 in this respect - i.e., subtracting the dynbal baselines in all
cases. However, this changes answers for methane in a way we want to
avoid right now.

See ESCOMP#659 for details.
  • Loading branch information
billsacks committed Mar 12, 2019
1 parent 1775f28 commit 44e254d
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 26 deletions.
8 changes: 6 additions & 2 deletions src/biogeophys/BalanceCheckMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,14 @@ subroutine BeginWaterBalance(bounds, &
end do

call ComputeWaterMassNonLake(bounds, num_nolakec, filter_nolakec, &
soilhydrology_inst, waterstate_inst, begwb(bounds%begc:bounds%endc))
soilhydrology_inst, waterstate_inst, &
subtract_dynbal_baselines = .false., &
water_mass = begwb(bounds%begc:bounds%endc))

call ComputeWaterMassLake(bounds, num_lakec, filter_lakec, &
waterstate_inst, begwb(bounds%begc:bounds%endc))
waterstate_inst, &
subtract_dynbal_baselines = .false., &
water_mass = begwb(bounds%begc:bounds%endc))

end associate

Expand Down
6 changes: 3 additions & 3 deletions src/biogeophys/HydrologyDrainageMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ subroutine HydrologyDrainage(bounds, &
end do

call ComputeWaterMassNonLake(bounds, num_nolakec, filter_nolakec, &
soilhydrology_inst, waterstate_inst, endwb(bounds%begc:bounds%endc))


soilhydrology_inst, waterstate_inst, &
subtract_dynbal_baselines = .false., &
water_mass = endwb(bounds%begc:bounds%endc))


! Determine wetland and land ice hydrology (must be placed here
Expand Down
4 changes: 3 additions & 1 deletion src/biogeophys/LakeHydrologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,9 @@ subroutine LakeHydrology(bounds, &
! Determine ending water balance and volumetric soil water

call ComputeWaterMassLake(bounds, num_lakec, filter_lakec, &
waterstate_inst, endwb(bounds%begc:bounds%endc))
waterstate_inst, &
subtract_dynbal_baselines = .false., &
water_mass = endwb(bounds%begc:bounds%endc))

do j = 1, nlevgrnd
do fc = 1, num_lakec
Expand Down
66 changes: 50 additions & 16 deletions src/biogeophys/TotalWaterAndHeatMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ module TotalWaterAndHeatMod

!-----------------------------------------------------------------------
subroutine ComputeWaterMassNonLake(bounds, num_nolakec, filter_nolakec, &
soilhydrology_inst, waterstate_inst, water_mass)
soilhydrology_inst, waterstate_inst, &
subtract_dynbal_baselines, &
water_mass)
!
! !DESCRIPTION:
! Compute total water mass for all non-lake columns
Expand All @@ -96,6 +98,11 @@ subroutine ComputeWaterMassNonLake(bounds, num_nolakec, filter_nolakec, &
integer , intent(in) :: filter_nolakec(:) ! column filter for non-lake points
type(soilhydrology_type) , intent(in) :: soilhydrology_inst
type(waterstate_type) , intent(in) :: waterstate_inst

! BUG(wjs, 2019-03-12, ESCOMP/ctsm#659) When we can accept answer changes to methane,
! remove this argument, always assuming it's true.
logical, intent(in) :: subtract_dynbal_baselines ! whether to subtract dynbal_baseline_liq and dynbal_baseline_ice from liquid_mass and ice_mass

real(r8) , intent(inout) :: water_mass( bounds%begc: ) ! computed water mass (kg m-2)
!
! !LOCAL VARIABLES:
Expand All @@ -114,6 +121,7 @@ subroutine ComputeWaterMassNonLake(bounds, num_nolakec, filter_nolakec, &
filter_nolakec = filter_nolakec, &
soilhydrology_inst = soilhydrology_inst, &
waterstate_inst = waterstate_inst, &
subtract_dynbal_baselines = subtract_dynbal_baselines, &
liquid_mass = liquid_mass(bounds%begc:bounds%endc), &
ice_mass = ice_mass(bounds%begc:bounds%endc))

Expand All @@ -126,7 +134,9 @@ end subroutine ComputeWaterMassNonLake

!-----------------------------------------------------------------------
subroutine ComputeWaterMassLake(bounds, num_lakec, filter_lakec, &
waterstate_inst, water_mass)
waterstate_inst, &
subtract_dynbal_baselines, &
water_mass)
!
! !DESCRIPTION:
! Compute total water mass for all lake columns
Expand All @@ -136,6 +146,11 @@ subroutine ComputeWaterMassLake(bounds, num_lakec, filter_lakec, &
integer , intent(in) :: num_lakec ! number of column lake points in column filter
integer , intent(in) :: filter_lakec(:) ! column filter for lake points
type(waterstate_type) , intent(in) :: waterstate_inst

! BUG(wjs, 2019-03-12, ESCOMP/ctsm#659) When we can accept answer changes to methane,
! remove this argument, always assuming it's true.
logical, intent(in) :: subtract_dynbal_baselines ! whether to subtract dynbal_baseline_liq and dynbal_baseline_ice from liquid_mass and ice_mass

real(r8) , intent(inout) :: water_mass( bounds%begc: ) ! computed water mass (kg m-2)
!
! !LOCAL VARIABLES:
Expand All @@ -153,6 +168,7 @@ subroutine ComputeWaterMassLake(bounds, num_lakec, filter_lakec, &
num_lakec = num_lakec, &
filter_lakec = filter_lakec, &
waterstate_inst = waterstate_inst, &
subtract_dynbal_baselines = subtract_dynbal_baselines, &
liquid_mass = liquid_mass(bounds%begc:bounds%endc), &
ice_mass = ice_mass(bounds%begc:bounds%endc))

Expand All @@ -166,7 +182,9 @@ end subroutine ComputeWaterMassLake

!-----------------------------------------------------------------------
subroutine ComputeLiqIceMassNonLake(bounds, num_nolakec, filter_nolakec, &
soilhydrology_inst, waterstate_inst, liquid_mass, ice_mass)
soilhydrology_inst, waterstate_inst, &
subtract_dynbal_baselines, &
liquid_mass, ice_mass)
!
! !DESCRIPTION:
! Compute total water mass for all non-lake columns, separated into liquid and ice
Expand All @@ -180,6 +198,11 @@ subroutine ComputeLiqIceMassNonLake(bounds, num_nolakec, filter_nolakec, &
integer , intent(in) :: filter_nolakec(:) ! column filter for non-lake points
type(soilhydrology_type) , intent(in) :: soilhydrology_inst
type(waterstate_type) , intent(in) :: waterstate_inst

! BUG(wjs, 2019-03-12, ESCOMP/ctsm#659) When we can accept answer changes to methane,
! remove this argument, always assuming it's true.
logical, intent(in) :: subtract_dynbal_baselines ! whether to subtract dynbal_baseline_liq and dynbal_baseline_ice from liquid_mass and ice_mass

real(r8) , intent(inout) :: liquid_mass( bounds%begc: ) ! computed liquid water mass (kg m-2)
real(r8) , intent(inout) :: ice_mass( bounds%begc: ) ! computed ice mass (kg m-2)
!
Expand Down Expand Up @@ -282,12 +305,14 @@ subroutine ComputeLiqIceMassNonLake(bounds, num_nolakec, filter_nolakec, &
liquid_mass = liquid_mass(bounds%begc:bounds%endc), &
ice_mass = ice_mass(bounds%begc:bounds%endc))

! Subtract baselines set in initialization
do fc = 1, num_nolakec
c = filter_nolakec(fc)
liquid_mass(c) = liquid_mass(c) - dynbal_baseline_liq(c)
ice_mass(c) = ice_mass(c) - dynbal_baseline_ice(c)
end do
if (subtract_dynbal_baselines) then
! Subtract baselines set in initialization
do fc = 1, num_nolakec
c = filter_nolakec(fc)
liquid_mass(c) = liquid_mass(c) - dynbal_baseline_liq(c)
ice_mass(c) = ice_mass(c) - dynbal_baseline_ice(c)
end do
end if

end associate

Expand Down Expand Up @@ -358,7 +383,9 @@ end subroutine AccumulateSoilLiqIceMassNonLake

!-----------------------------------------------------------------------
subroutine ComputeLiqIceMassLake(bounds, num_lakec, filter_lakec, &
waterstate_inst, liquid_mass, ice_mass)
waterstate_inst, &
subtract_dynbal_baselines, &
liquid_mass, ice_mass)
!
! !DESCRIPTION:
! Compute total water mass for all lake columns, separated into liquid and ice
Expand All @@ -371,6 +398,11 @@ subroutine ComputeLiqIceMassLake(bounds, num_lakec, filter_lakec, &
integer , intent(in) :: num_lakec ! number of column lake points in column filter
integer , intent(in) :: filter_lakec(:) ! column filter for lake points
type(waterstate_type) , intent(in) :: waterstate_inst

! BUG(wjs, 2019-03-12, ESCOMP/ctsm#659) When we can accept answer changes to methane,
! remove this argument, always assuming it's true.
logical, intent(in) :: subtract_dynbal_baselines ! whether to subtract dynbal_baseline_liq and dynbal_baseline_ice from liquid_mass and ice_mass

real(r8) , intent(inout) :: liquid_mass( bounds%begc: ) ! computed liquid water mass (kg m-2)
real(r8) , intent(inout) :: ice_mass( bounds%begc: ) ! computed ice mass (kg m-2)
!
Expand Down Expand Up @@ -424,12 +456,14 @@ subroutine ComputeLiqIceMassLake(bounds, num_lakec, filter_lakec, &
end do
end do

! Subtract baselines set in initialization
do fc = 1, num_lakec
c = filter_lakec(fc)
liquid_mass(c) = liquid_mass(c) - dynbal_baseline_liq(c)
ice_mass(c) = ice_mass(c) - dynbal_baseline_ice(c)
end do
if (subtract_dynbal_baselines) then
! Subtract baselines set in initialization
do fc = 1, num_lakec
c = filter_lakec(fc)
liquid_mass(c) = liquid_mass(c) - dynbal_baseline_liq(c)
ice_mass(c) = ice_mass(c) - dynbal_baseline_ice(c)
end do
end if

end associate

Expand Down
10 changes: 6 additions & 4 deletions src/dyn_subgrid/dynConsBiogeophysMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,15 @@ subroutine dyn_water_content(bounds, &

call ComputeLiqIceMassNonLake(bounds, num_nolakec, filter_nolakec, &
soilhydrology_inst, waterstate_inst, &
liquid_mass_col(bounds%begc:bounds%endc), &
ice_mass_col(bounds%begc:bounds%endc))
subtract_dynbal_baselines = .true., &
liquid_mass = liquid_mass_col(bounds%begc:bounds%endc), &
ice_mass = ice_mass_col(bounds%begc:bounds%endc))

call ComputeLiqIceMassLake(bounds, num_lakec, filter_lakec, &
waterstate_inst, &
liquid_mass_col(bounds%begc:bounds%endc), &
ice_mass_col(bounds%begc:bounds%endc))
subtract_dynbal_baselines = .true., &
liquid_mass = liquid_mass_col(bounds%begc:bounds%endc), &
ice_mass = ice_mass_col(bounds%begc:bounds%endc))

call c2g(bounds, &
carr = liquid_mass_col(bounds%begc:bounds%endc), &
Expand Down

0 comments on commit 44e254d

Please sign in to comment.