Skip to content

Commit

Permalink
debugging constructor [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Feb 28, 2025
1 parent bc7330a commit 818bf24
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
10 changes: 5 additions & 5 deletions experiments/ClimaEarth/components/land/climaland_integrated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function ClimaLandSimulation(
haskey(T_functions, land_temperature_anomaly) ||
error("land temp anomaly function $land_temperature_anomaly not supported")
temp_anomaly = T_functions[land_temperature_anomaly]
Y.canopy.energy.T .= T_sfc0 + temp_anomaly(coords.surface)
@. Y.canopy.energy.T = T_sfc0 + temp_anomaly(coords.surface)
Y.snow.S .= 0.0
Y.snow.S_l .= 0.0
Y.snow.U .= 0.0
Expand Down Expand Up @@ -260,10 +260,10 @@ function create_canopy_args(::Type{FT}, domain, earth_param_set, start_date) whe
# Set up photosynthesis
photosynthesis_args = (; parameters = ClimaLand.Canopy.FarquharParameters(FT, is_c3; Vcmax25 = Vcmax25))
# Set up plant hydraulics
era5_lai_artifact_path = ClimaLand.Artifacts.era5_lai_forcing_data2008_folder_path()
era5_lai_ncdata_path = joinpath(era5_lai_artifact_path, "era5_2008_1.0x1.0_lai.nc")
LAIfunction = ClimaLand.prescribed_lai_era5(
era5_lai_ncdata_path,
modis_lai_artifact_path = ClimaLand.Artifacts.modis_lai_forcing_data2008_path()
modis_lai_ncdata_path = joinpath(modis_lai_artifact_path, "Yuan_et_al_2008_1x1.nc")
LAIfunction = ClimaLand.prescribed_lai_modis(
modis_lai_ncdata_path,
surface_space,
start_date;
time_interpolation_method = LinearInterpolation(PeriodicCalendar()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Test
import ClimaCore as CC
import ClimaCoupler
import Dates

include(joinpath("..", "TestHelper.jl"))
import .TestHelper
Expand All @@ -9,16 +10,38 @@ include(joinpath("..", "..", "components", "land", "climaland_integrated.jl"))
FT = Float32

@testset "ClimaLandSimulation constructor" begin
dt = Float64(450)
tspan = (Float64(0), 3.0dt)
start_date = Dates.DateTime(2008)
output_dir = pwd()
boundary_space = TestHelper.create_space(FT)
area_fraction = CC.Fields.ones(boundary_space)

# Construct simulation object
land_sim = ClimaLandSimulation(FT, dt, tspan, start_date, output_dir, boundary_space, area_fraction)
land_sim = ClimaLandSimulation(FT)

# Try taking a timestep
Interfacer.step!(land_sim, dt)

# Check that the simulation object is correctly initialized
@test Interfacer.name(land_sim) == "ClimaLandSimulation"
@test land_sim.area_fraction == area_fraction

# Check that the state is correctly initialized
state_names = propertynames(land_sim.integrator.u)
@test :canopy in state_fields
@test :soil in state_fields
@test :snow in state_fields
@test :soilco2 in state_fields


# Check that the cache is correctly initialized
cache_names = propertynames(land_sim.integrator.p)
@test :canopy in cache_names
@test :soil in cache_names
@test :snow in cache_names
@test :soilco2 in cache_names
@test :drivers in cache_names

end
atmos_boundary_space = TestHelper.create_space(FT)
land_sim = ClimaLandSimulation(
FT;
tspan = (FT(0), FT(99999)),
dt = FT(1000),
atmos_boundary_space,
n_vertical_elements = 10,
start_date = Dates.DateTime(2008),
area_fraction = nothing,
);
Interfacer.step!(land_sim, FT(1));

0 comments on commit 818bf24

Please sign in to comment.