Skip to content

Commit 8ba2aaf

Browse files
authored
Merge pull request QMCPACK#4456 from williamfgc/ref-real-complex-QMCMain
Rename QMCAppBase and QMCMain members and one ifdef QMC_COMPLEX
2 parents 8206509 + 7c8637f commit 8ba2aaf

File tree

5 files changed

+92
-85
lines changed

5 files changed

+92
-85
lines changed

src/QMCApp/QMCAppBase.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ QMCAppBase::QMCAppBase() = default;
2121

2222
QMCAppBase::~QMCAppBase()
2323
{
24-
while (!XmlDocStack.empty())
24+
while (!xml_doc_stack_.empty())
2525
{
2626
popDocument();
2727
}
@@ -33,7 +33,7 @@ bool QMCAppBase::pushDocument(const std::string& infile)
3333
bool success = adoc->parse(infile);
3434
if (success)
3535
{
36-
XmlDocStack.push(adoc);
36+
xml_doc_stack_.push(adoc);
3737
}
3838
else
3939
{
@@ -45,12 +45,12 @@ bool QMCAppBase::pushDocument(const std::string& infile)
4545

4646
void QMCAppBase::popDocument()
4747
{
48-
if (!XmlDocStack.empty())
48+
if (!xml_doc_stack_.empty())
4949
//Check if the stack is empty
5050
{
51-
Libxml2Document* adoc = XmlDocStack.top();
51+
Libxml2Document* adoc = xml_doc_stack_.top();
5252
delete adoc;
53-
XmlDocStack.pop();
53+
xml_doc_stack_.pop();
5454
}
5555
}
5656

@@ -69,15 +69,15 @@ bool QMCAppBase::parse(const std::string& infile)
6969

7070
void QMCAppBase::saveXml()
7171
{
72-
if (!XmlDocStack.empty())
72+
if (!xml_doc_stack_.empty())
7373
{
74-
std::string newxml(myProject.currentMainRoot());
74+
std::string newxml(my_project_.currentMainRoot());
7575
newxml.append(".cont.xml");
7676
app_log() << "\n========================================================="
7777
<< "\n A new xml input file : " << newxml << std::endl;
78-
XmlDocStack.top()->dump(newxml);
78+
xml_doc_stack_.top()->dump(newxml);
7979
}
8080
}
8181

82-
const std::string& QMCAppBase::getTitle() const { return myProject.getTitle(); }
82+
const std::string& QMCAppBase::getTitle() const { return my_project_.getTitle(); }
8383
} // namespace qmcplusplus

src/QMCApp/QMCAppBase.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ class QMCAppBase
6161

6262
protected:
6363
///stack of xml document
64-
std::stack<Libxml2Document*> XmlDocStack;
64+
std::stack<Libxml2Document*> xml_doc_stack_;
6565

6666
///project description
67-
ProjectData myProject;
67+
ProjectData my_project_;
6868

6969
///random number controller
70-
RandomNumberControl myRandomControl;
70+
RandomNumberControl my_random_control_;
7171

7272
///open a new document
7373
bool pushDocument(const std::string& infile);

src/QMCApp/QMCMain.cpp

+55-58
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace qmcplusplus
6060
QMCMain::QMCMain(Communicate* c)
6161
: QMCMainState(c),
6262
QMCAppBase(),
63-
FirstQMC(true)
63+
first_qmc_(true)
6464
#if !defined(REMOVE_TRACEMANAGER)
6565
,
6666
traces_xml(NULL)
@@ -116,13 +116,11 @@ QMCMain::QMCMain(Communicate* c)
116116
}
117117
app_summary() << "\n Precision used in this calculation, see definitions in the manual:"
118118
<< "\n Base precision = " << GET_MACRO_VAL(OHMMS_PRECISION)
119-
<< "\n Full precision = " << GET_MACRO_VAL(OHMMS_PRECISION_FULL)
120-
<< std::endl;
119+
<< "\n Full precision = " << GET_MACRO_VAL(OHMMS_PRECISION_FULL) << std::endl;
121120

122121
// Record features configured in cmake or selected via command-line arguments to the printout
123122
app_summary() << std::endl;
124-
#if !defined(ENABLE_OFFLOAD) && !defined(ENABLE_CUDA) && !defined(ENABLE_HIP) && \
125-
!defined(ENABLE_SYCL)
123+
#if !defined(ENABLE_OFFLOAD) && !defined(ENABLE_CUDA) && !defined(ENABLE_HIP) && !defined(ENABLE_SYCL)
126124
app_summary() << " CPU only build" << std::endl;
127125
#else // GPU case
128126
#if defined(ENABLE_OFFLOAD)
@@ -141,11 +139,10 @@ QMCMain::QMCMain(Communicate* c)
141139
#endif
142140
#endif // GPU case end
143141

144-
#ifdef QMC_COMPLEX
145-
app_summary() << " Complex build. QMC_COMPLEX=ON" << std::endl;
146-
#else
147-
app_summary() << " Real build. QMC_COMPLEX=OFF" << std::endl;
148-
#endif
142+
if (my_project_.isComplex())
143+
app_summary() << " Complex build. QMC_COMPLEX=ON" << std::endl;
144+
else
145+
app_summary() << " Real build. QMC_COMPLEX=OFF" << std::endl;
149146

150147
#ifdef ENABLE_TIMERS
151148
app_summary() << " Timer build option is enabled. Current timer level is "
@@ -161,23 +158,23 @@ QMCMain::QMCMain(Communicate* c)
161158
QMCMain::~QMCMain()
162159
{
163160
// free last_driver before clearing P,Psi,H clones
164-
last_driver.reset();
161+
last_driver_.reset();
165162
CloneManager::clearClones();
166163
}
167164

168165

169166
bool QMCMain::execute()
170167
{
171168
Timer t0;
172-
if (XmlDocStack.empty())
169+
if (xml_doc_stack_.empty())
173170
{
174171
ERRORMSG("No valid input file exists! Aborting QMCMain::execute")
175172
return false;
176173
}
177174

178175
std::string simulationType = "realspaceQMC";
179176
{ // mmorales: is this necessary??? Don't want to leave xmlNodes lying around unused
180-
xmlNodePtr cur = XmlDocStack.top()->getRoot();
177+
xmlNodePtr cur = xml_doc_stack_.top()->getRoot();
181178
OhmmsAttributeSet simType;
182179
simType.add(simulationType, "type");
183180
simType.add(simulationType, "name");
@@ -194,11 +191,11 @@ bool QMCMain::execute()
194191
<< "/*************************************************\n"
195192
<< " ******** This is an AFQMC calculation ********\n"
196193
<< " *************************************************" << std::endl;
197-
xmlNodePtr cur = XmlDocStack.top()->getRoot();
194+
xmlNodePtr cur = xml_doc_stack_.top()->getRoot();
198195

199-
xmlXPathContextPtr m_context = XmlDocStack.top()->getXPathContext();
196+
xmlXPathContextPtr m_context = xml_doc_stack_.top()->getXPathContext();
200197
//initialize the random number generator
201-
xmlNodePtr rptr = myRandomControl.initialize(m_context);
198+
xmlNodePtr rptr = my_random_control_.initialize(m_context);
202199

203200
auto world = boost::mpi3::environment::get_world_instance();
204201
afqmc::AFQMCFactory afqmc_fac(world);
@@ -207,7 +204,7 @@ bool QMCMain::execute()
207204
app_log() << " Error in AFQMCFactory::parse() ." << std::endl;
208205
return false;
209206
}
210-
cur = XmlDocStack.top()->getRoot();
207+
cur = xml_doc_stack_.top()->getRoot();
211208
return afqmc_fac.execute(cur);
212209
}
213210
#else
@@ -250,11 +247,11 @@ bool QMCMain::execute()
250247
Timer t1;
251248
curMethod = std::string("invalid");
252249
qmc_common.qmc_counter = 0;
253-
for (int qa = 0; qa < m_qmcaction.size(); qa++)
250+
for (int qa = 0; qa < qmc_action_.size(); qa++)
254251
{
255252
if (run_time_manager.isStopNeeded())
256253
break;
257-
xmlNodePtr cur = m_qmcaction[qa].first;
254+
xmlNodePtr cur = qmc_action_[qa].first;
258255
std::string cname((const char*)cur->name);
259256
if (cname == "qmc" || cname == "optimize")
260257
{
@@ -279,32 +276,32 @@ bool QMCMain::execute()
279276
}
280277
}
281278
// free if m_qmcation owns the memory of xmlNodePtr before clearing
282-
for (auto& qmcactionPair : m_qmcaction)
279+
for (auto& qmcactionPair : qmc_action_)
283280
if (!qmcactionPair.second)
284281
xmlFreeNode(qmcactionPair.first);
285282

286-
m_qmcaction.clear();
283+
qmc_action_.clear();
287284
t2->stop();
288285
app_log() << " Total Execution time = " << std::setprecision(4) << t1.elapsed() << " secs" << std::endl;
289286
if (is_manager())
290287
{
291288
//generate multiple files
292289
xmlNodePtr mcptr = NULL;
293-
if (m_walkerset.size())
294-
mcptr = m_walkerset[0];
290+
if (walker_set_.size())
291+
mcptr = walker_set_[0];
295292
//remove input mcwalkerset but one
296-
for (int i = 1; i < m_walkerset.size(); i++)
293+
for (int i = 1; i < walker_set_.size(); i++)
297294
{
298-
xmlUnlinkNode(m_walkerset[i]);
299-
xmlFreeNode(m_walkerset[i]);
295+
xmlUnlinkNode(walker_set_[i]);
296+
xmlFreeNode(walker_set_[i]);
300297
}
301-
m_walkerset.clear(); //empty the container
298+
walker_set_.clear(); //empty the container
302299
std::ostringstream np_str, v_str;
303300
np_str << myComm->size();
304301
HDFVersion cur_version;
305302
v_str << cur_version[0] << " " << cur_version[1];
306303
xmlNodePtr newmcptr = xmlNewNode(NULL, (const xmlChar*)"mcwalkerset");
307-
xmlNewProp(newmcptr, (const xmlChar*)"fileroot", (const xmlChar*)myProject.currentMainRoot().c_str());
304+
xmlNewProp(newmcptr, (const xmlChar*)"fileroot", (const xmlChar*)my_project_.currentMainRoot().c_str());
308305
xmlNewProp(newmcptr, (const xmlChar*)"node", (const xmlChar*)"-1");
309306
xmlNewProp(newmcptr, (const xmlChar*)"nprocs", (const xmlChar*)np_str.str().c_str());
310307
xmlNewProp(newmcptr, (const xmlChar*)"version", (const xmlChar*)v_str.str().c_str());
@@ -315,7 +312,7 @@ bool QMCMain::execute()
315312
//#endif
316313
if (mcptr == NULL)
317314
{
318-
xmlAddNextSibling(lastInputNode, newmcptr);
315+
xmlAddNextSibling(last_input_node_, newmcptr);
319316
}
320317
else
321318
{
@@ -359,7 +356,7 @@ void QMCMain::executeLoop(xmlNodePtr cur)
359356
}
360357
}
361358
// Destroy the last driver at the end of a loop with no further reuse of a driver needed.
362-
last_driver.reset(nullptr);
359+
last_driver_.reset(nullptr);
363360
}
364361

365362
bool QMCMain::executeQMCSection(xmlNodePtr cur, bool reuse)
@@ -375,7 +372,7 @@ bool QMCMain::executeQMCSection(xmlNodePtr cur, bool reuse)
375372
if (qmcSystem == 0)
376373
qmcSystem = ptclPool->getWalkerSet(target);
377374
bool success = runQMC(cur, reuse);
378-
FirstQMC = false;
375+
first_qmc_ = false;
379376
return success;
380377
}
381378

@@ -395,27 +392,27 @@ bool QMCMain::executeQMCSection(xmlNodePtr cur, bool reuse)
395392
*/
396393
bool QMCMain::validateXML()
397394
{
398-
xmlXPathContextPtr m_context = XmlDocStack.top()->getXPathContext();
395+
xmlXPathContextPtr m_context = xml_doc_stack_.top()->getXPathContext();
399396
OhmmsXPathObject result("//project", m_context);
400-
myProject.setCommunicator(myComm);
397+
my_project_.setCommunicator(myComm);
401398
if (result.empty())
402399
{
403400
app_warning() << "Project is not defined" << std::endl;
404-
myProject.reset();
401+
my_project_.reset();
405402
}
406403
else
407404
{
408405
try
409406
{
410-
myProject.put(result[0]);
407+
my_project_.put(result[0]);
411408
}
412409
catch (const UniformCommunicateError& ue)
413410
{
414411
myComm->barrier_and_abort(ue.what());
415412
}
416413
}
417414
app_summary() << std::endl;
418-
myProject.get(app_summary());
415+
my_project_.get(app_summary());
419416
app_summary() << std::endl;
420417
OhmmsXPathObject ham("//hamiltonian", m_context);
421418
if (ham.empty())
@@ -447,10 +444,10 @@ bool QMCMain::validateXML()
447444
}
448445

449446
//initialize the random number generator
450-
xmlNodePtr rptr = myRandomControl.initialize(m_context);
447+
xmlNodePtr rptr = my_random_control_.initialize(m_context);
451448
//preserve the input order
452-
xmlNodePtr cur = XmlDocStack.top()->getRoot()->children;
453-
lastInputNode = NULL;
449+
xmlNodePtr cur = xml_doc_stack_.top()->getRoot()->children;
450+
last_input_node_ = NULL;
454451
while (cur != NULL)
455452
{
456453
std::string cname((const char*)cur->name);
@@ -476,7 +473,7 @@ bool QMCMain::validateXML()
476473
bool success = pushDocument(include_name);
477474
if (success)
478475
{
479-
inputnode = processPWH(XmlDocStack.top()->getRoot());
476+
inputnode = processPWH(xml_doc_stack_.top()->getRoot());
480477
popDocument();
481478
}
482479
else
@@ -503,11 +500,11 @@ bool QMCMain::validateXML()
503500
else
504501
{
505502
//everything else goes to m_qmcaction
506-
m_qmcaction.push_back(std::pair<xmlNodePtr, bool>(cur, true));
503+
qmc_action_.push_back(std::pair<xmlNodePtr, bool>(cur, true));
507504
inputnode = false;
508505
}
509506
if (inputnode)
510-
lastInputNode = cur;
507+
last_input_node_ = cur;
511508
cur = cur->next;
512509
}
513510

@@ -585,7 +582,7 @@ bool QMCMain::processPWH(xmlNodePtr cur)
585582
else
586583
//add to m_qmcaction
587584
{
588-
m_qmcaction.push_back(std::pair<xmlNodePtr, bool>(xmlCopyNode(cur, 1), false));
585+
qmc_action_.push_back(std::pair<xmlNodePtr, bool>(xmlCopyNode(cur, 1), false));
589586
}
590587
cur = cur->next;
591588
}
@@ -604,11 +601,11 @@ bool QMCMain::runQMC(xmlNodePtr cur, bool reuse)
604601
std::unique_ptr<QMCDriverInterface> qmc_driver;
605602
bool append_run = false;
606603

607-
if (reuse && last_driver)
608-
qmc_driver = std::move(last_driver);
604+
if (reuse && last_driver_)
605+
qmc_driver = std::move(last_driver_);
609606
else
610607
{
611-
QMCDriverFactory driver_factory(myProject);
608+
QMCDriverFactory driver_factory(my_project_);
612609
try
613610
{
614611
QMCDriverFactory::DriverAssemblyState das = driver_factory.readSection(cur);
@@ -624,24 +621,24 @@ bool QMCMain::runQMC(xmlNodePtr cur, bool reuse)
624621

625622
if (qmc_driver)
626623
{
627-
if (last_branch_engine_legacy_driver)
624+
if (last_branch_engine_legacy_driver_)
628625
{
629-
last_branch_engine_legacy_driver->resetRun(cur);
630-
qmc_driver->setBranchEngine(std::move(last_branch_engine_legacy_driver));
626+
last_branch_engine_legacy_driver_->resetRun(cur);
627+
qmc_driver->setBranchEngine(std::move(last_branch_engine_legacy_driver_));
631628
}
632629

633630
//advance the project id
634631
//if it is NOT the first qmc node and qmc/@append!='yes'
635-
if (!FirstQMC && !append_run)
636-
myProject.advance();
632+
if (!first_qmc_ && !append_run)
633+
my_project_.advance();
637634

638-
qmc_driver->setStatus(myProject.currentMainRoot(), "", append_run);
635+
qmc_driver->setStatus(my_project_.currentMainRoot(), "", append_run);
639636
// PD:
640-
// Q: How does m_walkerset_in end up being non empty?
637+
// Q: How does walker_set_in end up being non empty?
641638
// A: Anytime that we aren't doing a restart.
642639
// So put walkers is an exceptional call. This code does not tell a useful
643640
// story of a QMCDriver's life.
644-
qmc_driver->putWalkers(m_walkerset_in);
641+
qmc_driver->putWalkers(walker_set_in_);
645642
#if !defined(REMOVE_TRACEMANAGER)
646643
qmc_driver->putTraces(traces_xml);
647644
#endif
@@ -652,10 +649,10 @@ bool QMCMain::runQMC(xmlNodePtr cur, bool reuse)
652649
qmc_driver->run();
653650
app_log() << " QMC Execution time = " << std::setprecision(4) << qmcTimer.elapsed() << " secs" << std::endl;
654651
// transfer the states of a driver before its destruction
655-
last_branch_engine_legacy_driver = qmc_driver->getBranchEngine();
652+
last_branch_engine_legacy_driver_ = qmc_driver->getBranchEngine();
656653
// save the driver in a driver loop
657654
if (reuse)
658-
last_driver = std::move(qmc_driver);
655+
last_driver_ = std::move(qmc_driver);
659656
return true;
660657
}
661658
else
@@ -676,8 +673,8 @@ bool QMCMain::setMCWalkers(xmlXPathContextPtr context_)
676673
for (int iconf = 0; iconf < result.size(); iconf++)
677674
{
678675
xmlNodePtr mc_ptr = result[iconf];
679-
m_walkerset.push_back(mc_ptr);
680-
m_walkerset_in.push_back(mc_ptr);
676+
walker_set_.push_back(mc_ptr);
677+
walker_set_in_.push_back(mc_ptr);
681678
}
682679
//use the last mcwalkerset to initialize random numbers if possible
683680
if (result.size())

0 commit comments

Comments
 (0)