QMCPACK
qmc_common.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
8 // Anouar Benali, benali@anl.gov, Argonne National Laboratory
9 // Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
10 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 // Paul R. C. Kent, kentpr@ornl.gov, Oak Ridge National Laboratory
12 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
13 //
14 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
15 //////////////////////////////////////////////////////////////////////////////////////
16 
17 
18 #include "qmc_common.h"
19 #include "config.h"
20 #include "qmcpack_version.h"
21 #include "Message/Communicate.h"
23 
24 namespace qmcplusplus
25 {
26 QMCState::QMCState() = default;
27 
28 void QMCState::initialize(int argc, char** argv)
29 {
30  io_node = (OHMMS::Controller->rank() == 0);
31  bool stopit = false;
32  //going to use better option library
33  int i = 1;
34  while (i < argc)
35  {
36  std::string c(argv[i]);
37  if (c.find("--dryrun") < c.size())
38  {
39  dryrun = true;
40  }
41  else if (c.find("--save_wfs") < c.size())
42  {
43  if (io_node)
44  std::cerr << std::endl
45  << "ERROR: command line option --save_wfs has been removed."
46  << "Use save_coefs input tag as described in the manual." << std::endl;
47  stopit = true;
48  }
49  else if (c.find("--help") < c.size())
50  {
51  stopit = true;
52  }
53  else if (c.find("--version") < c.size())
54  {
55  stopit = true;
56  }
57  else if (c.find("--vacuum") < c.size())
58  {
59  if (io_node)
60  std::cerr << std::endl
61  << "ERROR: command line option --vacuum has been removed. "
62  << "Use vacuum input tag as described in the manual." << std::endl;
63  stopit = true;
64  }
65  else if (c.find("--noprint") < c.size())
66  { //do not print Jastrow or PP
67  io_node = false;
68  }
69  ++i;
70  }
71  if (stopit && io_node)
72  {
73  std::cerr << std::endl
74  << "QMCPACK version " << QMCPACK_VERSION_MAJOR << "." << QMCPACK_VERSION_MINOR << "."
75  << QMCPACK_VERSION_PATCH << " built on " << __DATE__ << std::endl;
76  print_git_info_if_present(std::cerr);
77  std::cerr << std::endl << "Usage: qmcpack input [--dryrun --gpu]" << std::endl << std::endl;
78  }
79  if (stopit)
80  {
82  exit(1);
83  }
84 }
85 
86 void QMCState::print_options(std::ostream& os)
87 {
88  os << " Global options " << std::endl;
89  if (dryrun)
90  os << " dryrun : All QMC and loop sections will be skipped." << std::endl;
91 }
92 
93 void QMCState::print_memory_change(const std::string& who, size_t before)
94 {
95  before = memory_allocated - before;
96  app_log() << "MEMORY increase " << (before >> 20) << " MB " << who << std::endl;
97 }
98 
100 {
101 #ifdef QMCPACK_GIT_BRANCH
102  os << std::endl;
103  os << " Git branch: " << QMCPACK_GIT_BRANCH << std::endl;
104  os << " Last git commit: " << QMCPACK_GIT_HASH << std::endl;
105  os << " Last git commit date: " << QMCPACK_GIT_COMMIT_LAST_CHANGED << std::endl;
106  os << " Last git commit subject: " << QMCPACK_GIT_COMMIT_SUBJECT << std::endl;
107 #endif
108 }
109 
110 
112 
113 } // namespace qmcplusplus
void print_git_info_if_present(std::ostream &os)
Print git info (commit hash, etc) if project was build from git repository.
Definition: qmc_common.cpp:99
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
QMCState()
constructor
int rank() const
return the rank
Definition: Communicate.h:116
Declaration of OutputManager class.
std::ostream & app_log()
Definition: OutputManager.h:65
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
void initialize(int argc, char **argv)
initialize options from the command-line
Definition: qmc_common.cpp:28
bool dryrun
true, if it is a dryrun
Definition: qmc_common.h:37
bool io_node
true, print out file
Definition: qmc_common.h:39
class to definte global variables to keep track a run
Definition: qmc_common.h:26
void print_options(std::ostream &os)
print command-line options
Definition: qmc_common.cpp:86
void finalize()
size_t memory_allocated
size of memory allocated in byte per MPI
Definition: qmc_common.h:29
void print_memory_change(const std::string &who, size_t before)
print memory increase
Definition: qmc_common.cpp:93
QMCState qmc_common
a unique QMCState during a run
Definition: qmc_common.cpp:111