Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LibTrixi.jl/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ version = "0.1.0"
[deps]
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Trixi = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"

[compat]
julia = "1.8"
MPI = "0.20.13"
OrdinaryDiffEq = "6.53.2"
Trixi = "0.5.29"

Expand Down
12 changes: 12 additions & 0 deletions LibTrixi.jl/src/LibTrixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module LibTrixi

using OrdinaryDiffEq: OrdinaryDiffEq, step!, check_error, DiscreteCallback
using Trixi: Trixi, summary_callback
using MPI: MPI, run_init_hooks, set_default_error_handler_return

export trixi_initialize_simulation,
trixi_initialize_simulation_cfptr,
Expand Down Expand Up @@ -38,4 +39,15 @@ function show_debug_output()
end
end

function __init__()
# MPI could have been initialized by an external application.
# In this situation MPI.jl's MPI.Init is not called and leaves some package-internal
# settings uninitialized. Recover those here.
MPI.run_init_hooks()
# Also make sure MPI returns errors, at least in debug mode
if show_debug_output()
MPI.set_default_error_handler_return()
end
end

end # module LibTrixi
12 changes: 0 additions & 12 deletions src/trixi.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,6 @@ void trixi_initialize(const char * project_directory, const char * depot_path) {
print_and_die("null pointer", LOC);
}
}

// TODO: Workaround for issue with MPI.jl: A required MPI key value is not initialized
// in case MPI has already been initialized before. With libtrixi MPI could have
// been initialized by an external application. Check if MPI is initialized but
// the key value not. In this case run the init hooks manually.
// This would better be fixed using some functionality of MPI.jl
const char * call_MPI_run_init_hook =
"using MPI;\n"
"if MPI.Initialized() && MPI.JULIA_TYPE_PTR_ATTR[]==0;\n"
" MPI.run_init_hooks();\n"
"end\n";
checked_eval_string(call_MPI_run_init_hook, LOC);
}


Expand Down