diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index efee397207..e40f578cf1 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -137,7 +137,10 @@ steps: - label: "Global Bucket on CPU (functional albedo)" key: "global_bucket_function_cpu" command: "julia --color=yes --project=.buildkite experiments/standalone/Bucket/global_bucket_function.jl" - artifact_paths: "experiments/standalone/Bucket/artifacts/*cpu*" + artifact_paths: + - "experiments/standalone/Bucket/artifacts/*cpu*" + - "experiments/global_bucket_function/output_active/*.png" + - label: "Global Bucket on CPU (static map albedo)" key: "global_bucket_staticmap_cpu" diff --git a/experiments/standalone/Bucket/global_bucket_function.jl b/experiments/standalone/Bucket/global_bucket_function.jl index 78abb6d5b1..26dcab245b 100644 --- a/experiments/standalone/Bucket/global_bucket_function.jl +++ b/experiments/standalone/Bucket/global_bucket_function.jl @@ -158,19 +158,6 @@ prob = SciMLBase.ODEProblem( p, ); -saveat = collect(t0:(Δt * 3):tf); -saved_values = (; - t = Array{Float64}(undef, length(saveat)), - saveval = Array{NamedTuple}(undef, length(saveat)), -); -saving_cb = ClimaLand.NonInterpSavingCallback(saved_values, saveat); -updateat = copy(saveat) -updatefunc = ClimaLand.make_update_drivers(bucket_atmos, bucket_rad) -driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc) -cb = SciMLBase.CallbackSet(driver_cb, saving_cb) - - - # ClimaDiagnostics base_output_dir = "global_bucket_function/" output_dir = @@ -187,13 +174,13 @@ diagnostic_handler = diag_cb = ClimaDiagnostics.DiagnosticsCallback(diagnostic_handler) -sol_test = SciMLBase.solve(prob, ode_algo; dt = Δt, callback = diag_cb) +sol = ClimaComms.@time ClimaComms.device() SciMLBase.solve(prob, ode_algo; dt = Δt, callback = diag_cb) #### ClimaAnalysis #### # all simdir = ClimaAnalysis.SimDir(output_dir) -for short_name in [ +short_names_2D = [ "alpha", "rn", "tsfc", @@ -203,29 +190,19 @@ for short_name in [ "shf", "vflux", "rhosfc", - #"tsoil", # 3D "wsoil", "wsfc", "ssfc", ] +short_names_3D = ["tsoil"] +for short_name in vcat(short_names_2D..., short_names_3D...) var = get(simdir; short_name) - fig = CairoMakie.Figure(size = (400, 600)) - viz.plot!(fig, var, time = 1 * 86400) + fig = CairoMakie.Figure(size = (800, 600)) + kwargs = short_name in short_names_2D ? Dict() : Dict(:z => 1) + viz.plot!(fig, var, lat = 0; kwargs...) CairoMakie.save(joinpath(output_dir, "$short_name.png"), fig) end -# TO DO: this works, but all variables are constant in space. -# Should we use another Bucket experiment? -########### - -sol = ClimaComms.@time ClimaComms.device() SciMLBase.solve( - prob, - ode_algo; - dt = Δt, - saveat = saveat, - callback = cb, -); - # Interpolate to grid space = axes(coords.surface) longpts = range(-180.0, 180.0, 21) @@ -233,41 +210,16 @@ latpts = range(-90.0, 90.0, 21) hcoords = [Geometry.LatLongPoint(lat, long) for long in longpts, lat in latpts] remapper = Remapping.Remapper(space, hcoords) -W = [ - Array(Remapping.interpolate(remapper, sol.u[k].bucket.W)) for - k in 1:length(sol.t) -]; -Ws = [ - Array(Remapping.interpolate(remapper, sol.u[k].bucket.Ws)) for - k in 1:length(sol.t) -]; -σS = [ - Array(Remapping.interpolate(remapper, sol.u[k].bucket.σS)) for - k in 1:length(sol.t) -]; -T_sfc = [ - Array( - Remapping.interpolate(remapper, saved_values.saveval[k].bucket.T_sfc), - ) for k in 1:length(sol.t) -]; -evaporation = [ - Array( - Remapping.interpolate( - remapper, - saved_values.saveval[k].bucket.turbulent_fluxes.vapor_flux, - ), - ) for k in 1:length(sol.t) -]; -F_sfc = [ +W = +Array(Remapping.interpolate(remapper, sol.u[end].bucket.W)) +Ws = + Array(Remapping.interpolate(remapper, sol.u[end].bucket.Ws)) +σS = + Array(Remapping.interpolate(remapper, sol.u[end].bucket.σS)) +T_sfc = Array( - Remapping.interpolate( - remapper, - saved_values.saveval[k].bucket.R_n .+ - saved_values.saveval[k].bucket.turbulent_fluxes.lhf .+ - saved_values.saveval[k].bucket.turbulent_fluxes.shf, - ), - ) for k in 1:length(sol.t) -]; + Remapping.interpolate(remapper, prob.p.bucket.T_sfc)) + # save prognostic state to CSV - for comparison between # GPU and CPU output @@ -275,50 +227,6 @@ 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][:]), ',') + writedlm(io, hcat(T_sfc[:], W[:], Ws[:], σS[:]), ',') end; -# animation settings -nframes = length(W) -framerate = 2 -fig_ts = Figure(size = (1000, 1000)) -for (i, (field_ts, field_name)) in enumerate( - zip( - [W, σS, T_sfc, evaporation, F_sfc], - ["W", "σS", "T_sfc", "evaporation", "F_sfc"], - ), -) - if anim_plots - fig = Figure(size = (1000, 1000)) - ax = Axis( - fig[1, 1], - xlabel = "Longitude", - ylabel = "Latitude", - title = field_name, - ) - clims = compute_extrema(field_ts) - CairoMakie.Colorbar(fig[:, end + 1], colorrange = clims) - outfile = joinpath( - outdir, - string("anim_$(device_suffix)_", field_name, ".mp4"), - ) - record(fig, outfile, 1:nframes; framerate = framerate) do frame - CairoMakie.heatmap!( - longpts, - latpts, - field_ts[frame], - colorrange = clims, - ) - end - end - # Plot the timeseries of the mean value as well. - xlabel = i == 5 ? "Time (days)" : "" - ax2 = Axis( - fig_ts[i, 1], - xlabel = xlabel, - ylabel = field_name, - title = "Global bucket with analytic albedo", - ) - CairoMakie.lines!(ax2, sol.t ./ 3600 ./ 24, [mean(x) for x in field_ts]) -end -outfile = joinpath(outdir, string("ts_$device_suffix.png")) -CairoMakie.save(outfile, fig_ts) +