Skip to content

Commit

Permalink
save state every dt
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Feb 12, 2024
1 parent 697837e commit d5980b9
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions experiments/AMIP/coupler_driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -607,32 +607,33 @@ function solve_coupler!(cs)
## step in time
walltime = @elapsed for t in ((tspan[1] + Δt_cpl):Δt_cpl:tspan[end])

# save states every day
if t % 86400 == 0
date = date0 + Dates.Second(t)

# atmos state
atmos_ρe_tot = cs.model_sims.atmos_sim.integrator.u.c.ρe_tot
atmos_ρq_tot = cs.model_sims.atmos_sim.integrator.u.c.ρq_tot
atmos_ρ = cs.model_sims.atmos_sim.integrator.u.c.ρ
atmos_uₕ = cs.model_sims.atmos_sim.integrator.u.c.uₕ
atmos_u₃ = cs.model_sims.atmos_sim.integrator.u.f.u₃
Regridder.write_to_hdf5(COUPLER_ARTIFACTS_DIR, "atmos_ρe_tot", date, atmos_ρe_tot, "atmos_ρe_tot", comms_ctx)
Regridder.write_to_hdf5(COUPLER_ARTIFACTS_DIR, "atmos_ρq_tot", date, atmos_ρq_tot, "atmos_ρq_tot", comms_ctx)

# land state
land_T = cs.model_sims.land_sim.integrator.u.bucket.T
land_W = cs.model_sims.land_sim.integrator.u.bucket.W
land_Ws = cs.model_sims.land_sim.integrator.u.bucket.Ws
land_σS = cs.model_sims.land_sim.integrator.u.bucket.σS
Regridder.write_to_hdf5(COUPLER_ARTIFACTS_DIR, "land_T", date, land_T, "land_T", comms_ctx)
Regridder.write_to_hdf5(COUPLER_ARTIFACTS_DIR, "land_W", date, land_W, "land_W", comms_ctx)

# ocean state
ocean_T_sfc = cs.model_sims.ocean_sim.integrator.u.T_sfc
Regridder.write_to_hdf5(COUPLER_ARTIFACTS_DIR, "ocean_T_sfc", date, ocean_T_sfc, "ocean_T_sfc", comms_ctx)

end
# # save states every day
# if t % 86400 == 0
# save state every timestep
date = date0 + Dates.Second(t)

# atmos state
atmos_ρe_tot = cs.model_sims.atmos_sim.integrator.u.c.ρe_tot
atmos_ρq_tot = cs.model_sims.atmos_sim.integrator.u.c.ρq_tot
atmos_ρ = cs.model_sims.atmos_sim.integrator.u.c.ρ
atmos_uₕ = cs.model_sims.atmos_sim.integrator.u.c.uₕ
atmos_u₃ = cs.model_sims.atmos_sim.integrator.u.f.u₃
Regridder.write_to_hdf5(COUPLER_ARTIFACTS_DIR, "atmos_ρe_tot", date, atmos_ρe_tot, "atmos_ρe_tot", comms_ctx)
Regridder.write_to_hdf5(COUPLER_ARTIFACTS_DIR, "atmos_ρq_tot", date, atmos_ρq_tot, "atmos_ρq_tot", comms_ctx)

# land state
land_T = cs.model_sims.land_sim.integrator.u.bucket.T
land_W = cs.model_sims.land_sim.integrator.u.bucket.W
land_Ws = cs.model_sims.land_sim.integrator.u.bucket.Ws
land_σS = cs.model_sims.land_sim.integrator.u.bucket.σS
Regridder.write_to_hdf5(COUPLER_ARTIFACTS_DIR, "land_T", date, land_T, "land_T", comms_ctx)
Regridder.write_to_hdf5(COUPLER_ARTIFACTS_DIR, "land_W", date, land_W, "land_W", comms_ctx)

# ocean state
ocean_T_sfc = cs.model_sims.ocean_sim.integrator.u.T_sfc
Regridder.write_to_hdf5(COUPLER_ARTIFACTS_DIR, "ocean_T_sfc", date, ocean_T_sfc, "ocean_T_sfc", comms_ctx)
# end

cs.dates.date[1] = current_date(cs, t) # if not global, `date` is not updated.

Expand Down

0 comments on commit d5980b9

Please sign in to comment.