Skip to content

Commit

Permalink
move checkpoint_sims to Checkpointer; delete user_logging.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Nov 7, 2024
1 parent 4d614cf commit 73853e1
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 45 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ This PR does a few cleanup tasks in the experiments/ClimaEarth/ directory:
- Delete the `viz_explorer.jl`, which was previously used to create animations of simulation fields, but is not currently being used. Note that these animations will no longer appear in buildkite output.
- Move functions in the `io_helpers.jl` file to the Utilities module and delete this file.
This should not change any behavior.
- Move `checkpoint_sims` function to the Checkpointer module and delete the `user_logging.jl` file.
This should not change any behavior.
1 change: 1 addition & 0 deletions docs/src/checkpointer.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ This module contains general functions for logging the model states and restarti
ClimaCoupler.Checkpointer.get_model_prog_state
ClimaCoupler.Checkpointer.restart_model_state!
ClimaCoupler.Checkpointer.checkpoint_model_state
ClimaCoupler.Checkpointer.checkpoint_sims
```
1 change: 0 additions & 1 deletion experiments/ClimaEarth/run_amip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ include("components/ocean/prescr_seaice.jl")
include("components/ocean/eisenman_seaice.jl")

## helpers for user-specified IO
include("user_io/user_logging.jl")
include("user_io/debug_plots.jl")

#=
Expand Down
3 changes: 0 additions & 3 deletions experiments/ClimaEarth/run_cloudless_aquaplanet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ pkg_dir = pkgdir(ClimaCoupler)
include("components/atmosphere/climaatmos.jl")
include("components/ocean/slab_ocean.jl")

## helpers for user-specified IO
include("user_io/user_logging.jl")

#=
### Setup simulation parameters
=#
Expand Down
3 changes: 0 additions & 3 deletions experiments/ClimaEarth/run_cloudy_aquaplanet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ pkg_dir = pkgdir(ClimaCoupler)
include("components/atmosphere/climaatmos.jl")
include("components/ocean/slab_ocean.jl")

## helpers for user-specified IO
include("user_io/user_logging.jl")

#=
### Setup simulation parameters
=#
Expand Down
3 changes: 0 additions & 3 deletions experiments/ClimaEarth/run_cloudy_slabplanet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ include("components/atmosphere/climaatmos.jl")
include("components/ocean/slab_ocean.jl")
include("components/land/climaland_bucket.jl")

## helpers for user-specified IO
include("user_io/user_logging.jl")

#=
### Setup simulation parameters
=#
Expand Down
3 changes: 0 additions & 3 deletions experiments/ClimaEarth/run_dry_held_suarez.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ pkg_dir = pkgdir(ClimaCoupler)
## helpers for component models
include("components/atmosphere/climaatmos.jl")

## helpers for user-specified IO
include("user_io/user_logging.jl")

#=
### Setup simulation parameters
Here we follow ClimaCore's dry Held-Suarez `held_suarez_rhoe` example.
Expand Down
3 changes: 0 additions & 3 deletions experiments/ClimaEarth/run_moist_held_suarez.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ pkg_dir = pkgdir(ClimaCoupler)
## helpers for component models
include("components/atmosphere/climaatmos.jl")

## helpers for user-specified IO
include("user_io/user_logging.jl")

#=
### Setup simulation parameters
Here we follow Thatcher and Jablonowski (2016).
Expand Down
28 changes: 0 additions & 28 deletions experiments/ClimaEarth/user_io/user_logging.jl

This file was deleted.

17 changes: 16 additions & 1 deletion src/Checkpointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ClimaComms
import ClimaCore as CC
import ..Interfacer

export get_model_prog_state, checkpoint_model_state, restart_model_state!
export get_model_prog_state, checkpoint_model_state, restart_model_state!, checkpoint_sims

"""
get_model_prog_state(sim::Interfacer.ComponentModelSimulation)
Expand Down Expand Up @@ -71,4 +71,19 @@ function restart_model_state!(
Y .= Y_new
end

"""
checkpoint_sims(cs::CoupledSimulation, _)
This is a callback function that checkpoints all simulations defined in the current coupled simulation.
"""
function checkpoint_sims(cs::Interfacer.CoupledSimulation, _)
for sim in cs.model_sims
if Checkpointer.get_model_prog_state(sim) !== nothing
t = Dates.datetime2epochms(cs.dates.date[1])
t0 = Dates.datetime2epochms(cs.dates.date0[1])
Checkpointer.checkpoint_model_state(sim, cs.comms_ctx, Int((t - t0) / 1e3), output_dir = cs.dirs.artifacts)
end
end
end

end # module

0 comments on commit 73853e1

Please sign in to comment.