QMCPACK
qmcfinitesize.cpp File Reference
+ Include dependency graph for qmcfinitesize.cpp:

Go to the source code of this file.

Typedefs

using RealType = QMCTraits::RealType
 
using PosType = QMCTraits::PosType
 
using Grid_t = SkParserBase::Grid_t
 

Functions

int main (int argc, char **argv)
 

Typedef Documentation

◆ Grid_t

Definition at line 49 of file qmcfinitesize.cpp.

◆ PosType

Definition at line 48 of file qmcfinitesize.cpp.

◆ RealType

Definition at line 47 of file qmcfinitesize.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 51 of file qmcfinitesize.cpp.

References APP_ABORT, OHMMS::Controller, Communicate::finalize(), Communicate::initialize(), QMCAppBase::parse(), and Random.

52 {
53  OHMMS::Controller->initialize(argc, argv);
54  Random.init(-1);
55  std::cout.setf(std::ios::scientific, std::ios::floatfield);
56  std::cout.setf(std::ios::right, std::ios::adjustfield);
57  std::cout.precision(12);
58 
59  std::unique_ptr<SkParserBase> skparser(nullptr);
60 
61  bool show_usage = false;
62  bool show_warn = false;
63  std::string skname;
64  std::string skfile;
65  /* For a successful execution of the code, atleast 3 arguments will need to be
66  * provided along with the executable. Therefore, print usage information if
67  * argc is less than 4.
68  */
69  if (argc < 4)
70  {
71  std::cout << "Insufficient number of arguments.\n\n";
72  show_usage = true;
73  }
74  else
75  {
76  int iargc = 2;
77  bool skf_found = false;
78  while (iargc + 1 < argc)
79  {
80  std::string a(argv[iargc]);
81  std::string anxt(argv[iargc + 1]);
82  if (a == "--ascii")
83  {
84  skparser = std::make_unique<SkParserASCII>();
85  skfile = anxt;
86  if (skf_found)
87  show_warn = true;
88  skf_found = true;
89  }
90  else if (a == "--scalardat")
91  {
92  skparser = std::make_unique<SkParserScalarDat>();
93  skfile = anxt;
94  if (skf_found)
95  show_warn = true;
96  skf_found = true;
97  }
98  else if (a == "--hdf5")
99  {
100  skparser = std::make_unique<SkParserHDF5>();
101  skfile = anxt;
102  if (skf_found)
103  show_warn = true;
104  skf_found = true;
105  }
106  else if (a == "--skname")
107  {
108  skname = anxt;
109  }
110  else
111  {
112  std::cout << "Unrecognized flag '" << a << "'.\n\n";
113  show_usage = true;
114  }
115  iargc += 2;
116  }
117  }
118 
119  if (show_usage)
120  {
121  std::cout << "Usage: qmcfinitesize [main.xml] --[skformat] [SK_FILE] --[optional_arg] [option]\n";
122  std::cout << " [main.xml]\n";
123  std::cout << " input file to qmcpack corresponding that calculated S(k) data. ";
124  std::cout << " [skformat]\n";
125  std::cout << " ascii: S(k) given in kx ky kz sk sk_err format. Header necessary.\n";
126  std::cout << " scalardat: File containing skall elements with energy.pl output format.\n";
127  std::cout << " hdf5: stat.h5 file containing skall data.\n";
128  std::cout << " [SK_FILE]\n";
129  std::cout << " filename containing the S(k) data\n";
130  std::cout << " [optional_args]\n";
131  std::cout << " --skname: in the stat.h5, the S(k) group name. Set to \"name\" defined in qmcpack input file "
132  "where SkAll estimator was specified\n";
133  std::cout << " [option]\n";
134  std::cout << " option corresonding to the optional_arg\n";
135  std::cout << "---------------------------\n";
136  std::cout << "Examples:\n";
137  std::cout << " qmcfinitesize qmc.in.xml --hdf5 qmc.g000.s000.stat.h5 --skname SkAll\n";
138  std::cout << " qmcfinitesize qmc.in.xml --ascii processed_sk.dat\n";
139  return 0;
140  }
141 
142  if (show_warn)
143  std::cout << "WARNING: multiple skformats were provided. All but the last will be ignored.\n\n";
144 
145  if (!skname.empty())
146  skparser->setName(skname);
147  skparser->parse(skfile);
148 
149  if (skparser == NULL)
150  {
151  APP_ABORT("qmcfinitesize: skparser failed to initialize");
152  }
153 
154  QMCFiniteSize qmcfs(skparser.get());
155  qmcfs.parse(std::string(argv[1]));
156  qmcfs.validateXML();
157  qmcfs.execute();
158 
159  // Jobs done. Clean up.
161  return 0;
162 }
void initialize(int argc, char **argv)
bool parse(const std::string &infile)
parse an input file
Definition: QMCAppBase.cpp:64
#define Random
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
void finalize()
Class to handle FS corrections.
Definition: QMCFiniteSize.h:19