45 int main(
int argc,
char** argv)
49 mpi3::environment env(argc, argv);
57 std::vector<std::string> fgroup1, fgroup2;
61 std::string c(argv[i]);
64 if (c.find(
"clones") < c.size())
65 clones = atoi(argv[++i]);
70 if (c.find(
"-enable-timers") < c.size())
74 <<
"The '-enable-timers' command line option will have no effect. This executable was built without " 78 int pos = c.find(
"=");
79 if (pos != std::string::npos)
81 std::string timer_level = c.substr(pos + 1);
85 if (c.find(
"-verbosity") < c.size())
87 int pos = c.find(
"=");
88 if (pos != std::string::npos)
90 std::string verbose_level = c.substr(pos + 1);
91 if (verbose_level ==
"low")
95 else if (verbose_level ==
"high")
99 else if (verbose_level ==
"debug")
105 std::cerr <<
"Unknown verbosity level: " << verbose_level << std::endl;
112 if (c.find(
"xml") < c.size())
113 fgroup1.push_back(argv[i]);
116 std::ifstream fin(argv[i], std::ifstream::in);
117 bool valid = !fin.fail();
120 std::vector<std::string> words;
124 if (words[0].find(
"xml") < words[0].size())
127 if (words.size() > 1)
128 nc = atoi(words[1].c_str());
131 fgroup2.push_back(words[0]);
143 int in_files = fgroup1.size();
144 std::vector<std::string> inputs(in_files * clones + fgroup2.size());
145 copy(fgroup2.begin(), fgroup2.end(), inputs.begin());
147 for (
int k = 0; k < in_files; ++k)
148 for (
int c = 0; c < clones; ++c)
149 inputs[i++] = fgroup1[k];
154 std::cerr <<
"No input file is given." << std::endl;
155 std::cerr <<
"Usage: qmcpack <input-files> " << std::endl;
162 if (inputs.size() > 1)
166 std::ostringstream msg;
168 << inputs.size() <<
" individual calculations in the ensemble. " 169 <<
"Increase the number of MPI ranks or reduce the number of calculations." << std::endl;
175 std::stringstream logname;
176 int inpnum = (inputs.size() > 1) ? qmcComm->
getGroupID() : 0;
177 std::string myinput = inputs[qmcComm->
getGroupID()];
178 myinput = myinput.substr(0, myinput.size() - 4);
181 if (qmcComm->
rank() != 0)
186 if (inputs.size() > 1 && qmcComm->
rank() == 0)
188 std::array<char, 128> fn;
189 if (std::snprintf(fn.data(), fn.size(),
"%s.g%03d.qmc", logname.str().c_str(), qmcComm->
getGroupID()) < 0)
190 throw std::runtime_error(
"Error generating filename");
196 bool validInput =
false;
197 app_log() <<
" Input file(s): ";
198 for (
int k = 0; k < inputs.size(); ++k)
202 auto qmc = std::make_unique<QMCMain>(qmcComm);
204 if (inputs.size() > 1)
205 validInput = qmc->parse(inputs[qmcComm->
getGroupID()]);
207 validInput = qmc->parse(inputs[0]);
212 bool qmcSuccess = qmc->execute();
217 timingDoc.
newDoc(
"resources");
220 qmc->getParticlePool().output_particleset_info(timingDoc, timingDoc.
getRoot());
223 timingDoc.
dump(qmc->getTitle() +
".info.xml");
229 catch (
const std::exception&
e)
231 std::cerr <<
e.what() << std::endl;
236 APP_ABORT(
"Unhandled Exception (not derived from std::exception)");
240 std::cout << std::endl <<
"QMCPACK execution completed successfully" << std::endl;
249 xmlNodePtr hardware =
doc.
addChild(root,
"hardware");
251 bool using_mpi =
false;
258 bool using_openmp =
false;
class that handles xmlDoc
helper functions for EinsplineSetBuilder
int rank() const
return the rank
Declaration of OutputManager class.
void shutOff()
Permanently shut off all streams.
void newDoc(const std::string &rootName)
int main(int argc, char **argv)
Communicate * Controller
Global Communicator for a process.
int size() const
return the number of tasks
void redirectToFile(const std::string &fname)
Open a file and output to that file.
OutputManagerClass outputManager(Verbosity::HIGH)
void initialize(int argc, char **argv)
initialize options from the command-line
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Wrapping information on parallelism.
int getGroupID() const
return the group id
omp_int_t omp_get_max_threads()
void output_hardware_info(Communicate *comm, Libxml2Document &doc, xmlNodePtr root)
declaration of ProgressReportEngine
Declaration of QMCMain class.
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
int mpi_groups
number of mpi groups
void redirectToSameStream(InfoStream &info)
Copy a stream.
void addChild(xmlNodePtr newnode)
static void enableOutput()
TimerManager< NewTimer > & getGlobalTimerManager()
QMCState qmc_common
a unique QMCState during a run
void barrier_and_abort(const std::string &msg) const
int getwords(std::vector< std::string > &slist, std::istream &fp, std::string &aline)
void dump(const std::string &newxml)
void setVerbosity(Verbosity level)