14 <<
"Type \"exit\" to quit (or Ctl-C).";
18 auto BroadcastSingleInteger = [](
int* int_being_bcast)
20 MPI_Bcast(int_being_bcast,
28 auto HomeBroadcastStringAsRaw = [](std::string string_to_bcast,
int length)
30 char* raw_string_to_bcast = string_to_bcast.data();
31 MPI_Bcast(raw_string_to_bcast,
39 auto NonHomeBroadcastStringAsRaw = [](std::string& string_to_bcast,
int length)
41 std::vector<char> raw_chars(length+1,
'\0');
42 MPI_Bcast(raw_chars.data(),
47 string_to_bcast = std::string(raw_chars.data());
51 auto LuaDoString = [
this](
const std::string& the_string)
61 auto ConsoleInputNumChars = [](
const std::string& input)
63 int L =
static_cast<int>(input.size());
64 if (input == std::string(
"exit")) L = -1;
73 std::string console_input;
75 if (HOME) std::cin >> console_input;
77 int console_input_len = ConsoleInputNumChars(console_input);
79 BroadcastSingleInteger(&console_input_len);
81 if (console_input_len < 0)
break;
83 if (HOME) HomeBroadcastStringAsRaw(console_input, console_input_len);
84 else NonHomeBroadcastStringAsRaw(console_input, console_input_len);
86 try { LuaDoString(console_input); }
91 catch(
const std::exception& e)
100 Chi::log.
Log() <<
"Console loop stopped successfully.";
static bool termination_posted_
static void Exit(int error_code)
static chi::MPI_Info & mpi
LogStream Log(LOG_LVL level=LOG_0)
lua_State * console_state_
Pointer to lua console state.
void RunConsoleLoop(char *fileName=nullptr) const
const MPI_Comm & comm
MPI communicator.
const int & location_id
Current process rank.