Skip to content

Commit

Permalink
add initialize! check_units_opt keyword to check linked Variable unit…
Browse files Browse the repository at this point in the history
…s are consistent

initialize!(...): add `check_units_opt` keyword: check linked Variable units are consistent
  :no to disable check (default)
  :warn to warn and continue
  :error to error and stop
  • Loading branch information
sjdaines committed Jun 20, 2024
1 parent 44ecaef commit 0220f6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ JLD2 = "0.4"
MultiFloats = "1.0, 2.0"
NCDatasets = "0.12, 0.14.2"
NLsolve = "4.5"
PALEOboxes = "0.21.24"
PALEOboxes = "0.21.29"
RecipesBase = "1.2"
Requires = "1.0"
Revise = "3.1"
Expand Down
8 changes: 5 additions & 3 deletions src/Initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and supplying `method_barrier` (a thread barrier to add to `ReactionMethod` disp
# Keyword summary
- `pickup_output=nothing`: OutputWriter with pickup data to initialise from
- `check_units_opt=:no`: check linked Variable units are consistent (:no to disable check, :warn to warn and continue, :error to error and stop)
- `eltype::Type=Float64`: default data type to use for model arrays
- `eltypemap=Dict{String, DataType}()`: Dict of data types to look up Variable :datatype attribute
- `threadsafe=false`: true to create thread safe Atomic Variables where Variable attribute `:atomic==true`
Expand All @@ -37,9 +38,10 @@ and supplying `method_barrier` (a thread barrier to add to `ReactionMethod` disp
"""
function initialize!(
model::PB.Model;
eltype=Float64,
eltypemap=Dict{String, DataType}(),
pickup_output::Union{Nothing, AbstractOutputWriter}=nothing,
check_units_opt=:no,
eltype=Float64,
eltypemap=Dict{String, DataType}(),
threadsafe=false,
method_barrier=threadsafe ?
PB.reaction_method_thread_barrier(
Expand All @@ -62,7 +64,7 @@ function initialize!(
modeldata = PB.create_modeldata(model, eltype; threadsafe)

# Allocate variables
@timeit "allocate_variables" PB.allocate_variables!(model, modeldata, 1; eltypemap)
@timeit "allocate_variables" PB.allocate_variables!(model, modeldata, 1; eltypemap, check_units_opt)

# check all variables allocated
PB.check_ready(model, modeldata; expect_hostdep_varnames)
Expand Down

0 comments on commit 0220f6c

Please sign in to comment.