Skip to content

Commit

Permalink
auto-adjust things on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskaus committed Apr 22, 2024
1 parent 218f0bf commit 631296d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
11 changes: 2 additions & 9 deletions scripts/TM_Subduction_example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,9 @@ model.Solver = Solver( SolverType = "multigrid",
]
)

if Sys.iswindows()
model.Solver.MGCoarseSolver = "direct" # on windows MPI + mumps does not work
ncores = 1;
else
ncores = 8
end

try testing == true
# if we run this as part of the test suite, use fewer timesteps
run_lamem(model, ncores, "-nstep_max 2 -nstep_out 1")
run_lamem(model, 8, "-nstep_max 2 -nstep_out 1")
catch
run_lamem(model, ncores)
run_lamem(model, 8)
end
23 changes: 18 additions & 5 deletions src/LaMEM_ModelGeneration/Model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ function create_initialsetup(model::Model, cores::Int64=1, args::String=""; verb

write_LaMEM_inputFile(model, model.Output.param_file_name)

# corrections for certain platforms (e.g., windows):
model, cores = adjust_for_platforms(model, cores)

if !isnothing(model.FreeSurface.Topography)
save_LaMEM_topography(model.FreeSurface.Topography, model.FreeSurface.surf_topo_file)
Expand All @@ -290,11 +292,6 @@ function create_initialsetup(model::Model, cores::Int64=1, args::String=""; verb
# write marker files to disk before running LaMEM
Model3D = CartData(model.Grid.Grid, (Phases=model.Grid.Phases,Temp=model.Grid.Temp));

if Sys.iswindows()
cores=1;
println("LaMEM_jll does not support parallel runs on windows; using 1 core instead")
end

if cores>1
PartFile = run_lamem_save_grid(model.Output.param_file_name, cores)

Expand All @@ -308,3 +305,19 @@ function create_initialsetup(model::Model, cores::Int64=1, args::String=""; verb
return nothing
end


"""
model, cores = adjust_for_platforms(model, cores::Int64)
On certain platforms we have restrictions (MPI is broken on windows currently, so we need to adjust things accordingly)
"""
function adjust_for_platforms(model, cores::Int64)

if Sys.iswindows()
println("LaMEM_jll does not support parallel runs on windows; using 1 core instead")
model.Solver.MGCoarseSolver = "direct" # on windows MPI + mumps does not work
model.Solver.DirectSolver = "direct"
end

return model, cores
end

0 comments on commit 631296d

Please sign in to comment.