From c17d3c497f07a4ba6b73f78c1f65ed095b191cb5 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Thu, 16 May 2024 14:30:04 +0200 Subject: [PATCH 01/10] Fix subgrid_id in output (#1466) Fixes #895 --- core/src/parameter.jl | 1 + core/src/read.jl | 9 ++++++--- core/src/write.jl | 5 ++--- core/test/run_models_test.jl | 3 +-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/parameter.jl b/core/src/parameter.jl index df3aa43c8..a4ee97098 100644 --- a/core/src/parameter.jl +++ b/core/src/parameter.jl @@ -630,6 +630,7 @@ end "Subgrid linearly interpolates basin levels." struct Subgrid + subgrid_id::Vector{Int32} basin_index::Vector{Int32} interpolations::Vector{ScalarInterpolation} level::Vector{Float64} diff --git a/core/src/read.jl b/core/src/read.jl index 2c7b2df43..785290f14 100644 --- a/core/src/read.jl +++ b/core/src/read.jl @@ -970,7 +970,8 @@ function Subgrid(db::DB, config::Config, basin::Basin)::Subgrid node_to_basin = Dict(node_id => index for (index, node_id) in enumerate(basin.node_id)) tables = load_structvector(db, config, BasinSubgridV1) - basin_ids = Int32[] + subgrid_ids = Int32[] + basin_index = Int32[] interpolations = ScalarInterpolation[] has_error = false for group in IterTools.groupby(row -> row.subgrid_id, tables) @@ -987,7 +988,8 @@ function Subgrid(db::DB, config::Config, basin::Basin)::Subgrid pushfirst!(subgrid_level, first(subgrid_level)) pushfirst!(basin_level, nextfloat(-Inf)) new_interp = LinearInterpolation(subgrid_level, basin_level; extrapolate = true) - push!(basin_ids, node_to_basin[node_id]) + push!(subgrid_ids, subgrid_id) + push!(basin_index, node_to_basin[node_id]) push!(interpolations, new_interp) else has_error = true @@ -995,8 +997,9 @@ function Subgrid(db::DB, config::Config, basin::Basin)::Subgrid end has_error && error("Invalid Basin / subgrid table.") + level = fill(NaN, length(subgrid_ids)) - return Subgrid(basin_ids, interpolations, fill(NaN, length(basin_ids))) + return Subgrid(subgrid_ids, basin_index, interpolations, level) end function Allocation(db::DB, config::Config, graph::MetaGraph)::Allocation diff --git a/core/src/write.jl b/core/src/write.jl index 1f2ed07d4..da89faade 100644 --- a/core/src/write.jl +++ b/core/src/write.jl @@ -315,12 +315,11 @@ function subgrid_level_table( (; t, saveval) = saved.subgrid_level subgrid = integrator.p.subgrid - nelem = length(subgrid.basin_index) + nelem = length(subgrid.subgrid_id) ntsteps = length(t) - unique_elem_id = collect(1:nelem) time = repeat(datetime_since.(t, config.starttime); inner = nelem) - subgrid_id = repeat(unique_elem_id; outer = ntsteps) + subgrid_id = repeat(subgrid.subgrid_id; outer = ntsteps) subgrid_level = FlatVector(saveval) return (; time, subgrid_id, subgrid_level) end diff --git a/core/test/run_models_test.jl b/core/test/run_models_test.jl index 5c9037cd2..45fa53f73 100644 --- a/core/test/run_models_test.jl +++ b/core/test/run_models_test.jl @@ -147,8 +147,7 @@ basin_level = basin.level[1] @test length(p.subgrid.level) == 3 @test diff(p.subgrid.level) ≈ [-1.0, 2.0] - # TODO The original subgrid IDs are lost and mapped to 1, 2, 3 - @test subgrid.subgrid_id[1:3] == [11, 22, 33] broken = true + @test subgrid.subgrid_id[1:3] == [11, 22, 33] @test subgrid.subgrid_level[1:3] ≈ [basin_level, basin_level - 1.0, basin_level + 1.0] @test subgrid.subgrid_level[(end - 2):end] == p.subgrid.level From 1c30c401cf55b4a03b9238324f824d08c52fc0f7 Mon Sep 17 00:00:00 2001 From: "git@evetion.nl" Date: Thu, 16 May 2024 14:53:42 +0200 Subject: [PATCH 02/10] TeamCity change in 'Ribasim / Windows' project: 'Test Delwaq coupling' build configuration was created --- .../Ribasim_Windows_TestDelwaqCoupling.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml new file mode 100644 index 000000000..bf1947675 --- /dev/null +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml @@ -0,0 +1,14 @@ + + + Test Delwaq coupling + + + + + + + + + + + From 79cda4ec3f3c0b0c6668e39de3d3d1a0c22acadd Mon Sep 17 00:00:00 2001 From: "git@evetion.nl" Date: Thu, 16 May 2024 14:55:51 +0200 Subject: [PATCH 03/10] TeamCity change in 'Ribasim / Windows' project: artifact dependencies of 'Test Delwaq coupling' build configuration were updated --- .../buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml index bf1947675..b996819ae 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml @@ -8,6 +8,12 @@ + + + + + + From 268bfe8d856ffb9781b67839e15ad04cfa94d410 Mon Sep 17 00:00:00 2001 From: "git@evetion.nl" Date: Thu, 16 May 2024 15:13:53 +0200 Subject: [PATCH 04/10] TeamCity change in 'Ribasim / Windows' project: snapshot dependency was added in 'Test Delwaq coupling' build configuration --- .../buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml index b996819ae..9aa714a3c 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml @@ -14,6 +14,14 @@ + + + + + + From b42c1c912c53609d95d85ca756d4df0d40a34e74 Mon Sep 17 00:00:00 2001 From: "git@evetion.nl" Date: Thu, 16 May 2024 15:14:04 +0200 Subject: [PATCH 05/10] TeamCity change in 'Ribasim / Windows' project: artifact dependencies of 'Test Delwaq coupling' build configuration were updated --- .../buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml index 9aa714a3c..3d3e37288 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml @@ -10,7 +10,7 @@ - + From 178c9365ece34a52d356df654ef9723ab5fe3f5a Mon Sep 17 00:00:00 2001 From: "git@evetion.nl" Date: Thu, 16 May 2024 15:16:24 +0200 Subject: [PATCH 06/10] TeamCity change in 'Ribasim / Windows' project: triggers of 'Test Delwaq coupling' build configuration were updated --- .../buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml index 3d3e37288..8e42d5f16 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml @@ -7,7 +7,16 @@ - + + + + + + + + + + From 80d226a4e915b6c0a57fc2c69dd51b8b50c18509 Mon Sep 17 00:00:00 2001 From: "git@evetion.nl" Date: Thu, 16 May 2024 15:17:26 +0200 Subject: [PATCH 07/10] TeamCity change in 'Ribasim / Windows' project: runners of 'Test Delwaq coupling' build configuration were updated --- .../buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml index 8e42d5f16..bb3493379 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml @@ -4,7 +4,15 @@ - + + + + + + + + + From f1d028cd999f98216ce241c9ff19ed759264d03f Mon Sep 17 00:00:00 2001 From: Maarten Pronk <8655030+evetion@users.noreply.github.com> Date: Thu, 16 May 2024 15:17:36 +0200 Subject: [PATCH 08/10] Support macOS in our cli build (#1476) Errors are unrelated. Note that this doesn't make it work on macOS yet, seems a problem with the shared library path, it cannot find @rpath/libjulia-internal.dylib. --- build/cli/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/cli/src/main.rs b/build/cli/src/main.rs index 3aa394c3f..1f71afa9a 100644 --- a/build/cli/src/main.rs +++ b/build/cli/src/main.rs @@ -44,7 +44,8 @@ fn main() -> ExitCode { let shared_lib_path = match OS { "windows" => exe_dir.join("bin/libribasim.dll"), "linux" => exe_dir.join("lib/libribasim.so"), - _ => unimplemented!(), + "macos" => exe_dir.join("lib/libribasim.dylib"), + _ => unimplemented!("Your OS is not supported yet."), }; unsafe { // Load the library From f0a61bb57e9a4bd22967aa0057e84efe33604697 Mon Sep 17 00:00:00 2001 From: "git@evetion.nl" Date: Thu, 16 May 2024 15:25:46 +0200 Subject: [PATCH 09/10] TeamCity change in 'Ribasim / Windows' project: artifact dependencies of 'Test Delwaq coupling' build configuration were updated --- .../buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml index bb3493379..a6f38a213 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestDelwaqCoupling.xml @@ -26,6 +26,10 @@ + + + + From 58a8b8572b5775f0dae34358153629d402da5fab Mon Sep 17 00:00:00 2001 From: "git@evetion.nl" Date: Thu, 16 May 2024 15:27:49 +0200 Subject: [PATCH 10/10] TeamCity change in 'Ribasim / Windows' project: runners of 'Test Ribasim Binaries' build configuration were updated --- .../buildTypes/Ribasim_Windows_TestRibasimBinaries.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimBinaries.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimBinaries.xml index a39b5dd43..7b173640a 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimBinaries.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimBinaries.xml @@ -19,8 +19,8 @@ +set D3D_HOME=%teamcity.build.checkoutDir%/dimr +pixi run delwaq]]>