Skip to content

Commit

Permalink
init co2 read
Browse files Browse the repository at this point in the history
download art

fix art

art fix

direct link

test - no co2 up

co2 up

clean

gray fix
  • Loading branch information
LenkaNovak committed Oct 6, 2023
1 parent 15314cf commit 0946ca4
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,17 @@ steps:
slurm_ntasks: 1
slurm_mem: 20GB

- label: "AMIP - modular Float64 + monthly checkpoint + co2"
key: "coarse_single_modular_ft64_monthly_checkpoints_co2"
command: "julia --color=yes --project=experiments/AMIP/modular/ experiments/AMIP/modular/coupler_driver_modular.jl --config_file $CONFIG_PATH/coarse_single_modular_ft64_monthly_checkpoints_co2.yml"
artifact_paths: "experiments/AMIP/modular/output/amip/coarse_single_modular_ft64_monthly_checkpoints_co2_artifacts/*"
env:
FLAME_PLOT: ""
BUILD_HISTORY_HANDLE: ""
agents:
slurm_ntasks: 1
slurm_mem: 20GB

- label: "AMIP - modular, Float64 test"
command: "julia --color=yes --project=experiments/AMIP/modular/ experiments/AMIP/modular/coupler_driver_modular.jl --config_file $CONFIG_PATH/coarse_single_modular_ft64.yml"
artifact_paths: "experiments/AMIP/modular/output/amip/coarse_single_modular_ft64_artifacts/*"
Expand Down
3 changes: 3 additions & 0 deletions artifacts/Artifacts.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[co2]
git-tree-sha1 = "0612af4f944b576e09fccc97d337f4e878fc5180"

[land_mask]
git-tree-sha1 = "e41bc8c44124f867b64a9d70f1599515ae27f38a"

Expand Down
12 changes: 12 additions & 0 deletions artifacts/artifact_funcs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ function sic_dataset_path()
return AW.get_data_folder(sic_dataset)
end

function co2_dataset_path()
co2_dataset = AW.ArtifactWrapper(
@__DIR__,
"co2",
AW.ArtifactFile[AW.ArtifactFile(
url = "https://caltech.box.com/shared/static/4ts2f7oopm1m193wd2e0a6opu8wylma9.nc",
filename = "mauna_loa_co2.nc",
),],
)
return AW.get_data_folder(co2_dataset)
end

function mask_dataset_path()
mask_dataset = AW.ArtifactWrapper(
@__DIR__,
Expand Down
1 change: 1 addition & 0 deletions artifacts/download_artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include(joinpath(@__DIR__, "artifact_funcs.jl"))
function trigger_download()
@info "sst dataset path: `$(sst_dataset_path())`"
@info "sic dataset path: `$(sic_dataset_path())`"
@info "co2 dataset path: `$(co2_dataset_path())`"
@info "mask dataset path: `$(mask_dataset_path())`"
return nothing
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
run_name: "coarse_single_modular_ft64_monthly_checkpoints_co2"
monthly_checkpoint: true
moist: "equil"
vert_diff: "true"
rad: "allskywithclear"
energy_check: false
mode_name: "amip"
anim: true
t_end: "32days"
dt_save_to_sol: "1days"
dt_cpl: 400
dt: "400secs"
mono_surface: false
h_elem: 6
dt_save_restart: "10days"
precip_model: "0M"
apply_limiter: false
job_id: "coarse_single_modular_ft64_monthly_checkpoints_co2"
2 changes: 1 addition & 1 deletion config/model_configs/interactive_debug.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
moist: "equil"
vert_diff: "true"
rad: "gray"
rad: "allskywithclear"
energy_check: true
mode_name: "slabplanet"
t_end: "10days"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ get_field(sim::ClimaAtmosSimulation, ::Val{:gas_constant_air}) =

get_surface_params(sim::ClimaAtmosSimulation) = CAP.surface_fluxes_params(sim.integrator.p.params)

function update_field!(atmos_sim::ClimaAtmosSimulation, ::Val{:co2_gm}, field)
if atmos_sim.integrator.p.radiation_model.radiation_mode isa CA.RRTMGPI.GrayRadiation
@warn "Gray radiation_modeladiation model initialized, skipping CO2 update"
return
else
atmos_sim.integrator.p.radiation_model.volume_mixing_ratio_co2 .= parent(field)[1]
end
end
# extensions required by the Interfacer
function update_field!(sim::ClimaAtmosSimulation, ::Val{:surface_temperature}, csf)
sim.integrator.p.radiation_model.surface_temperature .= RRTMGPI.field2array(csf.T_S)
Expand Down
30 changes: 28 additions & 2 deletions experiments/AMIP/modular/coupler_driver_modular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ config_dict["print_config_dict"] ? @info(config_dict) : nothing
include(joinpath(pkgdir(ClimaCoupler), "artifacts", "artifact_funcs.jl"))
sst_data = joinpath(sst_dataset_path(), "sst.nc")
sic_data = joinpath(sic_dataset_path(), "sic.nc")
co2_data = joinpath(co2_dataset_path(), "mauna_loa_co2.nc")
land_mask_data = joinpath(mask_dataset_path(), "seamask.nc")

#=
Expand Down Expand Up @@ -293,7 +294,26 @@ if mode_name == "amip"
area_fraction = ice_fraction,
thermo_params = thermo_params,
)
mode_specifics = (; name = mode_name, SST_info = SST_info, SIC_info = SIC_info)

## CO2 concentration
CO2_info = bcfile_info_init(
FT,
REGRID_DIR,
co2_data,
"co2",
boundary_space,
comms_ctx,
interpolate_daily = true,
land_fraction = ones(boundary_space),
date0 = date0,
mono = mono_surface,
)

update_midmonth_data!(date0, CO2_info)
CO2_init = interpolate_midmonth_to_daily(date0, CO2_info)
update_field!(atmos_sim, Val(:co2_gm), CO2_init)

mode_specifics = (; name = mode_name, SST_info = SST_info, SIC_info = SIC_info, CO2_info = CO2_info)

elseif mode_name == "slabplanet"
## ocean
Expand Down Expand Up @@ -518,7 +538,7 @@ function solve_coupler!(cs)

if cs.mode.name == "amip"

## monthly read of boundary condition data for SST and SIC
## monthly read of boundary condition data for SST and SIC and CO2
if cs.dates.date[1] >= next_date_in_file(cs.mode.SST_info)
update_midmonth_data!(cs.dates.date[1], cs.mode.SST_info)
end
Expand All @@ -532,6 +552,12 @@ function solve_coupler!(cs)
get_ice_fraction.(interpolate_midmonth_to_daily(cs.dates.date[1], cs.mode.SIC_info), mono_surface)
update_field!(ice_sim, Val(:area_fraction), SIC_current)

if cs.dates.date[1] >= next_date_in_file(cs.mode.CO2_info)
update_midmonth_data!(cs.dates.date[1], cs.mode.CO2_info)
end
CO2_current = interpolate_midmonth_to_daily(date0, CO2_info)
update_field!(atmos_sim, Val(:co2_gm), CO2_current)

## calculate and accumulate diagnostics at each timestep
ClimaComms.barrier(comms_ctx)
accumulate_diagnostics!(cs)
Expand Down

0 comments on commit 0946ca4

Please sign in to comment.