From db346f8237ed11188466601eabdf9d74e78bc39b Mon Sep 17 00:00:00 2001 From: Takuya Iwanaga Date: Tue, 8 Oct 2024 22:12:23 +1100 Subject: [PATCH 1/4] Remove indicated import of MAT package --- docs/src/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/getting_started.md b/docs/src/getting_started.md index 1e0e875..855859c 100644 --- a/docs/src/getting_started.md +++ b/docs/src/getting_started.md @@ -141,7 +141,7 @@ reset_rme() ```julia using ReefModEngine -using CSV, DataFrames, MAT +using CSV, DataFrames # Initialize RME (may take a minute or two) init_rme("path to RME directory") From d4560576ad2c7664c1df58aa56625b3b521ff50e Mon Sep 17 00:00:00 2001 From: Takuya Iwanaga Date: Tue, 8 Oct 2024 22:15:46 +1100 Subject: [PATCH 2/4] Try to indicate potential issue after troubles initialising RME --- src/rme_init.jl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rme_init.jl b/src/rme_init.jl index 56f12af..2ee0845 100644 --- a/src/rme_init.jl +++ b/src/rme_init.jl @@ -42,7 +42,17 @@ function init_rme(rme_path::String)::Nothing data_fp = joinpath(rme_path, "data_files") @RME setDataFilesPath(data_fp::Cstring)::Cint - @RME init(joinpath(rme_path, "data_files", "config", "config.xml")::Cstring)::Cint + + try + @RME init(joinpath(rme_path, "data_files", "config", "config.xml")::Cstring)::Cint + catch err + msg = """ + Error encountered initializing RME. + See documentation for ReefModEngine.jl and check RME config.xml file. + """ + @info msg + rethrow(err) + end rme_vers = @RME version()::Cstring @info "Loaded RME $rme_vers" From 23bfddaf5bb296ce3e7d69171a804ce70ba06eea Mon Sep 17 00:00:00 2001 From: Takuya Iwanaga Date: Wed, 9 Oct 2024 11:34:00 +1100 Subject: [PATCH 3/4] Clear whitespace --- src/ResultStore.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ResultStore.jl b/src/ResultStore.jl index 65f29b2..16040dc 100644 --- a/src/ResultStore.jl +++ b/src/ResultStore.jl @@ -264,7 +264,7 @@ function append_scenarios!(rs::ResultStore, reps::Int)::Nothing outplant_count += n_years * @getRME ivOutplantCountPerM2(name::Cstring)::Cdouble outplant_area += n_years * @getRME ivOutplantAreaPct(name::Cstring)::Cdouble outplant_locs += n_years * n_locs[1] - elseif type=="enrich" + elseif type == "enrich" n_enrichment_iv += n_years enrichment_count += n_years * @getRME ivEnrichCountPerM2(name::Cstring)::Cdouble enrichment_area += n_years * @getRME ivEnrichAreaPct(name::Cstring)::Cdouble From 23ce14d5fa5665f23b736cbe67b30f811d1bacb1 Mon Sep 17 00:00:00 2001 From: Takuya Iwanaga Date: Wed, 9 Oct 2024 11:34:59 +1100 Subject: [PATCH 4/4] Handle cases where there are no outplant scenarios --- src/ResultStore.jl | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/ResultStore.jl b/src/ResultStore.jl index 16040dc..b713a51 100644 --- a/src/ResultStore.jl +++ b/src/ResultStore.jl @@ -276,12 +276,23 @@ function append_scenarios!(rs::ResultStore, reps::Int)::Nothing n_outplant_iv = max(1, n_outplant_iv) n_enrichment_iv = max(1, n_enrichment_iv) - # Create vector for compatibility with c++ pointers. + # Create vector for compatibility with C++ pointers. dhw_tolerance_outplants::Vector{Float64} = [0.0] - @RME getOption( - "restoration_dhw_tolerance_outplants"::Cstring, - dhw_tolerance_outplants::Ptr{Cdouble} - )::Cint + + has_outplants = try + @RME getOption( + "restoration_dhw_tolerance_outplants"::Cstring, + dhw_tolerance_outplants::Ptr{Cdouble} + )::Cint + + true + catch err + if !(err isa ArgumentError) + rethrow(err) + end + + false + end df_cf::DataFrame = DataFrame( counterfactual=repeat(1, reps),