9 #include <boost/program_options/errors.hpp>
10 #include <boost/program_options/options_description.hpp>
11 #include <boost/program_options/parsers.hpp>
12 #include <boost/program_options/variables_map.hpp>
14 #include <coolfluid-paths.hpp>
28 using namespace boost;
35 int main(
int argc,
char *argv[])
37 std::string error_string;
41 std::string hostfile(
"./machine.txt");
43 boost::program_options::options_description
desc(
"Allowed options");
46 (
"help",
"Prints this help message and exits")
47 (
"port", program_options::value<int>(&port)->default_value(port),
48 "Port to use for network communications.")
49 (
"np", program_options::value<Uint>(&nb_workers)->default_value(nb_workers),
50 "Number of MPI workers to spawn.")
51 (
"hostfile", program_options::value<std::string>(&hostfile)->default_value(hostfile),
55 AssertionManager::instance().AssertionDumps =
true;
56 AssertionManager::instance().AssertionThrows =
true;
59 Core::instance().network_info().start_server();
63 Core& cf_env = Core::instance();
66 program_options::variables_map vm;
67 program_options::store(program_options::parse_command_line(argc, argv, desc), vm);
68 program_options::notify(vm);
70 if ( vm.count(
"help") > 0 )
72 std::cout <<
"Usage: " << argv[0] <<
" [--port <port-number>] "
73 "[--np <workers-count>] [--hostfile <hostfile>]" << std::endl;
74 std::cout << desc << std::endl;
82 PE::Comm::instance().init( argc, argv );
83 ServerRoot::instance().root();
85 if( Comm::instance().size() != 1 )
86 error_string =
"This application is not designed to run in parallel.";
89 error_string =
"At least 1 worker must be spawn.";
94 mgr->
spawn_group(
"Workers", nb_workers, CF3_BUILD_DIR
"/cf3/Tools/solver/coolfluid-solver");
96 std::cout << getpid() << std::endl;
99 if(port < 49153 || port > 65535)
100 error_string =
"Port number must be an integer between 49153 and 65535\n";
101 else if( error_string.empty() )
111 PE::Comm::instance().finalize();
116 catch(program_options::error & error)
118 error_string = error.what();
122 error_string = ne.
what();
124 catch(std::string str)
126 error_string = str.c_str();
128 catch ( std::exception&
e )
130 error_string = e.what();
134 error_string =
"Unknown exception thrown and not caught !!!\n";
137 if(!error_string.empty())
139 std::cerr << std::endl << std::endl;
140 std::cerr <<
"Server application exited on error:" << std::endl;
141 std::cerr << error_string << std::endl;
142 std::cerr <<
"Aborting ..." << std::endl << std::endl << std::endl;
147 Core::instance().network_info().stop_server();
Exception thrown when the server can not open its socket.
boost::python::object get_child(ComponentWrapper &self, const std::string &name)
Safe pointer to an object. This is the supported method for referring to components.
external boost library namespace
Real e()
Definition of the Unit charge [C].
const char * what() const
void spawn_group(const std::string &name, Uint nb_workers, const char *command, const std::string &forward=std::string(), const char *hosts=nullptr)
void initiate(int argc, char **argv)
Top-level namespace for coolfluid.
bool listen_to_port(cf3::Uint portNumber)
LoadBalance::LoadBalance(const std::string &name) std::string desc
int main(int argc, char *argv[])
unsigned int Uint
typedef for unsigned int
Classes offering a MPI interface for COOLFluiD.
Most basic kernel library.