#include <boost/tokenizer.hpp>
#include <boost/algorithm/string.hpp> /* trim_right / trim_left */
+#if SMPI_IFORT
+ extern "C" void for_rtl_init_ (int *, char **);
+ extern "C" void for_rtl_finish_ ();
+#elif SMPI_FLANG
+ extern "C" void __io_set_argc(int);
+ extern "C" void __io_set_argv(char **);
+#elif SMPI_GFORTRAN
+ extern "C" void _gfortran_set_args(int, char **);
+#endif
+
#ifndef RTLD_DEEPBIND
/* RTLD_DEEPBIND is a bad idea of GNU ld that obviously does not exist on other platforms
* See https://www.akkadia.org/drepper/dsohowto.pdf
static int smpi_run_entry_point(smpi_entry_point_type entry_point, std::vector<std::string> args)
{
char noarg[] = {'\0'};
- const int argc = args.size();
- std::unique_ptr<char*[]> argv(new char*[argc + 1]);
+ int argc = args.size();
+ char** argv = new char*[argc + 1];
for (int i = 0; i != argc; ++i)
- argv[i] = args[i].empty() ? noarg : &args[i].front();
+ argv[i] = args[i].empty() ? noarg : xbt_strdup(&args[i].front());
argv[argc] = nullptr;
+ simgrid::smpi::ActorExt::init(&argc, &argv);
+#if SMPI_IFORT
+ for_rtl_init_ (&argc, argv);
+#elif SMPI_FLANG
+ __io_set_argc(argc);
+ __io_set_argv(argvptr);
+#elif SMPI_GFORTRAN
+ _gfortran_set_args(argc, argv);
+#endif
+ int res = entry_point(argc, argv);
+
+#if SMPI_IFORT
+ for_rtl_finish_ ();
+#endif
- int res = entry_point(argc, argv.get());
+ for (int i = 0; i != argc; ++i)
+ xbt_free(argv[i]);
+ xbt_free(argv);
if (res != 0){
XBT_WARN("SMPI process did not return 0. Return value : %d", res);
if (smpi_exit_status == 0)
smpi_fortran_entry_point_type entry_point_fortran = (smpi_fortran_entry_point_type)dlsym(handle, "user_main_");
if (entry_point_fortran != nullptr) {
return [entry_point_fortran](int argc, char** argv) {
- smpi_process_init(&argc, &argv);
entry_point_fortran();
return 0;
};
smpi_init_options();
smpi_global_init();
smpi_check_options();
- simgrid::s4u::on_simulation_end.connect(TRACE_smpi_release);
}
void SMPI_finalize(){