Skip to content

Commit

Permalink
Merge pull request #3466 from CliMA/gb/remove_start_date
Browse files Browse the repository at this point in the history
Remove start_date from cache
  • Loading branch information
Sbozzolo authored Dec 5, 2024
2 parents 9c37751 + e396a40 commit 299b8ab
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
5 changes: 0 additions & 5 deletions src/cache/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ struct AtmosCache{
FT <: AbstractFloat,
FTE,
WTE,
SD,
AM,
NUM,
CAP,
Expand Down Expand Up @@ -36,9 +35,6 @@ struct AtmosCache{
"""Walltime estimate"""
walltime_estimate::WTE

"""Start date (used for insolation and for data files)."""
start_date::SD

"""AtmosModel"""
atmos::AM

Expand Down Expand Up @@ -190,7 +186,6 @@ function build_cache(Y, atmos, params, surface_setup, sim_info, aerosol_names)
dt,
t_end,
WallTimeEstimate(),
start_date,
atmos,
numerics,
params,
Expand Down
5 changes: 3 additions & 2 deletions src/callbacks/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,17 @@ function set_insolation_variables!(Y, p, t, ::IdealizedInsolation)
rrtmgp_model.weighted_irradiance .= weighted_irradiance
end

function set_insolation_variables!(Y, p, t, ::TimeVaryingInsolation)
function set_insolation_variables!(Y, p, t, tvi::TimeVaryingInsolation)
FT = Spaces.undertype(axes(Y.c))
params = p.params
insolation_params = CAP.insolation_params(params)
(; insolation_tuple, rrtmgp_model) = p.radiation

current_datetime = p.start_date + Dates.Second(round(Int, t)) # current time
current_datetime = tvi.start_date + Dates.Second(round(Int, t)) # current time
max_zenith_angle = FT(π) / 2 - eps(FT)
irradiance = FT(CAP.tot_solar_irrad(params))
au = FT(CAP.astro_unit(params))
# TODO: Where does this date0 come from?
date0 = DateTime("2000-01-01T11:58:56.816")
d, δ, η_UTC =
FT.(
Expand Down
16 changes: 9 additions & 7 deletions src/callbacks/get_callbacks.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function get_diagnostics(parsed_args, atmos_model, Y, p, dt, t_start)
function get_diagnostics(parsed_args, atmos_model, Y, p, sim_info, t_start)

(; dt, start_date) = sim_info

FT = Spaces.undertype(axes(Y.c))

Expand Down Expand Up @@ -110,11 +112,11 @@ function get_diagnostics(parsed_args, atmos_model, Y, p, dt, t_start)

output_schedule = CAD.EveryCalendarDtSchedule(
period_dates;
reference_date = p.start_date,
reference_date = start_date,
)
compute_schedule = CAD.EveryCalendarDtSchedule(
period_dates;
reference_date = p.start_date,
reference_date = start_date,
)

if isnothing(output_name)
Expand Down Expand Up @@ -152,7 +154,7 @@ function get_diagnostics(parsed_args, atmos_model, Y, p, dt, t_start)
CAD.default_diagnostics(
atmos_model,
FT(time_to_seconds(parsed_args["t_end"]) - t_start),
p.start_date;
start_date;
output_writer = netcdf_writer,
)...,
diagnostics...,
Expand Down Expand Up @@ -214,7 +216,7 @@ end
function get_callbacks(config, sim_info, atmos, params, Y, p, t_start)
(; parsed_args, comms_ctx) = config
FT = eltype(params)
(; dt, output_dir) = sim_info
(; dt, output_dir, start_date) = sim_info

callbacks = ()
if parsed_args["log_progress"]
Expand Down Expand Up @@ -256,8 +258,8 @@ function get_callbacks(config, sim_info, atmos, params, Y, p, t_start)
if dt_save_state_to_disk_dates != Inf
schedule = CAD.EveryCalendarDtSchedule(
dt_save_state_to_disk_dates;
reference_date = p.start_date,
date_last = p.start_date + Dates.Second(t_start),
reference_date = start_date,
date_last = start_date + Dates.Second(t_start),
)
cond = let schedule = schedule
(u, t, integrator) -> schedule(integrator)
Expand Down
5 changes: 4 additions & 1 deletion src/solver/model_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ function get_insolation_form(parsed_args)
return if insolation == "idealized"
IdealizedInsolation()
elseif insolation == "timevarying"
TimeVaryingInsolation()
# TODO: Remove this argument once we have support for integer time and
# we can easily convert from time to date
start_date = DateTime(parsed_args["start_date"], dateformat"yyyymmdd")
TimeVaryingInsolation(start_date)
elseif insolation == "rcemipii"
RCEMIPIIInsolation()
elseif insolation == "gcmdriven"
Expand Down
2 changes: 1 addition & 1 deletion src/solver/type_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ function get_simulation(config::AtmosConfig)
atmos,
Y,
p,
sim_info.dt,
sim_info,
t_start,
)
end
Expand Down
6 changes: 5 additions & 1 deletion src/solver/types.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import FastGaussQuadrature
import StaticArrays as SA
import Thermodynamics as TD
import Dates

import ClimaUtilities.ClimaArtifacts: @clima_artifact
import LazyArtifacts
Expand Down Expand Up @@ -33,7 +34,10 @@ struct RCEMIPIISST <: AbstractSST end

abstract type AbstractInsolation end
struct IdealizedInsolation <: AbstractInsolation end
struct TimeVaryingInsolation <: AbstractInsolation end
struct TimeVaryingInsolation <: AbstractInsolation
# TODO: Remove when we can easily go from time to date
start_date::Dates.DateTime
end
struct RCEMIPIIInsolation <: AbstractInsolation end
struct GCMDrivenInsolation <: AbstractInsolation end

Expand Down
1 change: 0 additions & 1 deletion test/coupler_compatibility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const T2 = 290
p.dt,
simulation.t_end,
CA.WallTimeEstimate(),
p.start_date,
p.atmos,
p.numerics,
p.params,
Expand Down

0 comments on commit 299b8ab

Please sign in to comment.