QMCPACK
qmc-extract-eshdf-kvectors.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: Luke Shulenburger, lshulen@sandia.gov, Sandia National Laboratories
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 //
11 // File created by: Luke Shulenburger, lshulen@sandia.gov, Sandia National Laboratories
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 #include <iostream>
16 #include <string>
17 #include <sstream>
18 #include <array>
19 #include "Message/Communicate.h"
20 #include "hdf/hdf_archive.h"
21 
22 int main(int argc, char* argv[])
23 {
24 #ifdef HAVE_MPI
25  mpi3::environment env(argc, argv);
26 #endif
27 
28  using namespace qmcplusplus;
29  if (argc != 2)
30  {
31  std::cout << "Program must take as an argument a single input eshdf file to parse" << std::endl;
32  return 1;
33  }
34  std::string fname(argv[1]);
35  //cout << "Input file is: " << fname << std::endl;
36  hdf_archive hin;
37  hin.open(fname, H5F_ACC_RDONLY);
38  const std::string dataset = "electrons/number_of_kpoints";
39  // Get the number of kpoints from the eshdf file
40  int data;
41  hin.read(data, dataset);
42  // get all of the reduced kpoints from the file
43  std::array<float, 3> kpt;
44  for (int i = 0; i < data; i++)
45  {
46  std::ostringstream os;
47  os << "electrons/kpoint_" << i << "/reduced_k";
48  hin.read(kpt, os.str());
49  std::cout << kpt[0] << " " << kpt[1] << " " << kpt[2] << "\n";
50  }
51  hin.close();
52  return 0;
53 }
bool open(const std::filesystem::path &fname, unsigned flags=H5F_ACC_RDWR)
open a file
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void close()
close all the open groups and file
Definition: hdf_archive.cpp:38
class to handle hdf file
Definition: hdf_archive.h:51
int main(int argc, char *argv[])
void read(T &data, const std::string &aname)
read the data from the group aname and check status runtime error is issued on I/O error ...
Definition: hdf_archive.h:306