Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CO2 from AMIP driver #1143

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ object initialization and `step!`. Note that this results in changed order of
operations and slightly different behavior for AMIP simulations - see the PR
description for more details.

#### CO2 is now updated by ClimaAtmos directly PR[#1143](https://github.com/CliMA/ClimaCoupler.jl/pull/1143)

Previously, CO2 was read in directly from the driver during init and in the
coupling loop. Now, it is read internally by ClimaAtmos. Note that this results
in changed order of operations and slightly different behavior for AMIP
simulations - see the PR description for more details.


#### Simplified callbacks PR [#1121](https://github.com/CliMA/ClimaCoupler.jl/pull/1121)

Callbacks were also reworked, and the previous system was removed. Here is an example of the
Expand Down
1 change: 1 addition & 0 deletions config/amip_configs/amip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FLOAT_TYPE: "Float32"
albedo_model: "CouplerAlbedo"
atmos_config_file: "config/longrun_configs/amip_target_diagedmf.yml"
checkpoint_dt: "720hours"
co2: "maunaloa"
coupler_toml: ["toml/amip.toml"]
dt: "120secs"
dt_cpl: "120secs"
Expand Down
1 change: 1 addition & 0 deletions config/benchmark_configs/climaatmos.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
approximate_linear_solve_iters: 2
co2: "maunaloa"
dt: 120secs
dt_cloud_fraction: 1hours
dt_rad: 1hours
Expand Down
1 change: 1 addition & 0 deletions config/benchmark_configs/climaatmos_diagedmf.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
approximate_linear_solve_iters: 2
co2: "maunaloa"
dt: 120secs
dt_cloud_fraction: 1hours
dt_rad: 1hours
Expand Down
1 change: 1 addition & 0 deletions config/benchmark_configs/climaatmos_diagedmf_io.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FLOAT_TYPE: "Float32"
approximate_linear_solve_iters: 2
co2: "maunaloa"
dt: 120secs
dt_cloud_fraction: 1hours
dt_rad: 1hours
Expand Down
1 change: 1 addition & 0 deletions config/ci_configs/amip_albedo_temporal_map.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply_limiter: false
co2: "maunaloa"
dt: "150secs"
dt_cpl: "150secs"
dt_rad: "1hours"
Expand Down
1 change: 1 addition & 0 deletions config/ci_configs/amip_albedo_temporal_map_1M.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply_limiter: false
co2: "maunaloa"
dt: "150secs"
dt_cpl: "150secs"
dt_rad: "1hours"
Expand Down
1 change: 1 addition & 0 deletions config/ci_configs/amip_bucket_ic.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply_limiter: false
co2: "maunaloa"
dt: "150secs"
dt_cpl: "150secs"
dt_rad: "1hours"
Expand Down
1 change: 1 addition & 0 deletions config/ci_configs/amip_coarse_ft32.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FLOAT_TYPE: "Float32"
apply_limiter: false
co2: "maunaloa"
dt_save_to_sol: "100days"
energy_check: false
h_elem: 6
Expand Down
1 change: 1 addition & 0 deletions config/ci_configs/amip_coarse_ft64_hourly_checkpoints.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply_limiter: false
co2: "maunaloa"
dt_save_to_sol: "1days"
energy_check: false
h_elem: 6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply_limiter: false
co2: "maunaloa"
checkpoint_dt: "1hours"
dt_save_restart: "10days"
dt_save_to_sol: "1days"
Expand Down
1 change: 1 addition & 0 deletions config/ci_configs/amip_coarse_mpi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply_limiter: false
co2: "maunaloa"
dt_save_to_sol: "1days"
energy_check: false
h_elem: 6
Expand Down
1 change: 1 addition & 0 deletions config/ci_configs/amip_component_dts.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply_limiter: false
co2: "maunaloa"
dt_atmos: "150secs"
dt_cpl: "150secs"
dt_land: "50secs"
Expand Down
1 change: 1 addition & 0 deletions config/ci_configs/amip_default.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply_limiter: false
co2: "maunaloa"
dt: "150secs"
dt_cpl: "150secs"
dt_rad: "1hours"
Expand Down
1 change: 1 addition & 0 deletions config/ci_configs/amip_n1_shortrun.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply_limiter: false
co2: "maunaloa"
dt: "150secs"
dt_cpl: "150secs"
dt_rad: "1hours"
Expand Down
1 change: 1 addition & 0 deletions config/ci_configs/amip_target_topo_diagedmf_shortrun.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FLOAT_TYPE: "Float32"
apply_limiter: false
atmos_config_file: "config/longrun_configs/longrun_aquaplanet_allsky_diagedmf_0M.yml"
co2: "maunaloa"
dt: "100secs"
dt_cloud_fraction: "1hours"
dt_cpl: "100secs"
Expand Down
1 change: 1 addition & 0 deletions config/longrun_configs/amip_target.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FLOAT_TYPE: "Float32"
aerosol_radiation: true
atmos_config_file: "config/longrun_configs/longrun_aquaplanet_allsky_0M.yml"
co2: "maunaloa"
dt: "120secs"
dt_cloud_fraction: "1hours"
dt_cpl: "120secs"
Expand Down
1 change: 1 addition & 0 deletions config/longrun_configs/amip_target_topo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FLOAT_TYPE: "Float32"
aerosol_radiation: true
albedo_model: "CouplerAlbedo"
atmos_config_file: "config/longrun_configs/longrun_aquaplanet_allsky_0M_earth.yml"
co2: "maunaloa"
dt: "120secs"
dt_cloud_fraction: "1hours"
dt_cpl: "120secs"
Expand Down
25 changes: 1 addition & 24 deletions experiments/ClimaEarth/run_amip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ tspan = (t_start, t_end)
#=
## Data File Paths
=#
co2_data = joinpath(@clima_artifact("co2_dataset", comms_ctx), "co2_mm_mlo.txt")
land_mask_data = joinpath(@clima_artifact("landsea_mask_60arcseconds", comms_ctx), "landsea_mask.nc")

#=
Expand Down Expand Up @@ -281,22 +280,7 @@ if sim_mode <: AMIPMode
ocean_fraction = FT(1) .- ice_fraction .- land_fraction
ocean_sim = PrescribedOceanSimulation(FT, boundary_space, date0, t_start, ocean_fraction, thermo_params, comms_ctx)

## CO2 concentration from temporally varying file
CO2_text = DelimitedFiles.readdlm(co2_data, Float64; comments = true)
# The text file only has month and year, so we set the day to 15th of the month
years = CO2_text[:, 1]
months = CO2_text[:, 2]
CO2_dates = Dates.DateTime.(years, months) + Dates.Day(14)
CO2_times = period_to_seconds_float.(CO2_dates .- date0)
# convert from ppm to fraction, data is in fourth column of the text file
CO2_vals = CO2_text[:, 4] .* 10^(-6)
CO2_timevaryinginput = TimeVaryingInput(CO2_times, CO2_vals;)

CO2_init = zeros(boundary_space)
evaluate!(CO2_init, CO2_timevaryinginput, t_start)
CO2_field = Interfacer.update_field!(atmos_sim, Val(:co2), CO2_init)

mode_specifics = (; type = sim_mode, CO2_timevaryinginput = CO2_timevaryinginput)
mode_specifics = (; type = sim_mode)
Utilities.show_memory_usage()

elseif (sim_mode <: AbstractSlabplanetSimulationMode) && !(sim_mode <: SlabplanetEisenmanMode)
Expand Down Expand Up @@ -629,13 +613,6 @@ function solve_coupler!(cs)
# Update date
cs.dates.date[] = TimeManager.current_date(cs, t)

if cs.mode.type <: AMIPMode
# TODO: get_field with :co2 is not implemented, so this is a little awkward
current_CO2 = zeros(boundary_space)
evaluate!(current_CO2, cs.mode.CO2_timevaryinginput, t)
Interfacer.update_field!(atmos_sim, Val(:co2), current_CO2)
end

## compute global energy and water conservation checks
## (only for slabplanet if tracking conservation is enabled)
!isnothing(cs.conservation_checks) && ConservationChecker.check_conservation!(cs)
Expand Down
Loading