From 8ee1d35711a2ca6744b0e03fc560827b4e8c1314 Mon Sep 17 00:00:00 2001 From: Bart de Koning <74617371+SouthEndMusic@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:45:39 +0200 Subject: [PATCH] Add error starttime > endtime (#1379) Fixes https://github.com/Deltares/Ribasim/issues/1378. --------- Co-authored-by: Martijn Visser --- core/src/model.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/model.jl b/core/src/model.jl index 4aacb0417..241ba2ec6 100644 --- a/core/src/model.jl +++ b/core/src/model.jl @@ -44,6 +44,11 @@ function Model(config::Config)::Model TimerOutputs.enable_debug_timings(Ribasim) # causes recompilation (!) end + t_end = seconds_since(config.endtime, config.starttime) + if t_end <= 0 + error("Model starttime is not before endtime.") + end + # All data from the database that we need during runtime is copied into memory, # so we can directly close it again. db = SQLite.DB(db_path) @@ -108,7 +113,6 @@ function Model(config::Config)::Model # Integrals for PID control integral = zeros(length(parameters.pid_control.node_id)) u0 = ComponentVector{Float64}(; storage, integral) - t_end = seconds_since(config.endtime, config.starttime) # for Float32 this method allows max ~1000 year simulations without accuracy issues @assert eps(t_end) < 3600 "Simulation time too long" t0 = zero(t_end)