From 2f70312203c26d84c713e9d4092718c7413fb1d2 Mon Sep 17 00:00:00 2001 From: John Omotani Date: Thu, 5 Dec 2024 12:25:22 +0000 Subject: [PATCH] Fix "Enable using wall bc in preconditioner for ADI preconditioner" When called from within a parallelised loop, like the implicit-v ADI preconditioner, we cannot change the shared-memory region type. --- moment_kinetics/src/electron_kinetic_equation.jl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/moment_kinetics/src/electron_kinetic_equation.jl b/moment_kinetics/src/electron_kinetic_equation.jl index eb8821fc4..a033fe3b6 100644 --- a/moment_kinetics/src/electron_kinetic_equation.jl +++ b/moment_kinetics/src/electron_kinetic_equation.jl @@ -3123,6 +3123,7 @@ boundary condition on those entries of δg (when the right-hand-side is set to z vthe_upper = vthe[end] upar_lower = upar[1] upar_upper = upar[end] + shared_mem_parallel = true elseif include === :implicit_v include_lower = (z.irank == 0) && iz == 1 include_upper = (z.irank == z.nrank - 1) && iz == z.n @@ -3132,12 +3133,16 @@ boundary condition on those entries of δg (when the right-hand-side is set to z ppar_lower = ppar_upper = ppar vthe_lower = vthe_upper = vthe upar_lower = upar_upper = upar + + # When using :implicit_v, this function is called inside a loop that is already + # parallelised over z, so we cannot change the parallel region type. + shared_mem_parallel = false else return nothing end if include_lower - begin_vperp_region() + shared_mem_parallel && begin_vperp_region() @loop_vperp ivperp begin # Skip velocity space boundary points. if vperp.n > 1 && ivperp == vperp.n @@ -3629,7 +3634,7 @@ boundary condition on those entries of δg (when the right-hand-side is set to z end if include_upper - begin_vperp_region() + shared_mem_parallel && begin_vperp_region() @loop_vperp ivperp begin # Skip vperp boundary points. if vperp.n > 1 && ivperp == vperp.n