Skip to content

Commit

Permalink
Base lake frac_sno reset on h2osno_total rather than snow_depth
Browse files Browse the repository at this point in the history
ERI tests were failing the base-hybrid comparison when basing this reset
on snow_depth. My guess is that it's possible for snow_depth to be > 0
even when frac_sno is 0, at least for lakes. I'm hoping that using
h2osno_total will be more robust - i.e., that we should never have
frac_sno == 0 when h2osno_total > 0.

Addresses ESCOMP#783
  • Loading branch information
billsacks committed Oct 20, 2019
1 parent 00c614f commit b1f282c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
25 changes: 20 additions & 5 deletions src/biogeophys/WaterDiagnosticBulkType.F90
Expand Up @@ -21,10 +21,12 @@ module WaterDiagnosticBulkType
use clm_varcon , only : spval
use LandunitType , only : lun
use ColumnType , only : col
use filterColMod , only : filter_col_type, col_filter_from_ltypes
use WaterDiagnosticType, only : waterdiagnostic_type
use WaterInfoBaseType, only : water_info_base_type
use WaterTracerContainerType, only : water_tracer_container_type
use WaterStateType, only : waterstate_type
use WaterStateBulkType, only : waterstatebulk_type
use WaterFluxType, only : waterflux_type
!
implicit none
Expand Down Expand Up @@ -600,7 +602,7 @@ subroutine InitBulkCold(this, bounds, &
end subroutine InitBulkCold

!------------------------------------------------------------------------
subroutine RestartBulk(this, bounds, ncid, flag)
subroutine RestartBulk(this, bounds, ncid, flag, waterstatebulk_inst)
!
! !DESCRIPTION:
! Read/Write module information to/from restart file.
Expand All @@ -620,10 +622,13 @@ subroutine RestartBulk(this, bounds, ncid, flag)
type(bounds_type), intent(in) :: bounds
type(file_desc_t), intent(inout) :: ncid ! netcdf id
character(len=*) , intent(in) :: flag ! 'read' or 'write'
type(waterstatebulk_type), intent(in) :: waterstatebulk_inst
!
! !LOCAL VARIABLES:
logical :: readvar
integer :: c
integer :: fc, c
real(r8) :: h2osno_total(bounds%begc:bounds%endc) ! total snow water (mm H2O)
type(filter_col_type) :: filter_lakec ! filter for lake columns
!------------------------------------------------------------------------


Expand Down Expand Up @@ -685,9 +690,19 @@ subroutine RestartBulk(this, bounds, ncid, flag)
! being from versions later than the tag where this backwards compatibility was first
! implemented.)
if (flag == 'read' .and. .not. is_restart()) then
do c = bounds%begc, bounds%endc
if (col%lun_itype(c) == istdlak .and. &
this%frac_sno_col(c) == 0._r8 .and. this%snow_depth_col(c) > 0._r8) then
filter_lakec = col_filter_from_ltypes( &
bounds = bounds, &
ltypes = [istdlak], &
include_inactive = .true.)
call waterstatebulk_inst%CalculateTotalH2osno( &
bounds = bounds, &
num_c = filter_lakec%num, &
filter_c = filter_lakec%indices, &
caller = 'WaterDiagnosticBulkType_RestartBulk', &
h2osno_total = h2osno_total(bounds%begc:bounds%endc))
do fc = 1, filter_lakec%num
c = filter_lakec%indices(fc)
if (this%frac_sno_col(c) == 0._r8 .and. h2osno_total(c) > 0._r8) then
! Often the value should be between 0 and 1 rather than being 1, but 1 is at
! least better than 0 in this case, and it would be tricky or impossible to
! figure out the "correct" value.
Expand Down
3 changes: 2 additions & 1 deletion src/biogeophys/WaterType.F90
Expand Up @@ -738,7 +738,8 @@ subroutine Restart(this, bounds, ncid, flag, &
call this%waterstatebulk_inst%restartBulk (bounds, ncid, flag=flag, &
watsat_col=watsat_col(bounds%begc:bounds%endc,:))

call this%waterdiagnosticbulk_inst%restartBulk (bounds, ncid, flag=flag)
call this%waterdiagnosticbulk_inst%restartBulk (bounds, ncid, flag=flag, &
waterstatebulk_inst = this%waterstatebulk_inst)

do i = this%tracers_beg, this%tracers_end

Expand Down

0 comments on commit b1f282c

Please sign in to comment.