artdaq_mpich_plugin  v1_00_00
RoutingMasterMain.cc
1 #include <iostream>
2 #include <boost/program_options.hpp>
3 #include <boost/lexical_cast.hpp>
4 #include "artdaq/Application/TaskType.hh"
5 #include "artdaq/Application/RoutingMasterApp.hh"
6 #include "artdaq/Application/LoadParameterSet.hh"
7 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
8 #include "artdaq-mpich-plugin/Application/MPISentry.hh"
9 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
10 #include "cetlib_except/exception.h"
11 #include "artdaq/DAQdata/Globals.hh"
12 
13 int main(int argc, char* argv[])
14 {
15  // initialization
16 
17  int const wanted_threading_level{ MPI_THREAD_FUNNELED };
18 
19  MPI_Comm local_group_comm;
20  std::unique_ptr<artdaq::MPISentry> mpiSentry;
21 
22  try
23  {
24  mpiSentry.reset(new artdaq::MPISentry(&argc, &argv, wanted_threading_level, artdaq::TaskType::RoutingMasterTask, local_group_comm));
25  }
26  catch (cet::exception& errormsg)
27  {
28  TLOG_ERROR("RoutingMasterMain") << errormsg ;
29  TLOG_ERROR("RoutingMasterMain") << "MPISentry error encountered in RoutingMasterMain; exiting..." ;
30  throw errormsg;
31  }
32 
33  fhicl::ParameterSet config_ps = LoadParameterSet(argc, argv);
34  app_name = config_ps.get<std::string>("application_name", "RoutingMaster");
35  std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config_ps.get<int>("id"));
36  artdaq::configureMessageFacility(mf_app_name.c_str());
37  TLOG_DEBUG(app_name + "Main") << "Setting application name to " << mf_app_name ;
38 
39 
40  TLOG_INFO(app_name + "Main") << "artdaq version " <<
41  artdaq::GetPackageBuildInfo::getPackageBuildInfo().getPackageVersion()
42  << ", built " <<
43  artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp() ;
44 
45  // create the RoutingMasterApp
46  my_rank = mpiSentry->rank();
47  artdaq::RoutingMasterApp rm_app;
48 
49  auto commander = artdaq::MakeCommanderPlugin(config_ps, rm_app);
50  TLOG_INFO(app_name + "Main") << "Running Commmander Server" ;
51  commander->run_server();
52  TLOG_INFO(app_name + "Main") << "Commandable Server ended, exiting..." ;
53 }
The MPISentry class initializes and finalizes the MPI context that the artdaq applciations run in...
Definition: MPISentry.hh:15
int rank() const
Get the MPI rank of the application.
Definition: MPISentry.cc:113