Skip to content

Commit c71bee4

Browse files
committed
(#494) - Remove incorrect densities in water balance calc.
User ssnow%wbtot to avoid approximating the ice density with the liquid water density.
1 parent 31a233f commit c71bee4

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

src/offline/cable_checks.F90

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -474,48 +474,46 @@ END SUBROUTINE constant_check_range
474474

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

478480
! Input arguments
479-
REAL,INTENT(IN) :: dels ! time step size
480-
INTEGER, INTENT(IN) :: ktau ! timestep number
481-
TYPE (soil_snow_type),INTENT(IN) :: ssnow ! soil data
482-
TYPE (soil_parameter_type),INTENT(IN) :: soil ! soil data
483-
TYPE (canopy_type),INTENT(IN) :: canopy ! canopy variable data
484-
TYPE(met_type),INTENT(IN) :: met ! met data
481+
REAL,INTENT(IN) :: dels
482+
!! Time step length \(s\)
483+
INTEGER, INTENT(IN) :: ktau
484+
!! Number of time steps since the start of the simulation \(-\)
485+
TYPE (soil_snow_type),INTENT(IN) :: ssnow
486+
!! Soil and snow variables data
487+
TYPE (soil_parameter_type),INTENT(IN) :: soil
488+
!! Soil parameters
489+
TYPE (canopy_type),INTENT(IN) :: canopy
490+
!! Canopy variables data
491+
TYPE(met_type),INTENT(IN) :: met
492+
!! Met forcing data
485493
TYPE (air_type),INTENT(IN) :: air
494+
!! Air variables data
495+
TYPE (balances_type),INTENT(INOUT) :: bal
496+
!! Water balance variables data
486497

487498
! Local variables
488-
REAL(r_2), DIMENSION(:,:,:),POINTER, SAVE :: bwb ! volumetric soil moisture
499+
REAL(r_2), DIMENSION(:),POINTER, SAVE :: owb ! volumetric soil moisture
500+
! at previous time step
489501
REAL(r_2), DIMENSION(mp) :: delwb ! change in soilmoisture
490502
! b/w tsteps
491-
REAL, DIMENSION(mp) :: canopy_wbal !canopy water balance
492-
TYPE (balances_type),INTENT(INOUT) :: bal
493-
INTEGER :: j, k ! do loop counter
503+
REAL, DIMENSION(mp) :: canopy_wbal !canopy water balance
504+
INTEGER :: j, k ! do loop counter
494505

495506
IF(ktau==1) THEN
496-
ALLOCATE( bwb(mp,ms,2) )
507+
ALLOCATE( owb(mp) )
497508
! initial vlaue of soil moisture
498-
bwb(:,:,1)=ssnow%wb
499-
bwb(:,:,2)=ssnow%wb
500-
delwb(:) = 0.
501-
ELSE
502-
! Calculate change in soil moisture b/w timesteps:
503-
IF(MOD(REAL(ktau),2.0)==1.0) THEN ! if odd timestep
504-
bwb(:,:,1)=ssnow%wb
505-
DO k=1,mp ! current smoist - prev tstep smoist
506-
delwb(k) = SUM((bwb(k,:,1) &
507-
- (bwb(k,:,2)))*soil%zse)*1000.0
508-
END DO
509-
ELSE IF(MOD(REAL(ktau),2.0)==0.0) THEN ! if even timestep
510-
bwb(:,:,2)=ssnow%wb
511-
DO k=1,mp ! current smoist - prev tstep smoist
512-
delwb(k) = SUM((bwb(k,:,2) &
513-
- (bwb(k,:,1)))*soil%zse)*1000.0
514-
END DO
515-
END IF
509+
owb=ssnow%wbtot
516510
END IF
517511

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

515+
! Update old soil moisture to this timestep value.
516+
owb = ssnow%wbtot
519517

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

0 commit comments

Comments
 (0)