Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

494 redux local ice fixes #527

Merged
merged 17 commits into from
Feb 25, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
(#494) - Remove incorrect densities in water balance calc.
User ssnow%wbtot to avoid approximating the ice density with the liquid water density.
ccarouge committed Feb 13, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit c71bee41a7315f5b57a824aae9863e6468326f4b
56 changes: 27 additions & 29 deletions src/offline/cable_checks.F90
Original file line number Diff line number Diff line change
@@ -474,48 +474,46 @@ END SUBROUTINE constant_check_range

SUBROUTINE mass_balance(dels,ktau, ssnow,soil,canopy,met, &
air,bal)
!* Calculates the energy and water balances at each time step as well as
! the cumulative balance over the simulation.

! Input arguments
REAL,INTENT(IN) :: dels ! time step size
INTEGER, INTENT(IN) :: ktau ! timestep number
TYPE (soil_snow_type),INTENT(IN) :: ssnow ! soil data
TYPE (soil_parameter_type),INTENT(IN) :: soil ! soil data
TYPE (canopy_type),INTENT(IN) :: canopy ! canopy variable data
TYPE(met_type),INTENT(IN) :: met ! met data
REAL,INTENT(IN) :: dels
!! Time step length \(s\)
INTEGER, INTENT(IN) :: ktau
!! Number of time steps since the start of the simulation \(-\)
TYPE (soil_snow_type),INTENT(IN) :: ssnow
!! Soil and snow variables data
TYPE (soil_parameter_type),INTENT(IN) :: soil
!! Soil parameters
TYPE (canopy_type),INTENT(IN) :: canopy
!! Canopy variables data
TYPE(met_type),INTENT(IN) :: met
!! Met forcing data
TYPE (air_type),INTENT(IN) :: air
!! Air variables data
TYPE (balances_type),INTENT(INOUT) :: bal
!! Water balance variables data

! Local variables
REAL(r_2), DIMENSION(:,:,:),POINTER, SAVE :: bwb ! volumetric soil moisture
REAL(r_2), DIMENSION(:),POINTER, SAVE :: owb ! volumetric soil moisture
! at previous time step
REAL(r_2), DIMENSION(mp) :: delwb ! change in soilmoisture
! b/w tsteps
REAL, DIMENSION(mp) :: canopy_wbal !canopy water balance
TYPE (balances_type),INTENT(INOUT) :: bal
INTEGER :: j, k ! do loop counter
REAL, DIMENSION(mp) :: canopy_wbal !canopy water balance
INTEGER :: j, k ! do loop counter

IF(ktau==1) THEN
ALLOCATE( bwb(mp,ms,2) )
ALLOCATE( owb(mp) )
! initial vlaue of soil moisture
bwb(:,:,1)=ssnow%wb
bwb(:,:,2)=ssnow%wb
delwb(:) = 0.
ELSE
! Calculate change in soil moisture b/w timesteps:
IF(MOD(REAL(ktau),2.0)==1.0) THEN ! if odd timestep
bwb(:,:,1)=ssnow%wb
DO k=1,mp ! current smoist - prev tstep smoist
delwb(k) = SUM((bwb(k,:,1) &
- (bwb(k,:,2)))*soil%zse)*1000.0
END DO
ELSE IF(MOD(REAL(ktau),2.0)==0.0) THEN ! if even timestep
bwb(:,:,2)=ssnow%wb
DO k=1,mp ! current smoist - prev tstep smoist
delwb(k) = SUM((bwb(k,:,2) &
- (bwb(k,:,1)))*soil%zse)*1000.0
END DO
END IF
owb=ssnow%wbtot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ccarouge sorry this is incorrect. This updates owb before using it to evaluate delwb - i.e. delwb will always = 0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only on ktau == 1. so first time step initialisation. So at first time step we will have 0 but then it will work fine. Same behaviour as before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it helps on the review page on GitHub, it's possible to display the differences unified or split. Use the gear icon to choose (let me know if not clear on the screenshot).

Screenshot 2025-02-14 at 4 01 21 pm

END IF

! Calculate change in soil moisture b/w timesteps:
delwb = ssnow%wbtot - owb

! Update old soil moisture to this timestep value.
owb = ssnow%wbtot

! net water into soil (precip-(change in canopy water storage)
! - (change in snow depth) - (surface runoff) - (deep drainage)