From af5593d52a22b205eb7794309d582268287fd1ff Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Wed, 25 Jul 2018 17:14:33 -0600 Subject: [PATCH] Add a water_type that holds instances of the various water derived types This follows the design laid out in https://github.com/escomp/ctsm/pull/395. This will be particularly valuable when we introduce tracer instances: the logic related to number of tracers can be encapsulated in water_type, rather than infiltrating clm_instMod. --- src/biogeophys/WaterDiagnosticBulkType.F90 | 12 +- src/biogeophys/WaterStateBulkType.F90 | 10 +- src/biogeophys/WaterStateType.F90 | 10 +- src/biogeophys/WaterType.F90 | 179 +++++++++++++++++++++ src/main/clm_driver.F90 | 138 ++++++++++------ src/main/clm_initializeMod.F90 | 10 +- src/main/clm_instMod.F90 | 43 ++--- 7 files changed, 304 insertions(+), 98 deletions(-) create mode 100644 src/biogeophys/WaterType.F90 diff --git a/src/biogeophys/WaterDiagnosticBulkType.F90 b/src/biogeophys/WaterDiagnosticBulkType.F90 index 98f565050b..6224943f70 100644 --- a/src/biogeophys/WaterDiagnosticBulkType.F90 +++ b/src/biogeophys/WaterDiagnosticBulkType.F90 @@ -92,10 +92,10 @@ module WaterDiagnosticBulkType subroutine InitBulk(this, bounds, & snow_depth_input_col, waterstatebulk_inst) - class(waterdiagnosticbulk_type) :: this - type(bounds_type) , intent(in) :: bounds - real(r8) , intent(inout) :: snow_depth_input_col(bounds%begc:) - class(waterstatebulk_type), intent(in) :: waterstatebulk_inst + class(waterdiagnosticbulk_type) :: this + type(bounds_type) , intent(in) :: bounds + real(r8) , intent(in) :: snow_depth_input_col(bounds%begc:) + class(waterstatebulk_type), intent(in) :: waterstatebulk_inst call this%Init(bounds) @@ -490,7 +490,7 @@ subroutine InitBulkCold(this, bounds, & end subroutine InitBulkCold !------------------------------------------------------------------------ - subroutine RestartBulk(this, waterstatebulk_inst, bounds, ncid, flag) + subroutine RestartBulk(this, bounds, ncid, flag, waterstatebulk_inst) ! ! !DESCRIPTION: ! Read/Write module information to/from restart file. @@ -507,10 +507,10 @@ subroutine RestartBulk(this, waterstatebulk_inst, bounds, ncid, flag) ! ! !ARGUMENTS: class(waterdiagnosticbulk_type) :: this - class(waterstatebulk_type), intent(in) :: waterstatebulk_inst type(bounds_type), intent(in) :: bounds type(file_desc_t), intent(inout) :: ncid ! netcdf id character(len=*) , intent(in) :: flag ! 'read' or 'write' + class(waterstatebulk_type), intent(in) :: waterstatebulk_inst ! ! !LOCAL VARIABLES: integer :: c,l,j diff --git a/src/biogeophys/WaterStateBulkType.F90 b/src/biogeophys/WaterStateBulkType.F90 index 9f553cf735..d2718a2af8 100644 --- a/src/biogeophys/WaterStateBulkType.F90 +++ b/src/biogeophys/WaterStateBulkType.F90 @@ -49,11 +49,11 @@ module WaterStateBulkType subroutine InitBulk(this, bounds, & h2osno_input_col, watsat_col, t_soisno_col) - class(waterstatebulk_type) :: this - type(bounds_type) , intent(in) :: bounds - real(r8) , intent(inout) :: h2osno_input_col(bounds%begc:) - real(r8) , intent(inout) :: watsat_col(bounds%begc:, 1:) ! volumetric soil water at saturation (porosity) - real(r8) , intent(inout) :: t_soisno_col(bounds%begc:, -nlevsno+1:) ! col soil temperature (Kelvin) + class(waterstatebulk_type) :: this + type(bounds_type) , intent(in) :: bounds + real(r8) , intent(in) :: h2osno_input_col(bounds%begc:) + real(r8) , intent(in) :: watsat_col(bounds%begc:, 1:) ! volumetric soil water at saturation (porosity) + real(r8) , intent(in) :: t_soisno_col(bounds%begc:, -nlevsno+1:) ! col soil temperature (Kelvin) call this%Init(bounds, & diff --git a/src/biogeophys/WaterStateType.F90 b/src/biogeophys/WaterStateType.F90 index fbd65e8abd..06e73e4076 100644 --- a/src/biogeophys/WaterStateType.F90 +++ b/src/biogeophys/WaterStateType.F90 @@ -55,11 +55,11 @@ module WaterStateType subroutine Init(this, bounds, & h2osno_input_col, watsat_col, t_soisno_col) - class(waterstate_type) :: this - type(bounds_type) , intent(in) :: bounds - real(r8) , intent(inout) :: h2osno_input_col(bounds%begc:) - real(r8) , intent(inout) :: watsat_col(bounds%begc:, 1:) ! volumetric soil water at saturation (porosity) - real(r8) , intent(inout) :: t_soisno_col(bounds%begc:, -nlevsno+1:) ! col soil temperature (Kelvin) + class(waterstate_type) :: this + type(bounds_type) , intent(in) :: bounds + real(r8) , intent(in) :: h2osno_input_col(bounds%begc:) + real(r8) , intent(in) :: watsat_col(bounds%begc:, 1:) ! volumetric soil water at saturation (porosity) + real(r8) , intent(in) :: t_soisno_col(bounds%begc:, -nlevsno+1:) ! col soil temperature (Kelvin) call this%InitAllocate(bounds) diff --git a/src/biogeophys/WaterType.F90 b/src/biogeophys/WaterType.F90 new file mode 100644 index 0000000000..b54480f561 --- /dev/null +++ b/src/biogeophys/WaterType.F90 @@ -0,0 +1,179 @@ +module WaterType + + !------------------------------------------------------------------------------ + ! !DESCRIPTION: + ! Container for derived types relating to water, both for bulk water and for isotopes + ! and other tracers. + ! + ! !USES: +#include "shr_assert.h" + use shr_kind_mod , only : r8 => shr_kind_r8 + use shr_log_mod , only : errMsg => shr_log_errMsg + use decompMod , only : bounds_type + use clm_varpar , only : nlevsno + use ncdio_pio , only : file_desc_t + use WaterFluxBulkType , only : waterfluxbulk_type + use WaterStateBulkType , only : waterstatebulk_type + use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type + use WaterBalanceType , only : waterbalance_type + + implicit none + private + + ! + ! !PUBLIC TYPES: + type, public :: water_type + type(waterfluxbulk_type) :: waterfluxbulk_inst + type(waterstatebulk_type) :: waterstatebulk_inst + type(waterdiagnosticbulk_type) :: waterdiagnosticbulk_inst + type(waterbalance_type) :: waterbalancebulk_inst + + contains + procedure, public :: Init + procedure, public :: InitAccBuffer + procedure, public :: InitAccVars + procedure, public :: UpdateAccVars + procedure, public :: Restart + end type water_type + + character(len=*), parameter, private :: sourcefile = & + __FILE__ + +contains + + !----------------------------------------------------------------------- + subroutine Init(this, bounds, & + h2osno_col, snow_depth_col, watsat_col, t_soisno_col) + ! + ! !DESCRIPTION: + ! Initialize all water variables + ! + ! !ARGUMENTS: + class(water_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + real(r8) , intent(in) :: h2osno_col(bounds%begc:) + real(r8) , intent(in) :: snow_depth_col(bounds%begc:) + real(r8) , intent(in) :: watsat_col(bounds%begc:, 1:) ! volumetric soil water at saturation (porosity) + real(r8) , intent(in) :: t_soisno_col(bounds%begc:, -nlevsno+1:) ! col soil temperature (Kelvin) + ! + ! !LOCAL VARIABLES: + integer :: begc, endc + + character(len=*), parameter :: subname = 'Init' + !----------------------------------------------------------------------- + + begc = bounds%begc + endc = bounds%endc + + SHR_ASSERT_ALL((ubound(h2osno_col) == [endc]), errMsg(sourcefile, __LINE__)) + SHR_ASSERT_ALL((ubound(snow_depth_col) == [endc]), errMsg(sourcefile, __LINE__)) + SHR_ASSERT_ALL((ubound(watsat_col, 1) == endc), errMsg(sourcefile, __LINE__)) + SHR_ASSERT_ALL((ubound(t_soisno_col, 1) == endc), errMsg(sourcefile, __LINE__)) + + call this%waterstatebulk_inst%InitBulk(bounds, & + h2osno_input_col = h2osno_col(begc:endc), & + watsat_col = watsat_col(begc:endc, 1:), & + t_soisno_col = t_soisno_col(begc:endc, -nlevsno+1:) ) + + call this%waterdiagnosticbulk_inst%InitBulk(bounds, & + snow_depth_input_col = snow_depth_col(begc:endc), & + waterstatebulk_inst = this%waterstatebulk_inst ) + + call this%waterbalancebulk_inst%Init(bounds) + + call this%waterfluxbulk_inst%InitBulk(bounds) + + end subroutine Init + + !----------------------------------------------------------------------- + subroutine InitAccBuffer(this, bounds) + ! + ! !DESCRIPTION: + ! Initialize accumulation buffer for all water variables + ! + ! !ARGUMENTS: + ! + ! !LOCAL VARIABLES: + class(water_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + + character(len=*), parameter :: subname = 'InitAccBuffer' + !----------------------------------------------------------------------- + + call this%waterfluxbulk_inst%InitAccBuffer(bounds) + + end subroutine InitAccBuffer + + !----------------------------------------------------------------------- + subroutine InitAccVars(this, bounds) + ! + ! !DESCRIPTION: + ! Initialize variables that are associated with accumulated fields + ! + ! !ARGUMENTS: + class(water_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'InitAccVars' + !----------------------------------------------------------------------- + + call this%waterfluxbulk_inst%initAccVars(bounds) + + end subroutine InitAccVars + + !----------------------------------------------------------------------- + subroutine UpdateAccVars(this, bounds) + ! + ! !DESCRIPTION: + ! Update accumulated variables + ! + ! Should be called every time step + ! + ! !ARGUMENTS: + class(water_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'UpdateAccVars' + !----------------------------------------------------------------------- + + call this%waterfluxbulk_inst%UpdateAccVars(bounds) + + end subroutine UpdateAccVars + + + !----------------------------------------------------------------------- + subroutine Restart(this, bounds, ncid, flag, & + watsat_col) + ! + ! !DESCRIPTION: + ! Read/write information to/from restart file for all water variables + ! + ! !ARGUMENTS: + class(water_type), intent(inout) :: this + type(bounds_type), intent(in) :: bounds + type(file_desc_t), intent(inout) :: ncid ! netcdf id + character(len=*) , intent(in) :: flag ! 'read', 'write' or 'define' + real(r8) , intent(in) :: watsat_col (bounds%begc:, 1:) ! volumetric soil water at saturation (porosity) + ! + ! !LOCAL VARIABLES: + + character(len=*), parameter :: subname = 'Restart' + !----------------------------------------------------------------------- + + SHR_ASSERT_ALL((ubound(watsat_col, 1) == bounds%endc), errMsg(sourcefile, __LINE__)) + + call this%waterfluxbulk_inst%restartBulk (bounds, ncid, flag=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, & + waterstatebulk_inst=this%waterstatebulk_inst) + + end subroutine Restart + +end module WaterType diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 911510c296..d005d67d45 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -306,7 +306,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call t_startf('dyn_subgrid') call dynSubgrid_driver(bounds_proc, & urbanparams_inst, soilstate_inst, soilhydrology_inst, & - waterstatebulk_inst, waterdiagnosticbulk_inst, waterbalance_inst, waterfluxbulk_inst, temperature_inst, energyflux_inst, & + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + water_inst%waterbalancebulk_inst, water_inst%waterfluxbulk_inst, & + temperature_inst, energyflux_inst, & canopystate_inst, photosyns_inst, crop_inst, glc2lnd_inst, bgc_vegetation_inst, & soilbiogeochem_state_inst, soilbiogeochem_carbonstate_inst, & c13_soilbiogeochem_carbonstate_inst, c14_soilbiogeochem_carbonstate_inst, & @@ -337,7 +339,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call BeginWaterBalance(bounds_clump, & filter(nc)%num_nolakec, filter(nc)%nolakec, & filter(nc)%num_lakec, filter(nc)%lakec, & - soilhydrology_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterbalance_inst) + soilhydrology_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, water_inst%waterbalancebulk_inst) call t_stopf('begwbal') @@ -406,7 +409,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_nolakec, filter(nc)%nolakec, & filter(nc)%num_nolakep, filter(nc)%nolakep, & filter(nc)%num_soilp , filter(nc)%soilp, & - canopystate_inst, waterstatebulk_inst, waterbalance_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, energyflux_inst) + canopystate_inst, water_inst%waterstatebulk_inst, & + water_inst%waterbalancebulk_inst, water_inst%waterdiagnosticbulk_inst, & + water_inst%waterfluxbulk_inst, energyflux_inst) call topo_inst%UpdateTopo(bounds_clump, & filter(nc)%num_icemecc, filter(nc)%icemecc, & @@ -424,7 +429,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! Irrigation flux ! input is main channel storage - call irrigation_inst%ApplyIrrigation(bounds_clump, waterfluxbulk_inst) + call irrigation_inst%ApplyIrrigation(bounds_clump, water_inst%waterfluxbulk_inst) call t_stopf('drvinit') ! ============================================================================ @@ -440,7 +445,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_nolakec, filter(nc)%nolakec, & filter(nc)%num_nolakep, filter(nc)%nolakep, & atm2lnd_inst, canopystate_inst, temperature_inst, & - aerosol_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst) + aerosol_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, water_inst%waterfluxbulk_inst) call t_stopf('canhydro') ! ============================================================================ @@ -471,7 +477,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_nourbanp, filter(nc)%nourbanp, & filter(nc)%num_urbanp, filter(nc)%urbanp, & filter(nc)%num_urbanc, filter(nc)%urbanc, & - atm2lnd_inst, waterdiagnosticbulk_inst, canopystate_inst, surfalb_inst, & + atm2lnd_inst, water_inst%waterdiagnosticbulk_inst, & + canopystate_inst, surfalb_inst, & solarabs_inst, surfrad_inst) ! Surface Radiation for only urban columns @@ -481,7 +488,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_urbanl, filter(nc)%urbanl, & filter(nc)%num_urbanc, filter(nc)%urbanc, & filter(nc)%num_urbanp, filter(nc)%urbanp, & - atm2lnd_inst, waterdiagnosticbulk_inst, temperature_inst, urbanparams_inst, & + atm2lnd_inst, water_inst%waterdiagnosticbulk_inst, & + temperature_inst, urbanparams_inst, & solarabs_inst, surfalb_inst, energyflux_inst) call t_stopf('surfrad') @@ -497,7 +505,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_nolakep, filter(nc)%nolakep, & clm_fates, & atm2lnd_inst, canopystate_inst, soilstate_inst, frictionvel_inst, & - waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, energyflux_inst, temperature_inst) + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + water_inst%waterfluxbulk_inst, energyflux_inst, temperature_inst) call t_stopf('bgp1') ! ============================================================================ @@ -512,7 +521,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_noexposedvegp, filter(nc)%noexposedvegp, & atm2lnd_inst, soilstate_inst, & frictionvel_inst, ch4_inst, energyflux_inst, temperature_inst, & - waterfluxbulk_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, photosyns_inst, humanindex_inst) + water_inst%waterfluxbulk_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, photosyns_inst, humanindex_inst) call t_stopf('bgflux') ! non-bareground fluxes for all patches except lakes and urban landunits @@ -545,7 +555,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro clm_fates,nc, & atm2lnd_inst, canopystate_inst, & energyflux_inst, frictionvel_inst, soilstate_inst, solarabs_inst, surfalb_inst, & - temperature_inst, waterfluxbulk_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, ch4_inst, ozone_inst, photosyns_inst, & + temperature_inst, water_inst%waterfluxbulk_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, ch4_inst, ozone_inst, photosyns_inst, & humanindex_inst, soil_water_retention_curve, & downreg_patch = downreg_patch(bounds_clump%begp:bounds_clump%endp), & leafn_patch = leafn_patch(bounds_clump%begp:bounds_clump%endp), & @@ -563,7 +574,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_urbanc, filter(nc)%urbanc, & filter(nc)%num_urbanp, filter(nc)%urbanp, & atm2lnd_inst, urbanparams_inst, soilstate_inst, temperature_inst, & - waterstatebulk_inst, waterdiagnosticbulk_inst, frictionvel_inst, energyflux_inst, waterfluxbulk_inst, & + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + frictionvel_inst, energyflux_inst, water_inst%waterfluxbulk_inst, & humanindex_inst) call t_stopf('uflux') @@ -574,7 +586,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_lakec, filter(nc)%lakec, & filter(nc)%num_lakep, filter(nc)%lakep, & atm2lnd_inst, solarabs_inst, frictionvel_inst, temperature_inst, & - energyflux_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, lakestate_inst,& + energyflux_inst, water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + water_inst%waterfluxbulk_inst, lakestate_inst,& humanindex_inst) call t_stopf('bgplake') @@ -596,7 +609,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro elai = canopystate_inst%elai_patch(bounds_clump%begp:bounds_clump%endp), & t_soisno = temperature_inst%t_soisno_col(bounds_clump%begc:bounds_clump%endc , 1:nlevgrnd), & eff_porosity = soilstate_inst%eff_porosity_col(bounds_clump%begc:bounds_clump%endc, 1:nlevgrnd), & - h2osoi_liq = waterstatebulk_inst%h2osoi_liq_col(bounds_clump%begc:bounds_clump%endc , 1:nlevgrnd), & + h2osoi_liq = water_inst%waterstatebulk_inst%h2osoi_liq_col& + (bounds_clump%begc:bounds_clump%endc , 1:nlevgrnd), & volr = atm2lnd_inst%volrmch_grc(bounds_clump%begg:bounds_clump%endg), & rof_prognostic = rof_prognostic) call t_stopf('irrigationneeded') @@ -610,7 +624,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! Dust mobilization (C. Zender's modified codes) call DustEmission(bounds_clump, & filter(nc)%num_nolakep, filter(nc)%nolakep, & - atm2lnd_inst, soilstate_inst, canopystate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, & + atm2lnd_inst, soilstate_inst, canopystate_inst, & + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & frictionvel_inst, dust_inst) ! Dust dry deposition (C. Zender's modified codes) @@ -635,7 +650,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call LakeTemperature(bounds_clump, & filter(nc)%num_lakec, filter(nc)%lakec, & filter(nc)%num_lakep, filter(nc)%lakep, & - solarabs_inst, soilstate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, ch4_inst, & + solarabs_inst, soilstate_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, water_inst%waterfluxbulk_inst, ch4_inst, & energyflux_inst, temperature_inst, lakestate_inst) call t_stopf('lakeTemp') @@ -645,14 +661,15 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call SoilTemperature(bounds_clump, & filter(nc)%num_urbanl , filter(nc)%urbanl, & filter(nc)%num_nolakec , filter(nc)%nolakec, & - atm2lnd_inst, urbanparams_inst, canopystate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, & + atm2lnd_inst, urbanparams_inst, canopystate_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, water_inst%waterfluxbulk_inst, & solarabs_inst, soilstate_inst, energyflux_inst, temperature_inst, urbantv_inst) ! The following is called immediately after SoilTemperature so that melted ice is ! converted back to solid ice as soon as possible call glacier_smb_inst%HandleIceMelt(bounds_clump, & filter(nc)%num_do_smb_c, filter(nc)%do_smb_c, & - waterstatebulk_inst, waterfluxbulk_inst) + water_inst%waterstatebulk_inst, water_inst%waterfluxbulk_inst) call t_stopf('soiltemperature') ! ============================================================================ @@ -665,8 +682,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_urbanp, filter(nc)%urbanp, & filter(nc)%num_nolakec, filter(nc)%nolakec, & filter(nc)%num_nolakep, filter(nc)%nolakep, & - atm2lnd_inst, solarabs_inst, temperature_inst, canopystate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, & - energyflux_inst, waterfluxbulk_inst) + atm2lnd_inst, solarabs_inst, temperature_inst, canopystate_inst, & + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + energyflux_inst, water_inst%waterfluxbulk_inst) call t_stopf('bgp2') ! ============================================================================ @@ -676,7 +694,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call t_startf('patch2col') call clm_drv_patch2col(bounds_clump, & filter(nc)%num_allc, filter(nc)%allc, filter(nc)%num_nolakec, filter(nc)%nolakec, & - energyflux_inst, waterfluxbulk_inst) + energyflux_inst, water_inst%waterfluxbulk_inst) call t_stopf('patch2col') ! ============================================================================ @@ -696,7 +714,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_nosnowc, filter(nc)%nosnowc, & clm_fates, & atm2lnd_inst, soilstate_inst, energyflux_inst, temperature_inst, & - waterfluxbulk_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, soilhydrology_inst, saturated_excess_runoff_inst, & + water_inst%waterfluxbulk_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, soilhydrology_inst, & + saturated_excess_runoff_inst, & infiltration_excess_runoff_inst, & aerosol_inst, canopystate_inst, soil_water_retention_curve, topo_inst) @@ -707,7 +727,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call glacier_smb_inst%ComputeSurfaceMassBalance(bounds_clump, & filter(nc)%num_allc, filter(nc)%allc, & filter(nc)%num_do_smb_c, filter(nc)%do_smb_c, & - glc2lnd_inst, waterstatebulk_inst, waterfluxbulk_inst) + glc2lnd_inst, water_inst%waterstatebulk_inst, water_inst%waterfluxbulk_inst) ! Calculate column-integrated aerosol masses, and ! mass concentrations for radiative calculations and output @@ -718,9 +738,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call AerosolMasses( bounds_clump, & num_on=filter(nc)%num_snowc, filter_on=filter(nc)%snowc, & num_off=filter(nc)%num_nosnowc, filter_off=filter(nc)%nosnowc, & - waterfluxbulk_inst=waterfluxbulk_inst, & - waterstatebulk_inst=waterstatebulk_inst, & - waterdiagnosticbulk_inst=waterdiagnosticbulk_inst, & + waterfluxbulk_inst = water_inst%waterfluxbulk_inst, & + waterstatebulk_inst = water_inst%waterstatebulk_inst, & + waterdiagnosticbulk_inst = water_inst%waterdiagnosticbulk_inst, & aerosol_inst=aerosol_inst) call t_stopf('hydro_without_drainage') @@ -738,7 +758,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_lakep, filter(nc)%lakep, & filter(nc)%num_lakesnowc, filter(nc)%lakesnowc, & filter(nc)%num_lakenosnowc, filter(nc)%lakenosnowc, & - atm2lnd_inst, temperature_inst, soilstate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterbalance_inst, waterfluxbulk_inst, & + atm2lnd_inst, temperature_inst, soilstate_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, water_inst%waterbalancebulk_inst, & + water_inst%waterfluxbulk_inst, & energyflux_inst, aerosol_inst, lakestate_inst, topo_inst) ! Calculate column-integrated aerosol masses, and @@ -750,9 +772,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call AerosolMasses(bounds_clump, & num_on=filter(nc)%num_lakesnowc, filter_on=filter(nc)%lakesnowc, & num_off=filter(nc)%num_lakenosnowc, filter_off=filter(nc)%lakenosnowc, & - waterfluxbulk_inst=waterfluxbulk_inst, & - waterstatebulk_inst=waterstatebulk_inst, & - waterdiagnosticbulk_inst=waterdiagnosticbulk_inst, & + waterfluxbulk_inst = water_inst%waterfluxbulk_inst, & + waterstatebulk_inst = water_inst%waterstatebulk_inst, & + waterdiagnosticbulk_inst = water_inst%waterdiagnosticbulk_inst, & aerosol_inst=aerosol_inst) ! Must be done here because must use a snow filter for lake columns @@ -760,7 +782,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call SnowAge_grain(bounds_clump, & filter(nc)%num_lakesnowc, filter(nc)%lakesnowc, & filter(nc)%num_lakenosnowc, filter(nc)%lakenosnowc, & - waterfluxbulk_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, temperature_inst, & + water_inst%waterfluxbulk_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, temperature_inst, & atm2lnd_inst) call t_stopf('hylake') @@ -774,7 +797,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro l = col%landunit(c) if (lun%urbpoi(l)) then ! Urban landunit use Bonan 1996 (LSM Technical Note) - waterdiagnosticbulk_inst%frac_sno_col(c) = min( waterdiagnosticbulk_inst%snow_depth_col(c)/0.05_r8, 1._r8) + water_inst%waterdiagnosticbulk_inst%frac_sno_col(c) = & + min( water_inst%waterdiagnosticbulk_inst%snow_depth_col(c)/0.05_r8, 1._r8) end if end do @@ -789,7 +813,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call SnowAge_grain(bounds_clump, & filter(nc)%num_snowc, filter(nc)%snowc, & filter(nc)%num_nosnowc, filter(nc)%nosnowc, & - waterfluxbulk_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, temperature_inst, & + water_inst%waterfluxbulk_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, temperature_inst, & atm2lnd_inst) call t_stopf('snow_init') @@ -814,7 +839,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro c14_soilbiogeochem_carbonflux_inst, c14_soilbiogeochem_carbonstate_inst, & soilbiogeochem_state_inst, & soilbiogeochem_nitrogenflux_inst, soilbiogeochem_nitrogenstate_inst, & - atm2lnd_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, & + atm2lnd_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, water_inst%waterfluxbulk_inst, & canopystate_inst, soilstate_inst, temperature_inst, crop_inst, ch4_inst, & photosyns_inst, saturated_excess_runoff_inst, energyflux_inst, & nutrient_competition_method, fireemis_inst) @@ -828,7 +854,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro if ((.not. use_cn) .and. (.not. use_fates) .and. (doalb)) then call t_startf('SatellitePhenology') call SatellitePhenology(bounds_clump, filter(nc)%num_nolakep, filter(nc)%nolakep, & - waterdiagnosticbulk_inst, canopystate_inst) + water_inst%waterdiagnosticbulk_inst, canopystate_inst) call t_stopf('SatellitePhenology') end if @@ -836,7 +862,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call t_startf('depvel') call depvel_compute(bounds_clump, & - atm2lnd_inst, canopystate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, frictionvel_inst, & + atm2lnd_inst, canopystate_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, frictionvel_inst, & photosyns_inst, drydepvel_inst) call t_stopf('depvel') @@ -852,7 +879,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_urbanc, filter(nc)%urbanc, & filter(nc)%num_do_smb_c, filter(nc)%do_smb_c, & atm2lnd_inst, glc2lnd_inst, temperature_inst, & - soilhydrology_inst, soilstate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterbalance_inst, waterfluxbulk_inst, & + soilhydrology_inst, soilstate_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, water_inst%waterbalancebulk_inst, & + water_inst%waterfluxbulk_inst, & glacier_smb_inst) call t_stopf('hydro2_drainage') @@ -865,7 +894,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_soilc, filter(nc)%soilc, & filter(nc)%num_soilp, filter(nc)%soilp, & doalb, crop_inst, & - waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, frictionvel_inst, canopystate_inst, & + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + water_inst%waterfluxbulk_inst, frictionvel_inst, canopystate_inst, & soilbiogeochem_carbonflux_inst, soilbiogeochem_carbonstate_inst, & c13_soilbiogeochem_carbonflux_inst, c13_soilbiogeochem_carbonstate_inst, & c14_soilbiogeochem_carbonflux_inst, c14_soilbiogeochem_carbonstate_inst, & @@ -882,7 +912,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call clm_fates%dynamics_driv( nc, bounds_clump, & atm2lnd_inst, soilstate_inst, temperature_inst, & - waterstatebulk_inst, waterdiagnosticbulk_inst, canopystate_inst, soilbiogeochem_carbonflux_inst,& + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + canopystate_inst, soilbiogeochem_carbonflux_inst,& frictionvel_inst) ! TODO(wjs, 2016-04-01) I think this setFilters call should be replaced by a @@ -905,7 +936,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro soilbiogeochem_nitrogenflux_inst, soilbiogeochem_nitrogenstate_inst, & c13_soilbiogeochem_carbonstate_inst, c13_soilbiogeochem_carbonflux_inst, & c14_soilbiogeochem_carbonstate_inst, c14_soilbiogeochem_carbonflux_inst, & - atm2lnd_inst, waterfluxbulk_inst, & + atm2lnd_inst, water_inst%waterfluxbulk_inst, & canopystate_inst, soilstate_inst, temperature_inst, crop_inst, ch4_inst) call EDBGCDynSummary(bounds_clump, & @@ -926,8 +957,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call t_startf('balchk') call BalanceCheck(bounds_clump, & - atm2lnd_inst, solarabs_inst, waterfluxbulk_inst, & - waterstatebulk_inst, waterdiagnosticbulk_inst, waterbalance_inst, & + atm2lnd_inst, solarabs_inst, water_inst%waterfluxbulk_inst, & + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + water_inst%waterbalancebulk_inst, & energyflux_inst, canopystate_inst) call t_stopf('balchk') @@ -969,7 +1001,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter(nc)%num_nolakec, filter(nc)%nolakec, & filter(nc)%num_soilp, filter(nc)%soilp, & atm2lnd_inst, lakestate_inst, canopystate_inst, soilstate_inst, soilhydrology_inst, & - temperature_inst, energyflux_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, & + temperature_inst, energyflux_inst, water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, water_inst%waterfluxbulk_inst, & soilbiogeochem_carbonflux_inst, & soilbiogeochem_nitrogenflux_inst, ch4_inst, lnd2atm_inst, & agnpp = agnpp_patch(bounds_clump%begp:bounds_clump%endp), & @@ -1000,7 +1033,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter_inactive_and_active(nc)%urbanp, & nextsw_cday, declinp1, & clm_fates, & - aerosol_inst, canopystate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, & + aerosol_inst, canopystate_inst, & + water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, & lakestate_inst, temperature_inst, surfalb_inst) call t_stopf('surfalb') @@ -1015,7 +1050,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro filter_inactive_and_active(nc)%urbanc, & filter_inactive_and_active(nc)%num_urbanp, & filter_inactive_and_active(nc)%urbanp, & - waterstatebulk_inst, waterdiagnosticbulk_inst, urbanparams_inst, & + water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, & + urbanparams_inst, & solarabs_inst, surfalb_inst) call t_stopf('urbalb') end if @@ -1041,7 +1078,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call lnd2atm(bounds_proc, & atm2lnd_inst, surfalb_inst, temperature_inst, frictionvel_inst, & - waterstatebulk_inst, waterdiagnosticbulk_inst, waterbalance_inst, waterfluxbulk_inst, energyflux_inst, & + water_inst%waterstatebulk_inst, water_inst%waterdiagnosticbulk_inst, & + water_inst%waterbalancebulk_inst, water_inst%waterfluxbulk_inst, & + energyflux_inst, & solarabs_inst, drydepvel_inst, & vocemis_inst, fireemis_inst, dust_inst, ch4_inst, glc_behavior, & lnd2atm_inst, & @@ -1059,7 +1098,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call get_clump_bounds(nc, bounds_clump) call lnd2glc_inst%update_lnd2glc(bounds_clump, & filter(nc)%num_do_smb_c, filter(nc)%do_smb_c, & - temperature_inst, waterfluxbulk_inst, topo_inst, & + temperature_inst, water_inst%waterfluxbulk_inst, topo_inst, & init=.false.) end do !$OMP END PARALLEL DO @@ -1092,7 +1131,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call canopystate_inst%UpdateAccVars(bounds_proc) - call waterfluxbulk_inst%UpdateAccVars(bounds_proc) + call water_inst%UpdateAccVars(bounds_proc) call energyflux_inst%UpdateAccVars(bounds_proc) @@ -1184,7 +1223,8 @@ subroutine clm_drv_init(bounds, & num_nolakec, filter_nolakec, & num_nolakep, filter_nolakep, & num_soilp , filter_soilp, & - canopystate_inst, waterstatebulk_inst, waterbalance_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, energyflux_inst) + canopystate_inst, waterstatebulk_inst, & + waterbalance_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, energyflux_inst) ! ! !DESCRIPTION: ! Initialization of clm driver variables needed from previous timestep @@ -1194,8 +1234,10 @@ subroutine clm_drv_init(bounds, & use shr_infnan_mod , only : nan => shr_infnan_nan, assignment(=) use clm_varpar , only : nlevsno use CanopyStateType , only : canopystate_type + use WaterBalanceType , only : waterbalance_type use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type use WaterFluxBulkType , only : waterfluxbulk_type + use WaterStateBulkType , only : waterstatebulk_type use EnergyFluxType , only : energyflux_type ! ! !ARGUMENTS: diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index f5e8adc406..1f35c4744c 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -586,7 +586,7 @@ subroutine initialize2( ) call atm2lnd_inst%initAccVars(bounds_proc) call temperature_inst%initAccVars(bounds_proc) - call waterfluxbulk_inst%initAccVars(bounds_proc) + call water_inst%initAccVars(bounds_proc) call energyflux_inst%initAccVars(bounds_proc) call canopystate_inst%initAccVars(bounds_proc) @@ -619,7 +619,7 @@ subroutine initialize2( ) if (nsrest == nsrStartup) then call t_startf('init_map2gc') call lnd2atm_minimal(bounds_proc, & - waterstatebulk_inst, surfalb_inst, energyflux_inst, lnd2atm_inst) + water_inst%waterstatebulk_inst, surfalb_inst, energyflux_inst, lnd2atm_inst) call t_stopf('init_map2gc') end if @@ -634,7 +634,7 @@ subroutine initialize2( ) call t_startf('init_lnd2glc') call lnd2glc_inst%update_lnd2glc(bounds_clump, & filter(nc)%num_do_smb_c, filter(nc)%do_smb_c, & - temperature_inst, waterfluxbulk_inst, topo_inst, & + temperature_inst, water_inst%waterfluxbulk_inst, topo_inst, & init=.true.) call t_stopf('init_lnd2glc') end do @@ -654,7 +654,9 @@ subroutine initialize2( ) ! -------------------------------------------------------------- if ( use_fates .and. .not.is_restart() .and. finidat == ' ') then - call clm_fates%init_coldstart(waterstatebulk_inst,waterdiagnosticbulk_inst, canopystate_inst,soilstate_inst, frictionvel_inst) + call clm_fates%init_coldstart(water_inst%waterstatebulk_inst, & + water_inst%waterdiagnosticbulk_inst, canopystate_inst, & + soilstate_inst, frictionvel_inst) end if ! topo_glc_mec was allocated in initialize1, but needed to be kept around through diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index dd4c16d6fd..43c3fae406 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -57,10 +57,7 @@ module clm_instMod use SurfaceRadiationMod , only : surfrad_type use SurfaceAlbedoType , only : surfalb_type use TemperatureType , only : temperature_type - use WaterFluxBulkType , only : waterfluxbulk_type - use WaterStateBulkType , only : waterstatebulk_type - use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type - use WaterBalanceType , only : waterbalance_type + use WaterType , only : water_type use UrbanParamsType , only : urbanparams_type use UrbanTimeVarType , only : urbantv_type use HumanIndexMod , only : humanindex_type @@ -114,10 +111,7 @@ module clm_instMod type(urbanparams_type) :: urbanparams_inst type(urbantv_type) :: urbantv_inst type(humanindex_type) :: humanindex_inst - type(waterfluxbulk_type) :: waterfluxbulk_inst - type(waterstatebulk_type) :: waterstatebulk_inst - type(waterdiagnosticbulk_type) :: waterdiagnosticbulk_inst - type(waterbalance_type) :: waterbalance_inst + type(water_type) :: water_inst type(atm2lnd_type) :: atm2lnd_inst type(glc2lnd_type) :: glc2lnd_inst type(lnd2atm_type) :: lnd2atm_inst @@ -281,18 +275,11 @@ subroutine clm_instInit(bounds) call soilstate_inst%Init(bounds) call SoilStateInitTimeConst(bounds, soilstate_inst, nlfilename) ! sets hydraulic and thermal soil properties - call waterstatebulk_inst%InitBulk(bounds, & - h2osno_col(begc:endc), & - soilstate_inst%watsat_col(begc:endc, 1:), & - temperature_inst%t_soisno_col(begc:endc, -nlevsno+1:) ) - - call waterdiagnosticbulk_inst%InitBulk(bounds, & - snow_depth_col(begc:endc), & - waterstatebulk_inst ) - - call waterbalance_inst%Init(bounds) - - call waterfluxbulk_inst%InitBulk(bounds) + call water_inst%Init(bounds, & + h2osno_col = h2osno_col(begc:endc), & + snow_depth_col = snow_depth_col(begc:endc), & + watsat_col = soilstate_inst%watsat_col(begc:endc, 1:), & + t_soisno_col = temperature_inst%t_soisno_col(begc:endc, -nlevsno+1:)) call glacier_smb_inst%Init(bounds) @@ -436,7 +423,7 @@ subroutine clm_instInit(bounds) call temperature_inst%InitAccBuffer(bounds) - call waterfluxbulk_inst%InitAccBuffer(bounds) + call water_inst%InitAccBuffer(bounds) call energyflux_inst%InitAccBuffer(bounds) @@ -502,18 +489,14 @@ subroutine clm_instRest(bounds, ncid, flag) call soilstate_inst%restart (bounds, ncid, flag=flag) - call waterfluxbulk_inst%restartBulk (bounds, ncid, flag=flag) - - call waterstatebulk_inst%restartBulk (bounds, ncid, flag=flag, & - watsat_col=soilstate_inst%watsat_col(bounds%begc:bounds%endc,:)) - - call waterdiagnosticbulk_inst%restartBulk (waterstatebulk_inst, bounds, ncid, flag=flag) + call water_inst%restart(bounds, ncid, flag=flag, & + watsat_col = soilstate_inst%watsat_col(bounds%begc:bounds%endc,:)) call irrigation_inst%restart (bounds, ncid, flag=flag) call aerosol_inst%restart (bounds, ncid, flag=flag, & - h2osoi_ice_col=waterstatebulk_inst%h2osoi_ice_col(bounds%begc:bounds%endc,:), & - h2osoi_liq_col=waterstatebulk_inst%h2osoi_liq_col(bounds%begc:bounds%endc,:)) + h2osoi_ice_col=water_inst%waterstatebulk_inst%h2osoi_ice_col(bounds%begc:bounds%endc,:), & + h2osoi_liq_col=water_inst%waterstatebulk_inst%h2osoi_liq_col(bounds%begc:bounds%endc,:)) call surfalb_inst%restart (bounds, ncid, flag=flag, & tlai_patch=canopystate_inst%tlai_patch(bounds%begp:bounds%endp), & @@ -559,7 +542,7 @@ subroutine clm_instRest(bounds, ncid, flag) if (use_fates) then call clm_fates%restart(bounds, ncid, flag=flag, & - waterdiagnosticbulk_inst=waterdiagnosticbulk_inst, & + waterdiagnosticbulk_inst=water_inst%waterdiagnosticbulk_inst, & canopystate_inst=canopystate_inst, & frictionvel_inst=frictionvel_inst)