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