Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snowy land #834

Merged
merged 2 commits into from
Oct 30, 2024
Merged

Snowy land #834

merged 2 commits into from
Oct 30, 2024

Conversation

kmdeck
Copy link
Member

@kmdeck kmdeck commented Oct 9, 2024

Purpose

Snowy land. Closes #630
Note: I will turn back on the long runs before merging, after incorporating review comments, to save running a lot on clima

ClimaLand with snow (note that the IC is zero snow) from global run:
water
bio
other

To-do

This PR is already so big!
Tutorial?
Tests?
Assess conservation in future PR, also addressing #847. Branch is kd/assess_conservation

Content

  1. This adds the snow/soil/canopy model, called "LandModel".
  2. It adds diagnostics for this model (this has to be done in this PR to see output in run_fluxnet or the global runs, since those use diagnostics)
  3. Creates a global run
  4. Uses the snowy land model in our fluxnet runs and in the conservation run

  • I have read and checked the items on the review checklist.

Copy link
Member

@juliasloan25 juliasloan25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was indeed a big PR! I left a lot of comments - happy to discuss in person if you have any questions

.gitignore Outdated Show resolved Hide resolved
experiments/integrated/fluxnet/US-Ha1/US-Ha1_simulation.jl Outdated Show resolved Hide resolved
experiments/integrated/fluxnet/US-MOz/US-MOz_simulation.jl Outdated Show resolved Hide resolved
src/diagnostics/default_diagnostics.jl Show resolved Hide resolved
src/diagnostics/define_diagnostics.jl Outdated Show resolved Hide resolved
src/integrated/soil_canopy_root_interactions.jl Outdated Show resolved Hide resolved
experiments/long_runs/snowy_land.jl Outdated Show resolved Hide resolved
regridder_type,
regridder_kwargs = (; extrapolation_bc,),
)
x = parent(vg_α)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to be x = Array(parent(vg_α)) for GPU compatibility. On GPU, wrapping in Array() would force the CuArray returned by parent to be converted to an Array, so that operations on it happen on the CPU instead of GPU. Without this, I think we would get a scalar indexing error in line 133

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we actually need the parent...let me check

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not using parent would be ideal :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do.... I think because if x is a Field, and we do x .> 0, it seems like it is trying to convert a field of booleans into a field of floats:

julia> typeof(x)
ClimaCore.Fields.Field{ClimaCore.DataLayouts.VIJFH{Float64, 15, 2, CUDA.CuArray{Float64, 5, CUDA.DeviceMemory}}, ClimaCore.Spaces.ExtrudedFiniteDifferenceSpace{ClimaCore.Grids.ExtrudedFiniteDifferenceGrid{ClimaCore.Grids.SpectralElementGrid2D{ClimaCore.Topologies.Topology2D{ClimaComms.SingletonCommsContext{ClimaComms.CUDADevice}, ClimaCore.Meshes.EquiangularCubedSphere{ClimaCore.Domains.SphereDomain{Float64}, ClimaCore.Meshes.NormalizedBilinearMap}, CartesianIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}, LinearIndices{3, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}}}, CUDA.CuArray{Tuple{Int64, Int64, Int64, Int64, Bool}, 1, CUDA.DeviceMemory}, Vector{Tuple{Int64, Int64, Int64, Int64, Bool}}, CUDA.CuArray{Tuple{Int64, Int64}, 1, CUDA.DeviceMemory}, CUDA.CuArray{Int64, 1, CUDA.DeviceMemory}, CUDA.CuArray{Tuple{Bool, Int64, Int64}, 1, CUDA.DeviceMemory}, CUDA.CuArray{Int64, 1, CUDA.DeviceMemory}, CUDA.CuArray{Int64, 1, CUDA.DeviceMemory}, @NamedTuple{}, CUDA.CuArray{Tuple{Int64, Int64}, 1, CUDA.DeviceMemory}}, ClimaCore.Quadratures.GLL{2}, ClimaCore.Geometry.SphericalGlobalGeometry{Float64}, ClimaCore.DataLayouts.IJFH{ClimaCore.Geometry.LocalGeometry{(1, 2), ClimaCore.Geometry.LatLongPoint{Float64}, Float64, StaticArraysCore.SMatrix{2, 2, Float64, 4}}, 2, CUDA.CuArray{Float64, 4, CUDA.DeviceMemory}}, ClimaCore.DataLayouts.IJFH{Float64, 2, CUDA.CuArray{Float64, 4, CUDA.DeviceMemory}}, ClimaCore.DataLayouts.IFH{ClimaCore.Geometry.SurfaceGeometry{Float64, ClimaCore.Geometry.UVVector{Float64}}, 2, CUDA.CuArray{Float64, 3, CUDA.DeviceMemory}}, @NamedTuple{}}, FiniteDifferenceGrid{IntervalTopology{ClimaComms.SingletonCommsContext{ClimaComms.CUDADevice}, ClimaCore.Meshes.IntervalMesh{ClimaCore.Domains.IntervalDomain{ClimaCore.Geometry.ZPoint{Float64}, Tuple{Symbol, Symbol}}, Vector{ClimaCore.Geometry.ZPoint{Float64}}}, @NamedTuple{bottom::Int64, top::Int64}}, ClimaCore.Geometry.CartesianGlobalGeometry, ClimaCore.DataLayouts.VF{ClimaCore.Geometry.LocalGeometry{(3,), ClimaCore.Geometry.ZPoint{Float64}, Float64, StaticArraysCore.SMatrix{1, 1, Float64, 1}}, 15, CUDA.CuArray{Float64, 2, CUDA.DeviceMemory}}, ClimaCore.DataLayouts.VF{ClimaCore.Geometry.LocalGeometry{(3,), ClimaCore.Geometry.ZPoint{Float64}, Float64, StaticArraysCore.SMatrix{1, 1, Float64, 1}}, 16, CUDA.CuArray{Float64, 2, CUDA.DeviceMemory}}}, ClimaCore.Grids.Flat, ClimaCore.Geometry.ShallowSphericalGlobalGeometry{Float64}, ClimaCore.DataLayouts.VIJFH{ClimaCore.Geometry.LocalGeometry{(1, 2, 3), ClimaCore.Geometry.LatLongZPoint{Float64}, Float64, StaticArraysCore.SMatrix{3, 3, Float64, 9}}, 15, 2, CUDA.CuArray{Float64, 5, CUDA.DeviceMemory}}, ClimaCore.DataLayouts.VIJFH{ClimaCore.Geometry.LocalGeometry{(1, 2, 3), ClimaCore.Geometry.LatLongZPoint{Float64}, Float64, StaticArraysCore.SMatrix{3, 3, Float64, 9}}, 16, 2, CUDA.CuArray{Float64, 5, CUDA.DeviceMemory}}}, ClimaCore.Grids.CellCenter}}

julia> μ = mean(x[x .> 0]);
ERROR: Struct type Bool cannot be represented using base type Float64
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] macro expansion
    @ ~/.julia/packages/ClimaCore/SvZXu/src/DataLayouts/struct.jl:34 [inlined]
  [3] check_basetype(::Type{Float64}, ::Type{Bool})
    @ ClimaCore.DataLayouts ~/.julia/packages/ClimaCore/SvZXu/src/DataLayouts/struct.jl:33
  [4] (ClimaCore.DataLayouts.VIJFH{Bool, 15, 2})(array::CUDA.CuArray{Float64, 5, CUDA.DeviceMemory})
    @ ClimaCore.DataLayouts ~/.julia/packages/ClimaCore/SvZXu/src/DataLayouts/DataLayouts.jl:918
  [5] similar(bc::Base.Broadcast.Broadcasted{ClimaCore.DataLayouts.VIJFHStyle{…}, Nothing, typeof(>), Tuple{…}}, ::Type{Bool}, ::Val{15})
    @ ClimaCore.DataLayouts ~/.julia/packages/ClimaCore/SvZXu/src/DataLayouts/broadcast.jl:377
  [6] similar(bc::Base.Broadcast.Broadcasted{ClimaCore.DataLayouts.VIJFHStyle{…}, Nothing, typeof(>), Tuple{…}}, ::Type{Bool})
    @ ClimaCore.DataLayouts ~/.julia/packages/ClimaCore/SvZXu/src/DataLayouts/broadcast.jl:364
  [7] similar(bc::Base.Broadcast.Broadcasted{…}, ::Type{…})
    @ ClimaCore.Fields ~/.julia/packages/ClimaCore/SvZXu/src/Fields/broadcast.jl:142
  [8] copy(bc::Base.Broadcast.Broadcasted{ClimaCore.Fields.FieldStyle{…}, ClimaCore.Spaces.ExtrudedFiniteDifferenceSpace{…}, typeof(>), Tuple{…}})
    @ ClimaCore.Fields ~/.julia/packages/ClimaCore/SvZXu/src/Fields/broadcast.jl:95
  [9] materialize(bc::Base.Broadcast.Broadcasted{ClimaCore.Fields.FieldStyle{…}, Nothing, typeof(>), Tuple{…}})
    @ Base.Broadcast ./broadcast.jl:867
 [10] top-level scope
    @ REPL[54]:1
Some type information was truncated. Use `show(err)` to see complete types.

but, that said, these scripts are running on GPU, so for some reason the parent call is OK:

julia> x = parent(vg_α);

julia> μ = mean(x[x .> 0]);

julia> typeof(x)
CUDA.CuArray{Float64, 5, CUDA.DeviceMemory}

so I will leave this as is

experiments/long_runs/snowy_land.jl Outdated Show resolved Hide resolved
experiments/long_runs/snowy_land.jl Outdated Show resolved Hide resolved
@juliasloan25
Copy link
Member

It looks like the Niwot Fluxnet experiment is unstable :( - it failed with

1m�[1mERROR: �[22m�[39mLoadError: DomainError with -7.839898692779407e9:
Exponentiation yielding a complex result requires a complex argument.
Replace x^y with (x+0im)^y, Complex(x)^y, or similar.
...

Copy link
Member

@AlexisRenchon AlexisRenchon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am very excited for this PR! Amazing work, thank you Kat!

.buildkite/longruns_gpu/pipeline.yml Outdated Show resolved Hide resolved
experiments/integrated/fluxnet/US-NR1/US-NR1_simulation.jl Outdated Show resolved Hide resolved
experiments/integrated/fluxnet/run_fluxnet.jl Show resolved Hide resolved
experiments/integrated/fluxnet/run_fluxnet.jl Show resolved Hide resolved
src/diagnostics/default_diagnostics.jl Show resolved Hide resolved
src/diagnostics/define_diagnostics.jl Outdated Show resolved Hide resolved
src/diagnostics/land_compute_methods.jl Show resolved Hide resolved
src/standalone/Snow/snow_parameterizations.jl Show resolved Hide resolved
@juliasloan25
Copy link
Member

I think the GPU bucket failure might be the same issue we saw in #739. I added a reproducer in CliMA/ClimaCore.jl#2062, but still in the process of debugging

The only change I see in src that might affect the bucket is here. I suggested a change - maybe that will help?

@kmdeck kmdeck force-pushed the kd/snowy_land branch 2 times, most recently from f9473d9 to 6dc381f Compare October 30, 2024 17:08
@kmdeck kmdeck merged commit 703d11c into main Oct 30, 2024
17 of 18 checks passed
@kmdeck kmdeck deleted the kd/snowy_land branch October 30, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

O2.1.2 Integrate snow model with soil and canopy model Change how we handle radiation under a canopy
3 participants