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 13, 2019
1 parent d2ba980 commit 366ddd6
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 24 deletions.
8 changes: 6 additions & 2 deletions src/biogeophys/BalanceCheckMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,14 @@ subroutine BeginWaterBalanceSingle(bounds, &
endif

call ComputeWaterMassNonLake(bounds, num_nolakec, filter_nolakec, &
waterstate_inst, waterdiagnostic_inst, begwb(bounds%begc:bounds%endc))
waterstate_inst, waterdiagnostic_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))

do c = bounds%begc, bounds%endc
h2osno_old(c) = h2osno(c)
Expand Down
4 changes: 3 additions & 1 deletion src/biogeophys/HydrologyDrainageMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ subroutine HydrologyDrainage(bounds, &
end do

call ComputeWaterMassNonLake(bounds, num_nolakec, filter_nolakec, &
waterstatebulk_inst, waterdiagnosticbulk_inst, endwb(bounds%begc:bounds%endc))
waterstatebulk_inst, waterdiagnosticbulk_inst, &
subtract_dynbal_baselines = .false., &
water_mass = endwb(bounds%begc:bounds%endc))

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

call ComputeWaterMassLake(bounds, num_lakec, filter_lakec, &
waterstatebulk_inst, endwb(bounds%begc:bounds%endc))
waterstatebulk_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 @@ -88,7 +88,9 @@ module TotalWaterAndHeatMod

!-----------------------------------------------------------------------
subroutine ComputeWaterMassNonLake(bounds, num_nolakec, filter_nolakec, &
waterstate_inst, waterdiagnostic_inst, water_mass)
waterstate_inst, waterdiagnostic_inst, &
subtract_dynbal_baselines, &
water_mass)
!
! !DESCRIPTION:
! Compute total water mass for all non-lake columns
Expand All @@ -102,6 +104,11 @@ subroutine ComputeWaterMassNonLake(bounds, num_nolakec, filter_nolakec, &
integer , intent(in) :: filter_nolakec(:) ! column filter for non-lake points
class(waterstate_type) , intent(in) :: waterstate_inst
class(waterdiagnostic_type), intent(in) :: waterdiagnostic_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 @@ -120,6 +127,7 @@ subroutine ComputeWaterMassNonLake(bounds, num_nolakec, filter_nolakec, &
filter_nolakec = filter_nolakec, &
waterstate_inst = waterstate_inst, &
waterdiagnostic_inst = waterdiagnostic_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 @@ -132,7 +140,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 @@ -145,6 +155,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
class(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 @@ -162,6 +177,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 @@ -175,7 +191,9 @@ end subroutine ComputeWaterMassLake

!-----------------------------------------------------------------------
subroutine ComputeLiqIceMassNonLake(bounds, num_nolakec, filter_nolakec, &
waterstate_inst, waterdiagnostic_inst, liquid_mass, ice_mass)
waterstate_inst, waterdiagnostic_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 @@ -192,6 +210,11 @@ subroutine ComputeLiqIceMassNonLake(bounds, num_nolakec, filter_nolakec, &
integer , intent(in) :: filter_nolakec(:) ! column filter for non-lake points
class(waterstate_type) , intent(in) :: waterstate_inst
class(waterdiagnostic_type), intent(in) :: waterdiagnostic_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 @@ -294,12 +317,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 @@ -370,7 +395,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 @@ -386,6 +413,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
class(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 @@ -439,12 +471,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 @@ -578,13 +578,15 @@ subroutine dyn_water_content(bounds, &

call ComputeLiqIceMassNonLake(bounds, num_nolakec, filter_nolakec, &
waterstate_inst, waterdiagnostic_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 366ddd6

Please sign in to comment.