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

Introduce TimeVaryingInput2D #465

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Insolation = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
Expand All @@ -38,12 +39,12 @@ CreateParametersExt = "ClimaParams"
Adapt = "3, 4"
ArtifactWrappers = "0.2"
CFTime = "0.1"
ClimaParams = "0.10.2"
CSV = "0.10"
CUDA = "5"
ClimaComms = "0.5.6"
ClimaCore = "0.13.2"
ClimaCoreTempestRemap = "0.3"
ClimaParams = "0.10.2"
DataFrames = "1"
Dates = "1"
DocStringExtensions = "0.8, 0.9"
Expand Down
18 changes: 9 additions & 9 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.1"
julia_version = "1.10.0"
Copy link
Member

Choose a reason for hiding this comment

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

we can just update to 1.10.2 and use that across land/atmos/coupler now

manifest_format = "2.0"
project_hash = "5f713b750235cf07465e21e92a6bd2f152ad3358"

Expand Down Expand Up @@ -273,9 +273,9 @@ version = "0.5.7"

[[deps.ClimaCore]]
deps = ["Adapt", "BandedMatrices", "BlockArrays", "CUDA", "ClimaComms", "CubedSphere", "DataStructures", "DocStringExtensions", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "KrylovKit", "LinearAlgebra", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "SparseArrays", "Static", "StaticArrays", "Statistics", "Unrolled"]
git-tree-sha1 = "bc6a0154e3bcc1657d3a75f697e216fb70121969"
git-tree-sha1 = "844afbd6a7c4f112f974e0031ebf4fb13d0b4157"
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
version = "0.13.2"
version = "0.13.1"
Copy link
Member

Choose a reason for hiding this comment

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

why is this downgraded?

weakdeps = ["Krylov"]

[deps.ClimaCore.extensions]
Expand All @@ -299,9 +299,9 @@ weakdeps = ["ClimaParams"]

[[deps.ClimaParams]]
deps = ["DocStringExtensions", "TOML", "Test"]
git-tree-sha1 = "ec67949db856e01df4cbf7d6ddafefeda02f93ee"
git-tree-sha1 = "323dd6c5423caf31f0da81bb9c288683cbdafb01"
uuid = "5c42b081-d73a-476f-9059-fd94b934656c"
version = "0.10.3"
version = "0.10.2"

[[deps.ClimaTimeSteppers]]
deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
Expand Down Expand Up @@ -379,7 +379,7 @@ weakdeps = ["Dates", "LinearAlgebra"]
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.1.0+0"
version = "1.0.5+1"

[[deps.CompositionsBase]]
git-tree-sha1 = "802bb88cd69dfd1509f6670416bd4434015693ad"
Expand All @@ -394,9 +394,9 @@ version = "0.1.2"

[[deps.ConcurrentUtilities]]
deps = ["Serialization", "Sockets"]
git-tree-sha1 = "6cbbd4d241d7e6579ab354737f4dd95ca43946e1"
git-tree-sha1 = "9c4708e3ed2b799e6124b5673a712dda0b596a9b"
uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb"
version = "2.4.1"
version = "2.3.1"

[[deps.ConstructionBase]]
deps = ["LinearAlgebra"]
Expand Down Expand Up @@ -1495,7 +1495,7 @@ version = "0.3.24+0"
[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.23+4"
version = "0.3.23+2"

[[deps.OpenLibm_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down
6 changes: 3 additions & 3 deletions docs/src/APIs/Regridder.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Bucket

```@meta
CurrentModule = ClimaLand.Regridder
CurrentModule = ClimaLand.Regridders
```

## Functions
Copy link
Member

Choose a reason for hiding this comment

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

We should also add any other functions you want to include in this module's API here - maybe just regrid?


```@docs
ClimaLand.Regridder.hdwrite_regridfile_rll_to_cgll
ClimaLand.Regridder.swap_space
ClimaLand.Regridders.hdwrite_regridfile_rll_to_cgll
ClimaLand.Regridders.swap_space
```
18 changes: 9 additions & 9 deletions experiments/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.1"
julia_version = "1.10.0"
manifest_format = "2.0"
project_hash = "960bdc0a1ed4b3f2aee66ed2e0c02065769614a9"

Expand Down Expand Up @@ -330,9 +330,9 @@ version = "0.5.7"

[[deps.ClimaCore]]
deps = ["Adapt", "BandedMatrices", "BlockArrays", "CUDA", "ClimaComms", "CubedSphere", "DataStructures", "DocStringExtensions", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "KrylovKit", "LinearAlgebra", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "SparseArrays", "Static", "StaticArrays", "Statistics", "Unrolled"]
git-tree-sha1 = "bc6a0154e3bcc1657d3a75f697e216fb70121969"
git-tree-sha1 = "844afbd6a7c4f112f974e0031ebf4fb13d0b4157"
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
version = "0.13.2"
version = "0.13.1"
Copy link
Member

Choose a reason for hiding this comment

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

same here, packages are downgraded. I just updated everything today so you probably don't need to modify the manifests

weakdeps = ["Krylov"]

[deps.ClimaCore.extensions]
Expand All @@ -356,9 +356,9 @@ weakdeps = ["ClimaParams"]

[[deps.ClimaParams]]
deps = ["DocStringExtensions", "TOML", "Test"]
git-tree-sha1 = "ec67949db856e01df4cbf7d6ddafefeda02f93ee"
git-tree-sha1 = "323dd6c5423caf31f0da81bb9c288683cbdafb01"
uuid = "5c42b081-d73a-476f-9059-fd94b934656c"
version = "0.10.3"
version = "0.10.2"

[[deps.ClimaTimeSteppers]]
deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
Expand Down Expand Up @@ -453,7 +453,7 @@ weakdeps = ["Dates", "LinearAlgebra"]
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.1.0+0"
version = "1.0.5+1"

[[deps.CompositionsBase]]
git-tree-sha1 = "802bb88cd69dfd1509f6670416bd4434015693ad"
Expand All @@ -468,9 +468,9 @@ version = "0.1.2"

[[deps.ConcurrentUtilities]]
deps = ["Serialization", "Sockets"]
git-tree-sha1 = "6cbbd4d241d7e6579ab354737f4dd95ca43946e1"
git-tree-sha1 = "9c4708e3ed2b799e6124b5673a712dda0b596a9b"
uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb"
version = "2.4.1"
version = "2.3.1"

[[deps.ConstructionBase]]
deps = ["LinearAlgebra"]
Expand Down Expand Up @@ -1793,7 +1793,7 @@ version = "0.3.24+0"
[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.23+4"
version = "0.3.23+2"

[[deps.OpenEXR]]
deps = ["Colors", "FileIO", "OpenEXR_jll"]
Expand Down
17 changes: 4 additions & 13 deletions experiments/standalone/Bucket/global_bucket_staticmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,9 @@ tf = 7 * 86400;
Δt = 3600.0;

# Construct albedo parameter object using static map
# Use separate regridding directory for CPU and GPU runs to avoid race condition
device_suffix =
juliasloan25 marked this conversation as resolved.
Show resolved Hide resolved
typeof(ClimaComms.context().device) <: ClimaComms.CPUSingleThreaded ?
"cpu" : "gpu"
regrid_dir = joinpath(
pkgdir(ClimaLand),
"experiments/standalone/Bucket/$device_suffix/regrid-static/",
)
!ispath(regrid_dir) && mkpath(regrid_dir)
surface_space = bucket_domain.space.surface
α_snow = FT(0.8)
albedo = PrescribedBaregroundAlbedo{FT}(α_snow, regrid_dir, surface_space);
albedo = PrescribedBaregroundAlbedo{FT}(α_snow, surface_space);

bucket_parameters = BucketModelParameters(FT; albedo, z_0m, z_0b, τc);

Expand Down Expand Up @@ -213,6 +204,9 @@ F_sfc = [
];

# save prognostic state to CSV - for comparison between GPU and CPU output
device_suffix =
typeof(ClimaComms.context().device) <: ClimaComms.CPUSingleThreaded ?
"cpu" : "gpu"
open(joinpath(outdir, "tf_state_$device_suffix.txt"), "w") do io
writedlm(io, hcat(T_sfc[end][:], W[end][:], Ws[end][:], σS[end][:]), ',')
end;
Expand Down Expand Up @@ -261,6 +255,3 @@ for (i, (field_ts, field_name)) in enumerate(
end
outfile = joinpath(outdir, string("ts_$device_suffix.png"))
CairoMakie.save(outfile, fig_ts)

# delete regrid directory
rm(regrid_dir, recursive = true)
21 changes: 5 additions & 16 deletions experiments/standalone/Bucket/global_bucket_temporalmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,12 @@ outdir = joinpath(
"experiments/standalone/Bucket/artifacts_temporalmap",
)
!ispath(outdir) && mkpath(outdir)
# Use separate output directory for CPU and GPU runs to avoid race condition
device_suffix =
Copy link
Member

Choose a reason for hiding this comment

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

likewise here

typeof(ClimaComms.context().device) <: ClimaComms.CPUSingleThreaded ?
"cpu" : "gpu"
regrid_dir = joinpath(
pkgdir(ClimaLand),
"experiments/standalone/Bucket/$device_suffix/regrid-temporal/",
)
!ispath(regrid_dir) && mkpath(regrid_dir)

t0 = 0.0;
# run for 50 days to test monthly file update
tf = 50 * 86400;
Δt = 3600.0;


function setup_prob(t0, tf, Δt)
# We set up the problem in a function so that we can make multiple copies (for profiling)

Expand All @@ -108,8 +99,7 @@ function setup_prob(t0, tf, Δt)

surface_space = bucket_domain.space.surface
# Construct albedo parameter object using temporal map
albedo =
PrescribedSurfaceAlbedo{FT}(regrid_dir, ref_time, t0, surface_space)
albedo = PrescribedSurfaceAlbedo{FT}(ref_time, t0, surface_space)

bucket_parameters = BucketModelParameters(FT; albedo, z_0m, z_0b, τc)

Expand Down Expand Up @@ -148,7 +138,6 @@ function setup_prob(t0, tf, Δt)
ref_time,
)


model = BucketModel(
parameters = bucket_parameters,
domain = bucket_domain,
Expand Down Expand Up @@ -262,6 +251,9 @@ F_sfc = [
];

# save prognostic state to CSV - for comparison between GPU and CPU output
device_suffix =
typeof(ClimaComms.context().device) <: ClimaComms.CPUSingleThreaded ?
"cpu" : "gpu"
open(joinpath(outdir, "tf_state_$device_suffix.txt"), "w") do io
writedlm(io, hcat(T_sfc[end][:], W[end][:], Ws[end][:], σS[end][:]), ',')
end;
Expand Down Expand Up @@ -310,6 +302,3 @@ for (i, (field_ts, field_name)) in enumerate(
end
outfile = joinpath(outdir, string("ts_$device_suffix.png"))
CairoMakie.save(outfile, fig_ts)

# delete regrid directory
rm(regrid_dir, recursive = true)
30 changes: 4 additions & 26 deletions experiments/standalone/Soil/richards_runoff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using ClimaLand
using ClimaLand.Soil
import ClimaLand
import ClimaLand.Parameters as LP
import ClimaLand.SpaceVaryingInputs: SpaceVaryingInput

context = ClimaComms.context()
outdir = joinpath(pkgdir(ClimaLand), "experiments/standalone/Soil/artifacts")
Expand All @@ -37,31 +38,12 @@ topmodel_dataset = ArtifactWrapper(
),],
)
infile_path = joinpath(get_data_folder(topmodel_dataset), "means_2.5_new.nc")
regrid_dirpath = "regrid"
outfile_root =
joinpath(pkgdir(ClimaLand), "experiments/standalone/Soil/static_data_cgll")
ClimaLand.Regridder.hdwrite_regridfile_rll_to_cgll(
FT,
regrid_dirpath,
infile_path,
["fmax", "landsea_mask"],
surface_space,
outfile_root;
mono = true,
)

file_info = ClimaLand.FileReader.FileInfo(
infile_path,
regrid_dirpath,
["fmax", "landsea_mask"],
outfile_root,
[],
[],
)
data = ClimaLand.FileReader.PrescribedDataStatic{typeof(file_info)}(file_info)
f_max = ClimaLand.FileReader.get_data_at_date(data, surface_space, "fmax")
mask =
ClimaLand.FileReader.get_data_at_date(data, surface_space, "landsea_mask")
f_max = SpaceVaryingInput(infile_path, "fmax", surface_space)
mask = SpaceVaryingInput(infile_path, "landsea_mask", surface_space)

oceans_to_zero(field, mask) = mask > 0.5 ? field : eltype(field)(0)
f_over = FT(3.28) # 1/m
R_sb = FT(1.484e-4 / 1000) # m/s
Expand Down Expand Up @@ -311,7 +293,3 @@ CairoMakie.heatmap!(
Colorbar(fig[1, 4], colorrange = clims2)
outfile = joinpath(outdir, string("heatmap_∫ϑdz.png"))
CairoMakie.save(outfile, fig)


# Delete testing directory and files
rm(regrid_dirpath; recursive = true, force = true)
7 changes: 4 additions & 3 deletions src/ClimaLand.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ include("shared_utilities/Parameters.jl")
import .Parameters as LP

include("shared_utilities/general_utils.jl")
include("shared_utilities/Domains.jl")
include("shared_utilities/FileReaders.jl")
include("shared_utilities/Regridders.jl")
include("shared_utilities/DataHandling.jl")
include("shared_utilities/TimeVaryingInputs.jl")
using .TimeVaryingInputs
export TimeVaryingInput, evaluate!
include("shared_utilities/Regridder.jl")
include("shared_utilities/Domains.jl")
include("shared_utilities/FileReader.jl")
include("shared_utilities/SpaceVaryingInputs.jl")
using .SpaceVaryingInputs
export SpaceVaryingInput
Expand Down
Loading
Loading