diff --git a/src/snow/snow.jl b/src/snow/snow.jl index 89dea579c..b0d6f47fa 100644 --- a/src/snow/snow.jl +++ b/src/snow/snow.jl @@ -15,20 +15,13 @@ abstract type AbstractSnowModel{T} end end "Initialize snow model variables" -function SnowVariables( - n; - snow_storage::Vector{T} = fill(0.0, n), - snow_water::Vector{T} = fill(0.0, n), - swe::Vector{T} = fill(mv, n), - snow_melt::Vector{T} = fill(mv, n), - runoff::Vector{T} = fill(mv, n), -) where {T} +function SnowVariables(T::Type{<:AbstractFloat}, n::Int) return SnowVariables{T}(; - snow_storage = snow_storage, - snow_water = snow_water, - swe = swe, - runoff = runoff, - snow_melt = snow_melt, + snow_storage = fill(0.0, n), + snow_water = fill(0.0, n), + swe = fill(mv, n), + runoff = fill(mv, n), + snow_melt = fill(mv, n), ) end @@ -43,16 +36,11 @@ end end "Initialize snow model boundary conditions" -function SnowBC( - n; - effective_precip::Vector{T} = fill(mv, n), - snow_precip::Vector{T} = fill(mv, n), - liquid_precip::Vector{T} = fill(mv, n), -) where {T} +function SnowBC(T::Type{<:AbstractFloat}, n::Int) return SnowBC{T}(; - effective_precip = effective_precip, - snow_precip = snow_precip, - liquid_precip = liquid_precip, + effective_precip = fill(mv, n), + snow_precip = fill(mv, n), + liquid_precip = fill(mv, n), ) end @@ -131,8 +119,8 @@ end function SnowHbvModel(nc, config, inds, dt) n = length(inds) params = SnowHbvParameters(nc, config, inds, dt) - vars = SnowVariables(n) - bc = SnowBC(n) + vars = SnowVariables(Float, n) + bc = SnowBC(Float, n) model = SnowHbvModel(; boundary_conditions = bc, parameters = params, variables = vars) return model end diff --git a/src/soil/soil.jl b/src/soil/soil.jl index 4317b40c9..e07985b63 100644 --- a/src/soil/soil.jl +++ b/src/soil/soil.jl @@ -102,10 +102,10 @@ function SbmSoilVariables(n, parameters) vars = SbmSoilVariables(; ustorelayerdepth = zero(act_thickl), ustorecapacity = soilwatercapacity .- satwaterdepth, - ustorelayerthickness = ustorelayerthickness, - satwaterdepth = satwaterdepth, - zi = zi, - n_unsatlayers = n_unsatlayers, + ustorelayerthickness, + satwaterdepth, + zi, + n_unsatlayers, transpiration = fill(mv, n), h3 = fill(mv, n), ae_ustore = fill(mv, n), @@ -604,36 +604,36 @@ function SbmSoilParameters(nc, config, vegetation_parameter_set, inds, dt) n = length(inds) sbm_params = SbmSoilParameters(; - maxlayers = maxlayers, - nlayers = nlayers, - soilwatercapacity = soilwatercapacity, - theta_s = theta_s, - theta_r = theta_r, + maxlayers, + nlayers, + soilwatercapacity, + theta_s, + theta_r, kvfrac = svectorscopy(kvfrac, Val{maxlayers}()), - hb = hb, - h1 = h1, - h2 = h2, - h3_high = h3_high, - h3_low = h3_low, - h4 = h4, - alpha_h1 = alpha_h1, - soilthickness = soilthickness, - act_thickl = act_thickl, - sumlayers = sumlayers, - infiltcappath = infiltcappath, - infiltcapsoil = infiltcapsoil, - maxleakage = maxleakage, - pathfrac = pathfrac, - rootdistpar = rootdistpar, + hb, + h1, + h2, + h3_high, + h3_low, + h4, + alpha_h1, + soilthickness, + act_thickl, + sumlayers, + infiltcappath, + infiltcapsoil, + maxleakage, + pathfrac, + rootdistpar, rootfraction = svectorscopy(rootfraction, Val{maxlayers}()), - cap_hmax = cap_hmax, - cap_n = cap_n, + cap_hmax, + cap_n, c = svectorscopy(c, Val{maxlayers}()), - w_soil = w_soil, - cf_soil = cf_soil, + w_soil, + cf_soil, soil_fraction = fill(mv, n), - kv_profile = kv_profile, - vegetation_parameter_set = vegetation_parameter_set, + kv_profile, + vegetation_parameter_set, ) return sbm_params end diff --git a/src/surfacewater/runoff.jl b/src/surfacewater/runoff.jl index 1bb3fbca9..900546e03 100644 --- a/src/surfacewater/runoff.jl +++ b/src/surfacewater/runoff.jl @@ -15,20 +15,13 @@ abstract type AbstractRunoffModel{T} end end "Initialize open water runoff model variables" -function OpenWaterRunoffVariables( - n; - runoff_river::Vector{T} = fill(mv, n), - runoff_land::Vector{T} = fill(mv, n), - ae_openw_l::Vector{T} = fill(mv, n), - ae_openw_r::Vector{T} = fill(mv, n), - net_runoff_river::Vector{T} = fill(mv, n), -) where {T} +function OpenWaterRunoffVariables(T::Type{<:AbstractFloat}, n::Int) return OpenWaterRunoffVariables{T}(; - runoff_river = runoff_river, - runoff_land = runoff_land, - ae_openw_l = ae_openw_l, - ae_openw_r = ae_openw_r, - net_runoff_river = net_runoff_river, + runoff_river = fill(mv, n), + runoff_land = fill(mv, n), + ae_openw_l = fill(mv, n), + ae_openw_r = fill(mv, n), + net_runoff_river = fill(mv, n), ) end @@ -64,16 +57,11 @@ end end "Initialize open water runoff boundary conditions" -function OpenWaterRunoffBC( - n; - water_flux_surface::Vector{T} = fill(mv, n), - waterlevel_land::Vector{T} = fill(mv, n), - waterlevel_river::Vector{T} = zeros(Float, n), # set to zero to account for cells outside river domain -) where {T} +function OpenWaterRunoffBC(T::Type{<:AbstractFloat}, n::Int) return OpenWaterRunoffBC{T}(; - water_flux_surface = water_flux_surface, - waterlevel_land = waterlevel_land, - waterlevel_river = waterlevel_river, + water_flux_surface = fill(mv, n), + waterlevel_land = fill(mv, n), + waterlevel_river = zeros(T, n), ) end @@ -87,8 +75,8 @@ end "Initialize open water runoff model" function OpenWaterRunoff(nc, config, inds, riverfrac) n = length(riverfrac) - vars = OpenWaterRunoffVariables(n) - bc = OpenWaterRunoffBC(n) + vars = OpenWaterRunoffVariables(Float, n) + bc = OpenWaterRunoffBC(Float, n) params = OpenWaterRunoffParameters(nc, config, inds, riverfrac) model = OpenWaterRunoff(; boundary_conditions = bc, parameters = params, variables = vars) diff --git a/src/vegetation/canopy.jl b/src/vegetation/canopy.jl index 232723217..6053fcd85 100644 --- a/src/vegetation/canopy.jl +++ b/src/vegetation/canopy.jl @@ -15,20 +15,13 @@ abstract type AbstractInterceptionModel{T} end end "Initialize interception model variables" -function InterceptionVariables( - n; - canopy_potevap::Vector{T} = fill(mv, n), - interception_rate::Vector{T} = fill(mv, n), - canopy_storage::Vector{T} = fill(0.0, n), - stemflow::Vector{T} = fill(mv, n), - throughfall::Vector{T} = fill(mv, n), -) where {T} +function InterceptionVariables(T::Type{<:AbstractFloat}, n::Int) return InterceptionVariables(; - canopy_potevap = canopy_potevap, - interception_rate = interception_rate, - canopy_storage = canopy_storage, - stemflow = stemflow, - throughfall = throughfall, + canopy_potevap = fill(mv, n), + interception_rate = fill(mv, n), + canopy_storage = zeros(T, n), + stemflow = fill(mv, n), + throughfall = fill(mv, n), ) end @@ -58,7 +51,7 @@ function GashInterceptionModel(nc, config, inds, vegetation_parameter_set) n = length(inds) params = GashParameters(; e_r = e_r, vegetation_parameter_set = vegetation_parameter_set) - vars = InterceptionVariables(n) + vars = InterceptionVariables(Float, n) model = GashInterceptionModel(; parameters = params, variables = vars) return model end