diff --git a/src/SpeedyWeather.jl b/src/SpeedyWeather.jl index 8d8560048..0cf01a018 100644 --- a/src/SpeedyWeather.jl +++ b/src/SpeedyWeather.jl @@ -26,6 +26,9 @@ import BitInformation: round, round! import UnicodePlots import ProgressMeter +# to avoid a `using Dates` to pass on DateTime arguments +export DateTime + # EXPORT MONOLITHIC INTERFACE TO SPEEDY export run_speedy, run_speedy!, diff --git a/src/dynamics/models.jl b/src/dynamics/models.jl index 875d49be5..9f51332d5 100644 --- a/src/dynamics/models.jl +++ b/src/dynamics/models.jl @@ -55,7 +55,7 @@ $(TYPEDSIGNATURES) Calls all `initialize!` functions for components of `model`, except for `model.output` and `model.feedback` which are always called at in `time_stepping!`.""" -function initialize!(model::Barotropic) +function initialize!(model::Barotropic;time::DateTime = DEFAULT_DATE) (;spectral_grid) = model spectral_grid.nlev > 1 && @warn "Only nlev=1 supported for BarotropicModel, \ @@ -68,6 +68,7 @@ function initialize!(model::Barotropic) # initial conditions prognostic_variables = PrognosticVariables(spectral_grid,model) initialize!(prognostic_variables,model.initial_conditions,model) + prognostic_variables.clock.time = time # set the time diagnostic_variables = DiagnosticVariables(spectral_grid,model) return Simulation(prognostic_variables,diagnostic_variables,model) @@ -115,7 +116,7 @@ $(TYPEDSIGNATURES) Calls all `initialize!` functions for components of `model`, except for `model.output` and `model.feedback` which are always called at in `time_stepping!` and `model.implicit` which is done in `first_timesteps!`.""" -function initialize!(model::ShallowWater) +function initialize!(model::ShallowWater;time::DateTime = DEFAULT_DATE) (;spectral_grid) = model spectral_grid.nlev > 1 && @warn "Only nlev=1 supported for ShallowWaterModel, \ @@ -129,6 +130,7 @@ function initialize!(model::ShallowWater) # initial conditions prognostic_variables = PrognosticVariables(spectral_grid,model) initialize!(prognostic_variables,model.initial_conditions,model) + prognostic_variables.clock.time = time # set the time diagnostic_variables = DiagnosticVariables(spectral_grid,model) return Simulation(prognostic_variables,diagnostic_variables,model) @@ -189,7 +191,7 @@ $(TYPEDSIGNATURES) Calls all `initialize!` functions for components of `model`, except for `model.output` and `model.feedback` which are always called at in `time_stepping!` and `model.implicit` which is done in `first_timesteps!`.""" -function initialize!(model::PrimitiveDry) +function initialize!(model::PrimitiveDry;time::DateTime = DEFAULT_DATE) (;spectral_grid) = model # numerics (implicit is initialized later) @@ -209,10 +211,12 @@ function initialize!(model::PrimitiveDry) # initial conditions prognostic_variables = PrognosticVariables(spectral_grid,model) initialize!(prognostic_variables,model.initial_conditions,model) - - (;time) = prognostic_variables.clock - initialize!(prognostic_variables.ocean,time,model) - initialize!(prognostic_variables.land,time,model) + (;clock) = prognostic_variables + clock.time = time # set the time + + # initialize ocean and land and synchronize clocks + initialize!(prognostic_variables.ocean,clock.time,model) + initialize!(prognostic_variables.land,clock.time,model) diagnostic_variables = DiagnosticVariables(spectral_grid,model) return Simulation(prognostic_variables,diagnostic_variables,model) @@ -278,7 +282,7 @@ $(TYPEDSIGNATURES) Calls all `initialize!` functions for components of `model`, except for `model.output` and `model.feedback` which are always called at in `time_stepping!` and `model.implicit` which is done in `first_timesteps!`.""" -function initialize!(model::PrimitiveWet) +function initialize!(model::PrimitiveWet;time::DateTime = DEFAULT_DATE) (;spectral_grid) = model # numerics (implicit is initialized later) @@ -301,10 +305,12 @@ function initialize!(model::PrimitiveWet) # initial conditions prognostic_variables = PrognosticVariables(spectral_grid,model) initialize!(prognostic_variables,model.initial_conditions,model) + (;clock) = prognostic_variables + clock.time = time # set the time - (;time) = prognostic_variables.clock - initialize!(prognostic_variables.ocean,time,model) - initialize!(prognostic_variables.land,time,model) + # initialize ocean and land and synchronize clocks + initialize!(prognostic_variables.ocean,clock.time,model) + initialize!(prognostic_variables.land,clock.time,model) diagnostic_variables = DiagnosticVariables(spectral_grid,model) return Simulation(prognostic_variables,diagnostic_variables,model) diff --git a/src/physics/boundary_layer.jl b/src/physics/boundary_layer.jl index cfe719b7f..c6fb27b0e 100644 --- a/src/physics/boundary_layer.jl +++ b/src/physics/boundary_layer.jl @@ -1,6 +1,8 @@ """Concrete type that disables the boundary layer drag scheme.""" struct NoBoundaryLayerDrag{NF} <: BoundaryLayerDrag{NF} end +NoBoundaryLayerDrag(SG::SpectralGrid) = NoBoundaryLayerDrag{SG.NF}() + """NoBoundaryLayer scheme does not need any initialisation.""" function initialize!( scheme::NoBoundaryLayerDrag, model::PrimitiveEquation) @@ -9,8 +11,7 @@ end """NoBoundaryLayer scheme just passes.""" function boundary_layer_drag!( column::ColumnVariables, - scheme::NoBoundaryLayerDrag, - model::PrimitiveEquation) + scheme::NoBoundaryLayerDrag) return nothing end diff --git a/src/run_speedy.jl b/src/run_speedy.jl index b9b359d10..ff5dafcce 100644 --- a/src/run_speedy.jl +++ b/src/run_speedy.jl @@ -1,19 +1,14 @@ """ $(TYPEDSIGNATURES) -Run a SpeedyWeather.jl `simulation`. The `simulation.model` is assumed to be initialized, -otherwise use `initialize=true` as keyword argument.""" +Run a SpeedyWeather.jl `simulation`. The `simulation.model` is assumed to be initialized.""" function run!( simulation::Simulation; n_days::Real = 10, - startdate::Union{Nothing,DateTime} = nothing, output::Bool = false) (;prognostic_variables, diagnostic_variables, model) = simulation (;clock) = prognostic_variables - # set the clock - if typeof(startdate) == DateTime - clock.time = startdate - end + # set the clock's enddate clock.n_days = n_days initialize!(clock,model.time_stepping)