Skip to content

Commit

Permalink
Multiprocessing issue fixed (#43)
Browse files Browse the repository at this point in the history
* Multiprocessing fixed
  • Loading branch information
JordiBolibar authored Dec 14, 2023
1 parent 7281def commit 54476a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/setup/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ function clean()
exit()
end

function enable_multiprocessing(procs::Int)
if procs > 0
function enable_multiprocessing(params::Sleipnir.Parameters)
procs::Int = params.simulation.workers
if procs > 0 && params.simulation.multiprocessing
if nprocs() < procs
@eval begin
addprocs($procs - nprocs(); exeflags="--project")
Expand Down
2 changes: 1 addition & 1 deletion src/simulations/predictions/prediction_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In-place run of the model.
"""
function run!(simulation::Prediction)

enable_multiprocessing(simulation.parameters.simulation.workers)
enable_multiprocessing(simulation.parameters)

println("Running forward in-place PDE ice flow model...\n")
results_list = @showprogress pmap((glacier_idx) -> batch_iceflow_PDE!(glacier_idx, simulation), 1:length(simulation.glaciers))
Expand Down

0 comments on commit 54476a4

Please sign in to comment.