+int smpi_main(int (*realmain) (int argc, char *argv[]),int argc, char *argv[])
+{
+ srand(SMPI_RAND_SEED);
+
+ if(getenv("SMPI_PRETEND_CC") != NULL) {
+ /* Hack to ensure that smpicc can pretend to be a simple compiler. Particularly handy to pass it to the configuration tools */
+ return 0;
+ }
+
+ /* Connect log categories. See xbt/log.c */
+ XBT_LOG_CONNECT(smpi); /* Keep this line as soon as possible in this
+ function: xbt_log_appender_file.c depends on it
+ DO NOT connect this in XBT or so, or it will be
+ useless to xbt_log_appender_file.c */
+#ifdef HAVE_TRACING
+ XBT_LOG_CONNECT(instr_smpi);
+#endif
+ XBT_LOG_CONNECT(smpi_base);
+ XBT_LOG_CONNECT(smpi_bench);
+ XBT_LOG_CONNECT(smpi_coll);
+ XBT_LOG_CONNECT(smpi_comm);
+ XBT_LOG_CONNECT(smpi_group);
+ XBT_LOG_CONNECT(smpi_kernel);
+ XBT_LOG_CONNECT(smpi_mpi);
+ XBT_LOG_CONNECT(smpi_mpi_dt);
+ XBT_LOG_CONNECT(smpi_pmpi);
+ XBT_LOG_CONNECT(smpi_replay);
+ XBT_LOG_CONNECT(smpi_colls);
+
+#ifdef HAVE_TRACING
+ TRACE_global_init(&argc, argv);
+
+ TRACE_add_start_function(TRACE_smpi_alloc);
+ TRACE_add_end_function(TRACE_smpi_release);
+#endif
+
+ SIMIX_global_init(&argc, argv);
+
+#ifdef HAVE_TRACING
+ TRACE_start();
+#endif
+
+ // parse the platform file: get the host list
+ SIMIX_create_environment(argv[1]);
+
+ SIMIX_function_register_default(realmain);
+ SIMIX_launch_application(argv[2]);
+
+ smpi_global_init();
+
+ /* Clean IO before the run */
+ fflush(stdout);
+ fflush(stderr);
+
+ if (MC_is_active())
+ MC_modelcheck_safety();
+ else
+ SIMIX_run();
+
+ if (sg_cfg_get_int("smpi/display_timing"))
+ XBT_INFO("Simulation time: %g seconds.", SIMIX_get_clock());
+
+ smpi_global_destroy();
+
+#ifdef HAVE_TRACING
+ TRACE_end();
+#endif
+
+ return 0;