Skip to content

Commit

Permalink
Simplify callbacks
Browse files Browse the repository at this point in the history
This commit removes most of the callback infrastructure in
`ClimaCoupler` in favor of a simpler one that leverages what we already
use in other packages. The current "schedule" system is the one from
`ClimaDiagnostics`, but the plan is to move it to `ClimaUtilities` as
part of the work towards the integer time.

Using the schedule system from `ClimaDiagnostics` eliminated the need
for keeping track of the first day of the month.

I also updated the checkpointing callbacks so that they can run with
frequencies that are smaller than one hour.
  • Loading branch information
Sbozzolo committed Dec 13, 2024
1 parent 5318c3b commit 6b546fb
Show file tree
Hide file tree
Showing 38 changed files with 222 additions and 504 deletions.
31 changes: 28 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,52 @@ ClimaCoupler.jl Release Notes

### ClimaEarth features

### Sea-surface temperature and sea ice concentration data can now be automatically downloaded
#### Sea-surface temperature and sea ice concentration data can now be automatically downloaded

Sea-surface temperature and sea ice concentration require external files. Now, a
low-resolution version of such files is automatically downloaded when a
higher-resolution version is not available. Please, refer to
[ClimaArtifacts](https://github.com/CliMA/ClimaArtifacts) for more information.

### A higher resolution land-sea mask is now used and automatically downloaded - PR [#1006](https://github.com/CliMA/ClimaCoupler.jl/pull/1006)
#### A higher resolution land-sea mask is now used and automatically downloaded - PR [#1006](https://github.com/CliMA/ClimaCoupler.jl/pull/1006)

A 60 arcsecond land-sea mask constructed from topographic data is now used.
Topographic data is automatically downloaded and a land-sea mask is constructed
by identifying where elevation is greater than 0. Note, this can lead to
misidentification of ocean in some areas of the globe that are inland but below
sea level (Dead Sea, Death Valley, ...).

### Leaderboard for variables over longitude, latitude, time, and pressure - PR [#1094](https://github.com/CliMA/ClimaCoupler.jl/pull/1094)
#### Leaderboard for variables over longitude, latitude, time, and pressure - PR [#1094](https://github.com/CliMA/ClimaCoupler.jl/pull/1094)

As a part of the post processing pipeline, bias plots for variables at the
pressure levels of 850.0, 500.0, 250.0 hPa and bias plots over latitude and
pressure levels are being created.

### Breaking changes

#### `hourly_checkpoint_dt` is now just `checkpoint_dt` - PR[#1121](https://github.com/CliMA/ClimaCoupler.jl/pull/1121)

Previously, the checkpointing frequency had to be specified in hours and it was
not possible to checkpoint with smaller frequencies. Now, the argument
`hourly_checkpoint_dt` was renamed to `checkpoint_dt` and any frequency can be
specified (e.g., "2months", "200secs").

Callbacks were also reworked, and the previous system was removed. Here is an example of the
new way to create a callback that runs every month:
```julia
import ClimaCouper.TimeManager: Callback, maybe_trigger_callback
import ClimaDiagnostics.Schedules: EveryCalendarDtSchedule # This will be moved to ClimaUtilities
import Dates

start_date = Dates.DateTime(1912, 4, 15)
func(cs) = println(maxima(cs.fields.T_s))
schedule = EveryCalendarDtSchedule(Dates.Month(1); start_date)
callback = Callback(schedule, func)

# Then, call it with
maybe_trigger_callback(callback, cs, t)
```

### Code cleanup

#### Output path updates - PRs [#1106](https://github.com/CliMA/ClimaCoupler.jl/pull/1058),
Expand Down
5 changes: 2 additions & 3 deletions config/amip_configs/amip.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FLOAT_TYPE: "Float32"
albedo_model: "CouplerAlbedo"
atmos_config_file: "config/longrun_configs/amip_target_diagedmf.yml"
checkpoint_dt: "720hours"
coupler_toml_file: "toml/amip.toml"
dt: "120secs"
dt_cpl: "120secs"
Expand All @@ -9,8 +10,6 @@ dt_save_to_sol: "30days"
dz_bottom: 30.0
energy_check: false
h_elem: 16
hourly_checkpoint: true
hourly_checkpoint_dt: 720
land_albedo_type: "map_temporal"
mode_name: "amip"
mono_surface: false
Expand All @@ -21,8 +20,8 @@ rayleigh_sponge: true
start_date: "20100101"
surface_setup: "PrescribedSurface"
t_end: "1098days"
topo_smoothing: true
topography: "Earth"
topo_smoothing: true
turb_flux_partition: "CombinedStateFluxesMOST"
viscous_sponge: true
z_elem: 63
Expand Down
6 changes: 3 additions & 3 deletions config/benchmark_configs/amip_diagedmf.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
atmos_config_file: "config/benchmark_configs/climaatmos_diagedmf.yml"
atmos_config_repo: "ClimaCoupler"
dt: "120secs"
Expand All @@ -10,10 +11,9 @@ land_albedo_type: "map_temporal"
mode_name: "amip"
mono_surface: false
monthly_checkpoint: false
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
prescribe_ozone: true
start_date: "20100101"
t_end: "12hours"
turb_flux_partition: "CombinedStateFluxesMOST"
use_coupler_diagnostics: false
prescribe_ozone: true
aerosol_radiation: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
6 changes: 3 additions & 3 deletions config/benchmark_configs/amip_diagedmf_io.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
atmos_config_file: "config/benchmark_configs/climaatmos_diagedmf_io.yml"
atmos_config_repo: "ClimaCoupler"
dt: "120secs"
Expand All @@ -10,10 +11,9 @@ land_albedo_type: "map_temporal"
mode_name: "amip"
mono_surface: false
monthly_checkpoint: false
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
prescribe_ozone: true
start_date: "20100101"
t_end: "12hours"
turb_flux_partition: "CombinedStateFluxesMOST"
use_coupler_diagnostics: true
prescribe_ozone: true
aerosol_radiation: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
8 changes: 4 additions & 4 deletions config/benchmark_configs/climaatmos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
approximate_linear_solve_iters: 2
dt: 120secs
dt_cloud_fraction: 1hours
Expand All @@ -8,18 +9,17 @@ dt_save_to_sol: "Inf"
dz_bottom: 30.0
dz_top: 3000.0
h_elem: 30
insolation: "timevarying"
implicit_diffusion: true
insolation: "timevarying"
moist: equil
output_default_diagnostics: false
precip_model: 0M
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
prescribe_ozone: true
rad: allskywithclear
surface_setup: DefaultMoninObukhov
t_end: 12hours
turb_flux_partition: "CombinedStateFluxesMOST"
vert_diff: "FriersonDiffusion"
z_elem: 63
z_max: 55000.0
prescribe_ozone: true
aerosol_radiation: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
10 changes: 5 additions & 5 deletions config/benchmark_configs/climaatmos_diagedmf.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
approximate_linear_solve_iters: 2
dt: 120secs
dt_cloud_fraction: 1hours
Expand All @@ -14,21 +15,20 @@ edmfx_sgs_diffusive_flux: true
edmfx_sgs_mass_flux: true
edmfx_upwinding: first_order
h_elem: 30
insolation: "timevarying"
implicit_diffusion: true
insolation: "timevarying"
moist: equil
ode_algo: ARS343
output_default_diagnostics: false
precip_model: 0M
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
prescribe_ozone: true
prognostic_tke: true
rad: allskywithclear
surface_setup: DefaultMoninObukhov
t_end: 12hours
turb_flux_partition: "CombinedStateFluxesMOST"
toml: [toml/diagnostic_edmfx.toml]
turbconv: diagnostic_edmfx
turb_flux_partition: "CombinedStateFluxesMOST"
z_elem: 63
z_max: 55000.0
prescribe_ozone: true
aerosol_radiation: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
1 change: 0 additions & 1 deletion config/ci_configs/amip_coarse_ft64_hourly_checkpoints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply_limiter: false
dt_save_to_sol: "1days"
energy_check: false
h_elem: 6
hourly_checkpoint: true
mode_name: "amip"
moist: "equil"
mono_surface: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
apply_limiter: false
checkpoint_dt: "1hours"
dt_save_restart: "10days"
dt_save_to_sol: "1days"
energy_check: false
h_elem: 6
hourly_checkpoint: true
hourly_checkpoint_dt: 1
mode_name: "amip"
moist: "equil"
mono_surface: false
Expand Down
4 changes: 2 additions & 2 deletions config/ci_configs/amip_component_dts.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply_limiter: false
dt_atmos: "150secs"
dt_cpl: "150secs"
dt_land: "50secs"
dt_ocean: "30secs"
dt_seaice: "75secs"
dt_cpl: "150secs"
dt_rad: "1hours"
dt_save_to_sol: "1days"
dt_seaice: "75secs"
dz_bottom: 30
dz_top: 3000
energy_check: false
Expand Down
1 change: 0 additions & 1 deletion config/ci_configs/amip_target_topo_diagedmf_shortrun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dt_rad: "1hours"
dt_save_state_to_disk: "1days"
dt_save_to_sol: "1days"
energy_check: false
hourly_checkpoint: true
insolation: "timevarying"
land_albedo_type: "map_temporal"
mode_name: "amip"
Expand Down
2 changes: 1 addition & 1 deletion config/ci_configs/slabplanet_dry_norad.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ h_elem: 4
mode_name: "slabplanet"
moist: "dry"
mono_surface: true
output_default_diagnostics: false
precip_model: nothing
rad: nothing
t_end: "10days"
vert_diff: "true"
output_default_diagnostics: false
7 changes: 3 additions & 4 deletions config/longrun_configs/amip_target.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
atmos_config_file: "config/longrun_configs/longrun_aquaplanet_allsky_0M.yml"
dt: "120secs"
dt_cloud_fraction: "1hours"
dt_cpl: "120secs"
dt_rad: "1hours"
dt_save_state_to_disk: "20days"
energy_check: false
hourly_checkpoint: true
insolation: "timevarying"
land_albedo_type: "map_temporal"
mode_name: "amip"
mono_surface: false
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
prescribe_ozone: true
rad: "allskywithclear"
start_date: "20100101"
surface_setup: "PrescribedSurface"
t_end: "366days"
turb_flux_partition: "CombinedStateFluxesMOST"
prescribe_ozone: true
aerosol_radiation: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
7 changes: 3 additions & 4 deletions config/longrun_configs/amip_target_topo.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
albedo_model: "CouplerAlbedo"
atmos_config_file: "config/longrun_configs/longrun_aquaplanet_allsky_0M_earth.yml"
dt: "120secs"
Expand All @@ -7,18 +8,16 @@ dt_cpl: "120secs"
dt_rad: "1hours"
dt_save_state_to_disk: "20days"
energy_check: false
hourly_checkpoint: true
insolation: "timevarying"
land_albedo_type: "map_temporal"
mode_name: "amip"
mono_surface: false
netcdf_interpolate_z_over_msl: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
prescribe_ozone: true
start_date: "20100101"
surface_setup: "PrescribedSurface"
t_end: "366days"
topo_smoothing: true
topography: "Earth"
turb_flux_partition: "CombinedStateFluxesMOST"
prescribe_ozone: true
aerosol_radiation: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
10 changes: 5 additions & 5 deletions config/longrun_configs/amip_target_topo_diagedmf_cpu.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
albedo_model: "CouplerAlbedo"
atmos_config_file: "config/longrun_configs/longrun_aquaplanet_allsky_diagedmf_0M.yml"
checkpoint_dt: "30days"
coupler_toml_file: "toml/amip_target_topo_diagedmf.toml"
dt: "120secs"
dt_cloud_fraction: "1hours"
dt_cpl: "120secs"
dt_rad: "1hours"
dt_save_state_to_disk: "20days"
energy_check: false
insolation: "timevarying"
hourly_checkpoint: false
land_albedo_type: "map_temporal"
mode_name: "amip"
mono_surface: false
netcdf_output_at_levels: true
output_default_diagnostics: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
prescribe_ozone: true
start_date: "20100101"
surface_setup: "PrescribedSurface"
t_end: "30days"
topo_smoothing: true
topography: "Earth"
coupler_toml_file: "toml/amip_target_topo_diagedmf.toml"
turb_flux_partition: "CombinedStateFluxesMOST"
prescribe_ozone: true
aerosol_radiation: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
10 changes: 5 additions & 5 deletions config/longrun_configs/amip_target_topo_diagedmf_gpu.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
albedo_model: "CouplerAlbedo"
atmos_config_file: "config/longrun_configs/longrun_aquaplanet_allsky_diagedmf_0M.yml"
checkpoint_dt: "300days"
coupler_toml_file: "toml/amip_target_topo_diagedmf.toml"
dt: "120secs"
dt_cloud_fraction: "1hours"
dt_cpl: "120secs"
dt_rad: "1hours"
dt_save_state_to_disk: "20days"
energy_check: false
insolation: "timevarying"
hourly_checkpoint: false
land_albedo_type: "map_temporal"
mode_name: "amip"
mono_surface: false
netcdf_output_at_levels: true
output_default_diagnostics: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
prescribe_ozone: true
start_date: "20100101"
surface_setup: "PrescribedSurface"
t_end: "300days"
topo_smoothing: true
topography: "Earth"
coupler_toml_file: "toml/amip_target_topo_diagedmf.toml"
turb_flux_partition: "CombinedStateFluxesMOST"
prescribe_ozone: true
aerosol_radiation: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
6 changes: 3 additions & 3 deletions config/longrun_configs/longrun_amip_dyamond.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
aerosol_radiation: true
atmos_config_file: "config/longrun_configs/longrun_aquaplanet_dyamond.yml"
dt: "30secs"
dt_cpl: "30secs"
Expand All @@ -8,9 +9,8 @@ land_albedo_type: "map_temporal"
mode_name: "amip"
mono_surface: false
monthly_checkpoint: false
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
prescribe_ozone: true
start_date: "20100101"
t_end: "1days"
turb_flux_partition: "CombinedStateFluxesMOST"
prescribe_ozone: true
aerosol_radiation: true
prescribed_aerosols: ["CB1", "CB2", "DST01", "OC1", "OC2", "SO4", "SSLT01"]
1 change: 0 additions & 1 deletion config/longrun_configs/slabplanet_aqua_target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dt_save_state_to_disk: "20days"
dt_save_to_sol: "10days"
energy_check: false
evolving_ocean: false
hourly_checkpoint: true
land_albedo_type: "function"
mode_name: "slabplanet_aqua"
mono_surface: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dt_save_state_to_disk: "20days"
dt_save_to_sol: "10days"
energy_check: false
evolving_ocean: true
hourly_checkpoint: true
land_albedo_type: "function"
mode_name: "slabplanet_aqua"
mono_surface: false
Expand Down
1 change: 0 additions & 1 deletion config/longrun_configs/slabplanet_aqua_target_nocouple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dt_save_state_to_disk: "20days"
dt_save_to_sol: "10days"
energy_check: false
evolving_ocean: false
hourly_checkpoint: true
land_albedo_type: "function"
mode_name: "slabplanet_aqua"
mono_surface: false
Expand Down
1 change: 0 additions & 1 deletion config/longrun_configs/slabplanet_target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dt_save_state_to_disk: "20days"
dt_save_to_sol: "10days"
energy_check: false
evolving_ocean: false
hourly_checkpoint: true
land_albedo_type: "function"
mode_name: "slabplanet"
mono_surface: false
Expand Down
Loading

0 comments on commit 6b546fb

Please sign in to comment.