From 5b036b82ff3babfa79639fd066dd4d90a0b6ff2b Mon Sep 17 00:00:00 2001 From: John Omotani Date: Mon, 16 Sep 2024 21:52:31 +0100 Subject: [PATCH] When we catch an exception, print it to stderr before calling MPI.Abort Previously, we were printing to stdout, but this makes it more likely for the error message and stack trace to get lost, e.g. when `quietoutput()` is used in the tests. --- moment_kinetics/src/moment_kinetics.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moment_kinetics/src/moment_kinetics.jl b/moment_kinetics/src/moment_kinetics.jl index 4c57e6ed8..2fe755af2 100644 --- a/moment_kinetics/src/moment_kinetics.jl +++ b/moment_kinetics/src/moment_kinetics.jl @@ -148,8 +148,8 @@ function run_moment_kinetics(to::Union{TimerOutput,Nothing}, input_dict=Dict(); # Stop code from hanging when running on multiple processes if only one of them # throws an error if global_size[] > 1 - println("$(typeof(e)) on process $(global_rank[]):") - showerror(stdout, e, catch_backtrace()) + println(stderr, "$(typeof(e)) on process $(global_rank[]):") + showerror(stderr, e, catch_backtrace()) flush(stdout) flush(stderr) MPI.Abort(comm_world, 1)