artdaq_mpich_plugin  v1_00_13
DataLoggerMain.cc
1 #include <boost/lexical_cast.hpp>
2 #include <boost/program_options.hpp>
3 #include <iostream>
4 #include "artdaq-mpich-plugin/Application/MPISentry.hh"
5 #include "artdaq/Application/DataLoggerApp.hh"
6 #include "artdaq/Application/LoadParameterSet.hh"
7 #include "artdaq/Application/TaskType.hh"
8 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
9 #include "artdaq/DAQdata/Globals.hh"
10 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
11 #include "cetlib_except/exception.h"
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::DataLoggerTask,
25  local_group_comm));
26  }
27  catch (cet::exception& errormsg)
28  {
29  TLOG_ERROR("DataLoggerMain") << errormsg;
30  TLOG_ERROR("DataLoggerMain") << "MPISentry error encountered in DataLoggerMain; exiting...";
31  throw errormsg;
32  }
33 
34  struct Config
35  {
36  fhicl::TableFragment<artdaq::CommanderInterface::Config> commander_config;
37  fhicl::Atom<std::string> application_name{fhicl::Name{"application_name"},
38  fhicl::Comment{"Name of the application for metrics and logging"},
39  "DataLogger"};
40  fhicl::TableFragment<artdaq::PortManager::Config> portsConfig;
41  };
42 
43  fhicl::ParameterSet config =
44  LoadParameterSet<Config>(argc, argv, "DataLoggerMain", "This is the DataLogger's main executable (MPI version)");
45  app_name = config.get<std::string>("application_name", "DataLogger");
46  portMan->UpdateConfiguration(config);
47  std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config.get<int>("id"));
48  artdaq::configureMessageFacility(mf_app_name.c_str());
49  TLOG_DEBUG(app_name + "Main") << "Setting application name to " << mf_app_name;
50 
51  // 23-May-2018, KAB: added lookup of the partition number from the command line arguments.
52  if (config.has_key("partition_number"))
53  {
54  artdaq::Globals::partition_number_ = config.get<int>("partition_number");
55  }
56  TLOG_DEBUG(app_name + "Main") << "Setting partition number to " << artdaq::Globals::partition_number_;
57 
58  TLOG_INFO(app_name + "Main") << "artdaq version "
59  << artdaq::GetPackageBuildInfo::getPackageBuildInfo().getPackageVersion() << ", built "
60  << artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp();
61 
62  // create the DataLoggerApp
63  my_rank = mpiSentry->rank();
64  artdaq::DataLoggerApp dl_app;
65 
66  auto commander = artdaq::MakeCommanderPlugin(config, dl_app);
67  TLOG_INFO(app_name + "Main") << "Running Commmander Server";
68  commander->run_server();
69  artdaq::Globals::CleanUpGlobals();
70  TLOG_INFO(app_name + "Main") << "Commandable Server ended, exiting...";
71 }
The MPISentry class initializes and finalizes the MPI context that the artdaq applciations run in...
Definition: MPISentry.hh:14
int rank() const
Get the MPI rank of the application.
Definition: MPISentry.cc:74