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

Return nothing from mutating BMI functions #1931

Merged
merged 1 commit into from
Nov 11, 2024
Merged
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
29 changes: 18 additions & 11 deletions core/src/bmi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,27 @@ BMI.initialize(T::Type{Model}, config_path::AbstractString)::Model = Model(confi

Write all results to the configured files.
"""
BMI.finalize(model::Model)::Model = write_results(model)
function BMI.finalize(model::Model)::Nothing
write_results(model)
return nothing
end

function BMI.update(model::Model)::Model
function BMI.update(model::Model)::Nothing
step!(model.integrator)
return model
return nothing
end

function BMI.update_until(model::Model, time::Float64)::Model
function BMI.update_until(model::Model, time::Float64)::Nothing
(; t) = model.integrator
dt = time - t
if dt < 0
error("The model has already passed the given timestamp.")
elseif dt == 0
return model
return nothing
else
step!(model, dt)
end
return model
return nothing
end

function BMI.get_value_ptr(model::Model, name::AbstractString)::AbstractVector{Float64}
Expand Down Expand Up @@ -55,8 +58,12 @@ function BMI.get_value_ptr(model::Model, name::AbstractString)::AbstractVector{F
end
end

BMI.get_current_time(model::Model) = model.integrator.t
BMI.get_start_time(model::Model) = 0.0
BMI.get_end_time(model::Model) = seconds_since(model.config.endtime, model.config.starttime)
BMI.get_time_units(model::Model) = "s"
BMI.get_time_step(model::Model) = get_proposed_dt(model.integrator)
BMI.get_current_time(model::Model)::Float64 = model.integrator.t
BMI.get_start_time(model::Model)::Float64 = 0.0
BMI.get_time_step(model::Model)::Float64 = get_proposed_dt(model.integrator)

function BMI.get_end_time(model::Model)::Float64
seconds_since(model.config.endtime, model.config.starttime)
end

BMI.get_time_units(model::Model)::String = "s"