Skip to content

Commit 06d13aa

Browse files
committed
fix state saving
1 parent 122a128 commit 06d13aa

File tree

1 file changed

+42
-36
lines changed

1 file changed

+42
-36
lines changed

experiments/AMIP/coupler_driver.jl

+42-36
Original file line numberDiff line numberDiff line change
@@ -771,42 +771,48 @@ 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+
DLM.writedlm(
777+
io,
778+
hcat(
779+
Array(parent(atmos_ρe_tot))[:],
780+
Array(parent(atmos_ρq_tot))[:],
781+
Array(parent(atmos_ρ))[:],
782+
Array(parent(atmos_uₕ.components)[:, :, :, 1, :])[:],
783+
Array(parent(atmos_uₕ.components)[:, :, :, 2, :])[:],
784+
),
785+
',',
786+
)
787+
end;
788+
789+
open(joinpath(COUPLER_ARTIFACTS_DIR, "atmos_state_face_tend_$device_suffix.txt"), "w") do io
790+
DLM.writedlm(io, Array(parent(atmos_u₃))[:], ',')
791+
end;
792+
793+
# Extract land state variables
794+
land_T = cs.model_sims.land_sim.integrator.u.bucket.T
795+
land_W = cs.model_sims.land_sim.integrator.u.bucket.W
796+
land_Ws = cs.model_sims.land_sim.integrator.u.bucket.Ws
797+
land_σS = cs.model_sims.land_sim.integrator.u.bucket.σS
798+
799+
# Write to text files
800+
open(joinpath(COUPLER_ARTIFACTS_DIR, "land_state_3d_tend_$device_suffix.txt"), "w") do io
801+
DLM.writedlm(io, Array(parent(land_T))[:], ',')
802+
end;
803+
open(joinpath(COUPLER_ARTIFACTS_DIR, "land_state_2d_tend_$device_suffix.txt"), "w") do io
804+
DLM.writedlm(io, hcat(Array(parent(land_W))[:], Array(parent(land_Ws))[:], Array(parent(land_σS))[:]), ',')
805+
end;
806+
807+
# ocean state
808+
if cs.mode.name != "amip"
809+
ocean_T_sfc = cs.model_sims.ocean_sim.integrator.u.T_sfc
810+
811+
# Write to text files
812+
open(joinpath(COUPLER_ARTIFACTS_DIR, "ocean_state_tend_$device_suffix.txt"), "w") do io
813+
DLM.writedlm(io, Array(parent(ocean_T_sfc))[:], ',')
814+
end
815+
end;
810816

811817
#=
812818
## Postprocessing

0 commit comments

Comments
 (0)