Skip to content

Commit

Permalink
Merge pull request #6 from billsacks/hillslope_hydrology
Browse files Browse the repository at this point in the history
Hillslope hydrology
  • Loading branch information
swensosc authored Jul 18, 2022
2 parents 78cbfed + 99cfb53 commit 64ba19d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
17 changes: 1 addition & 16 deletions bld/unit_testers/build-namelist_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ sub cat_and_create_namelistinfile {
#
# Figure out number of tests that will run
#
my $ntests = 1844;
my $ntests = 1841;
if ( defined($opts{'compare'}) ) {
$ntests += 1254;
}
Expand Down Expand Up @@ -771,21 +771,6 @@ sub cat_and_create_namelistinfile {
GLC_TWO_WAY_COUPLING=>"FALSE",
phys=>"clm4_5",
},
"-vic with origflag=1" =>{ options=>"-vichydro -envxml_dir .",
namelst=>"origflag=1",
GLC_TWO_WAY_COUPLING=>"FALSE",
phys=>"clm4_5",
},
"l_bnd=flux with origflag=0"=>{ options=>"-envxml_dir .",
namelst=>"origflag=0, lower_boundary_condition=1",
GLC_TWO_WAY_COUPLING=>"FALSE",
phys=>"clm4_5",
},
"l_bnd=zflux with origflag=0"=>{ options=>"-envxml_dir .",
namelst=>"origflag=0, lower_boundary_condition=2",
GLC_TWO_WAY_COUPLING=>"FALSE",
phys=>"clm4_5",
},
"bedrock with l_bnc=flux" =>{ options=>"-envxml_dir .",
namelst=>"use_bedrock=.true., lower_boundary_condition=1",
GLC_TWO_WAY_COUPLING=>"FALSE",
Expand Down
1 change: 0 additions & 1 deletion cime_config/testdefs/testmods_dirs/clm/oldhyd/user_nl_clm
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
snow_cover_fraction_method = 'NiuYang2007'
h2osfcflag = 0
origflag = 1
use_subgrid_fluxes = .false.
14 changes: 11 additions & 3 deletions src/main/lnd2glcMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module lnd2glcMod
use decompMod , only : get_proc_bounds, bounds_type, subgrid_level_column
use domainMod , only : ldomain
use clm_varpar , only : maxpatch_glc
use clm_varctl , only : iulog
use clm_varctl , only : iulog, use_hillslope
use clm_varcon , only : spval, tfrz
use column_varcon , only : col_itype_to_ice_class
use landunit_varcon , only : istice, istsoil
Expand Down Expand Up @@ -204,8 +204,16 @@ subroutine update_lnd2glc(this, bounds, num_do_smb_c, filter_do_smb_c, &
! Make sure we haven't already assigned the coupling fields for this point
! (this could happen, for example, if there were multiple columns in the
! istsoil landunit, which we aren't prepared to handle)
!scs if (fields_assigned(g,n)) then
if (1==2) then
!
! BUG(wjs, 2022-07-17, ESCOMP/CTSM#204) We have a known bug in the handling of bare
! land fluxes when we potentially have multiple vegetated columns in a grid cell.
! The most common configuration where this is the case is when use_hillslope is
! true. In order to allow hillslope hydrology runs to work for now, we are
! bypassing this error check when use_hillslope is true - under the assumption
! that, for now, people aren't going to be interested in SMB in a run with
! hillslope hydrology. Once we resolve ESCOMP/CTSM#204, we should remove the '.and.
! .not. use_hillslope' part of this conditional.
if (fields_assigned(g,n) .and. .not. use_hillslope) then
write(iulog,*) subname//' ERROR: attempt to assign coupling fields twice for the same index.'
write(iulog,*) 'One possible cause is having multiple columns in the istsoil landunit,'
write(iulog,*) 'which this routine cannot handle.'
Expand Down
11 changes: 9 additions & 2 deletions src/main/test/atm2lnd_test/test_downscale_forcings.pf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module test_downscale_forcings
use unittestSimpleSubgridSetupsMod
use unittestArrayMod
use atm2lndType, only : atm2lnd_type, atm2lnd_params_type
use SurfaceAlbedoType, only : surfalb_type
use Wateratm2lndBulkType, only : wateratm2lndbulk_type
use WaterInfoBulkType, only : water_info_bulk_type
use TopoMod, only : topo_type
Expand All @@ -25,6 +26,7 @@ module test_downscale_forcings
@TestCase
type, extends(TestCase) :: TestDownscaleForcings
type(atm2lnd_type) :: atm2lnd_inst
type(surfalb_type) :: surfalb_inst
type(wateratm2lndbulk_type) :: wateratm2lndbulk_inst
type(topo_type_always_downscale) :: topo_inst
real(r8), allocatable :: eflx_sh_precip_conversion(:)
Expand Down Expand Up @@ -204,8 +206,13 @@ contains
class(TestDownscaleForcings), intent(inout) :: this

this%eflx_sh_precip_conversion = col_array()
call downscale_forcings(bounds, this%topo_inst, &
this%atm2lnd_inst, this%wateratm2lndbulk_inst, &
call downscale_forcings(bounds, &
this%topo_inst, &
this%atm2lnd_inst, &
! Currently surfalb_inst is only used for hillslope downscaling; we need to pass
! it to satisfy the interface but we haven't bothered setting it up
this%surfalb_inst, &
this%wateratm2lndbulk_inst, &
this%eflx_sh_precip_conversion)
end subroutine call_downscale_forcings

Expand Down
11 changes: 11 additions & 0 deletions src/main/test/atm2lnd_test/test_partition_precip.pf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module test_partition_precip
use pfunit_mod
use atm2lndMod
use atm2lndType
use ColumnType, only : col
use shr_kind_mod, only : r8 => shr_kind_r8
use unittestSubgridMod
use unittestSimpleSubgridSetupsMod
Expand Down Expand Up @@ -64,6 +65,7 @@ contains

logical :: l_repartition_rain_snow
type(atm2lnd_params_type) :: atm2lnd_params
integer :: c, g

if (present(repartition_rain_snow)) then
l_repartition_rain_snow = repartition_rain_snow
Expand All @@ -89,6 +91,15 @@ contains
this%wateratm2lndbulk_inst%forc_rain_not_downscaled_grc(bounds%begg:bounds%endg) = rain(:)
this%wateratm2lndbulk_inst%forc_snow_not_downscaled_grc(bounds%begg:bounds%endg) = snow(:)
this%atm2lnd_inst%forc_t_downscaled_col(bounds%begc:bounds%endc) = temperature(:)

! In the production code, column-level versions of forc_rain and forc_snow are
! initialized to the gridcell-level versions prior to the call to partition_precip; do
! that here
do c = bounds%begc, bounds%endc
g = col%gridcell(c)
this%wateratm2lndbulk_inst%forc_rain_downscaled_col(c) = this%wateratm2lndbulk_inst%forc_rain_not_downscaled_grc(g)
this%wateratm2lndbulk_inst%forc_snow_downscaled_col(c) = this%wateratm2lndbulk_inst%forc_snow_not_downscaled_grc(g)
end do
end subroutine set_inputs

@Test
Expand Down

0 comments on commit 64ba19d

Please sign in to comment.