Skip to content

Commit ff4e8ee

Browse files
committed
add back state comparisons
1 parent ac1035b commit ff4e8ee

File tree

2 files changed

+45
-38
lines changed

2 files changed

+45
-38
lines changed

experiments/AMIP/compare_cpu_gpu.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ gpu_land_state_2d = DLM.readdlm(joinpath(gpu_artifacts_dir, "land_state_2d_tend_
9090

9191
# Read in ocean state variables (if not AMIP)
9292
if !(mode_name == "amip")
93-
cpu_land_state = DLM.readdlm(joinpath(cpu_artifacts_dir, "land_state_tend_cpu.txt"), ',')
94-
gpu_land_state = DLM.readdlm(joinpath(gpu_artifacts_dir, "land_state_tend_gpu.txt"), ',')
93+
cpu_ocean_state = DLM.readdlm(joinpath(cpu_artifacts_dir, "ocean_state_tend_cpu.txt"), ',')
94+
gpu_ocean_state = DLM.readdlm(joinpath(gpu_artifacts_dir, "ocean_state_tend_gpu.txt"), ',')
9595

9696
@show abs(maximum(cpu_ocean_state .- gpu_ocean_state))
9797
@show abs(median(cpu_ocean_state .- gpu_ocean_state))

experiments/AMIP/coupler_driver.jl

+43-36
Original file line numberDiff line numberDiff line change
@@ -771,42 +771,49 @@ atmos_ρ = cs.model_sims.atmos_sim.integrator.u.c.ρ
771771
atmos_uₕ = cs.model_sims.atmos_sim.integrator.u.c.uₕ
772772
atmos_u₃ = cs.model_sims.atmos_sim.integrator.u.f.u₃
773773

774-
# # Write to text files
775-
# open(joinpath(COUPLER_ARTIFACTS_DIR, "atmos_state_center_tend_$device_suffix.txt"), "w") do io
776-
# DLM.writedlm(
777-
# io,
778-
# hcat(parent(atmos_ρe_tot)[:], parent(atmos_ρq_tot)[:], parent(atmos_ρ)[:], parent(atmos_uₕ)[:]),
779-
# ',',
780-
# )
781-
# end;
782-
783-
# open(joinpath(COUPLER_ARTIFACTS_DIR, "atmos_state_face_tend_$device_suffix.txt"), "w") do io
784-
# DLM.writedlm(io, parent(atmos_u₃)[:], ',')
785-
# end;
786-
787-
# # Extract land state variables
788-
# land_T = cs.model_sims.land_sim.integrator.u.bucket.T
789-
# land_W = cs.model_sims.land_sim.integrator.u.bucket.W
790-
# land_Ws = cs.model_sims.land_sim.integrator.u.bucket.Ws
791-
# land_σS = cs.model_sims.land_sim.integrator.u.bucket.σS
792-
793-
# # Write to text files
794-
# open(joinpath(COUPLER_ARTIFACTS_DIR, "land_state_3d_tend_$device_suffix.txt"), "w") do io
795-
# DLM.writedlm(io, parent(land_T)[:], ',')
796-
# end;
797-
# open(joinpath(COUPLER_ARTIFACTS_DIR, "land_state_2d_tend_$device_suffix.txt"), "w") do io
798-
# DLM.writedlm(io, hcat(parent(land_W)[:], parent(land_Ws)[:], parent(land_σS)[:]), ',')
799-
# end;
800-
801-
# # ocean state
802-
# if cs.mode.name != "amip"
803-
# ocean_T_sfc = cs.model_sims.ocean_sim.integrator.u.T_sfc
804-
805-
# # Write to text files
806-
# open(joinpath(COUPLER_ARTIFACTS_DIR, "ocean_state_tend_$device_suffix.txt"), "w") do io
807-
# DLM.writedlm(io, parent(ocean_T_sfc)[:], ',')
808-
# end
809-
# end;
774+
# Write to text files
775+
open(joinpath(COUPLER_ARTIFACTS_DIR, "atmos_state_center_tend_$device_suffix.txt"), "w") do io
776+
# note: `atmos_uₕ` has two components that we have to index into
777+
DLM.writedlm(
778+
io,
779+
hcat(
780+
Array(parent(atmos_ρe_tot))[:],
781+
Array(parent(atmos_ρq_tot))[:],
782+
Array(parent(atmos_ρ))[:],
783+
Array(parent(atmos_uₕ.components))[:, :, :, 1, :][:],
784+
Array(parent(atmos_uₕ.components))[:, :, :, 2, :][:],
785+
),
786+
',',
787+
)
788+
end;
789+
790+
open(joinpath(COUPLER_ARTIFACTS_DIR, "atmos_state_face_tend_$device_suffix.txt"), "w") do io
791+
DLM.writedlm(io, Array(parent(atmos_u₃))[:], ',')
792+
end;
793+
794+
# Extract land state variables
795+
land_T = cs.model_sims.land_sim.integrator.u.bucket.T
796+
land_W = cs.model_sims.land_sim.integrator.u.bucket.W
797+
land_Ws = cs.model_sims.land_sim.integrator.u.bucket.Ws
798+
land_σS = cs.model_sims.land_sim.integrator.u.bucket.σS
799+
800+
# Write to text files
801+
open(joinpath(COUPLER_ARTIFACTS_DIR, "land_state_3d_tend_$device_suffix.txt"), "w") do io
802+
DLM.writedlm(io, Array(parent(land_T))[:], ',')
803+
end;
804+
open(joinpath(COUPLER_ARTIFACTS_DIR, "land_state_2d_tend_$device_suffix.txt"), "w") do io
805+
DLM.writedlm(io, hcat(Array(parent(land_W))[:], Array(parent(land_Ws))[:], Array(parent(land_σS))[:]), ',')
806+
end;
807+
808+
# ocean state
809+
if cs.mode.name != "amip"
810+
ocean_T_sfc = cs.model_sims.ocean_sim.integrator.u.T_sfc
811+
812+
# Write to text files
813+
open(joinpath(COUPLER_ARTIFACTS_DIR, "ocean_state_tend_$device_suffix.txt"), "w") do io
814+
DLM.writedlm(io, Array(parent(ocean_T_sfc))[:], ',')
815+
end
816+
end;
810817

811818
#=
812819
## Postprocessing

0 commit comments

Comments
 (0)