QMCPACK
hdf_archive Class Reference

class to handle hdf file More...

+ Collaboration diagram for hdf_archive:

Public Member Functions

template<class Comm = Communicate*>
 hdf_archive (Comm c, bool request_pio=false)
 constructor More...
 
 hdf_archive ()
 
 ~hdf_archive ()
 destructor More...
 
bool is_parallel () const
 return true if parallel i/o More...
 
bool is_master () const
 return true if master in parallel i/o More...
 
hid_t getFileID () const
 return file_id. should be only be used for connecting to old codes when porting More...
 
bool create (const std::filesystem::path &fname, unsigned flags=H5F_ACC_TRUNC)
 create a file More...
 
bool open (const std::filesystem::path &fname, unsigned flags=H5F_ACC_RDWR)
 open a file More...
 
void close ()
 close all the open groups and file More...
 
void flush ()
 flush a file More...
 
bool closed ()
 return true if the file is closed More...
 
bool is_group (const std::string &aname)
 check if aname is a group More...
 
bool is_dataset (const std::string &aname)
 check if aname is a dataset More...
 
template<typename T >
bool is_dataset_of_type (const std::string &aname)
 check if aname is a dataset of type T More...
 
hid_t top () const
 return the top of the group stack More...
 
bool open_groups ()
 check if any groups are open group stack will have entries if so More...
 
void push (const std::string &gname, bool createit=true)
 push a group to the group stack More...
 
void push (const hdf_path &gname, bool createit=true)
 
void pop ()
 
std::string group_path_as_string () const
 Return a string representation of the current group stack. More...
 
template<typename T >
bool getShape (const std::string &aname, std::vector< int > &sizes_out)
 read the shape of multidimensional filespace from the group aname this function can be used to query dataset for preparing containers. More...
 
template<typename T >
bool writeEntry (T &data, const std::string &aname)
 write the data to the group aname and return status use write() for inbuilt error checking More...
 
template<typename T >
void write (T &data, const std::string &aname)
 write the data to the group aname and check status runtime error is issued on I/O error More...
 
template<typename T , typename IT , std::size_t RANK>
void writeSlabReshaped (T &data, const std::array< IT, RANK > &shape, const std::string &aname)
 write the container data with a specific shape and check status More...
 
template<typename T , typename = std::enable_if_t<!std::is_const<T>::value>>
bool readEntry (T &data, const std::string &aname)
 read the data from the group aname and return status use read() for inbuilt error checking More...
 
template<typename T , typename = std::enable_if_t<!std::is_const<T>::value>>
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 More...
 
template<typename T , typename IT , std::size_t RANK, typename = std::enable_if_t<!std::is_const<T>::value>>
void readSlabReshaped (T &data, const std::array< IT, RANK > &shape, const std::string &aname)
 read file dataset with a specific shape into a container and check status More...
 
template<typename T , typename IT , std::size_t RANK, typename = std::enable_if_t<!std::is_const<T>::value>>
void readSlabSelection (T &data, const std::array< IT, RANK > &readSpec, const std::string &aname)
 read a portion of the data from the group aname and check status runtime error is issued on I/O error More...
 
void unlink (const std::string &aname)
 

Private Types

enum  { IS_PARALLEL = 0, IS_MASTER, NOIO }
 

Private Member Functions

void set_access_plist (Communicate *comm, bool request_pio)
 set the access property More...
 
void set_access_plist ()
 

Private Attributes

std::bitset< 4 > Mode
 bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed More...
 
hid_t file_id
 file id More...
 
hid_t access_id
 access id More...
 
hid_t xfer_plist
 transfer property More...
 
hid_t lcpl_id
 Link creation property list identifier. More...
 
std::stack< hid_t > group_id
 FILO to handle H5Group. More...
 
std::vector< std::string > group_names
 Track group names corresponding to group_id. More...
 
std::string possible_filename_
 Name of file that hdf_archive thinks is open. More...
 

Static Private Attributes

static const hid_t is_closed = -1
 

Detailed Description

class to handle hdf file

Definition at line 51 of file hdf_archive.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
IS_PARALLEL 
IS_MASTER 
NOIO 

Definition at line 54 of file hdf_archive.h.

Constructor & Destructor Documentation

◆ hdf_archive() [1/2]

hdf_archive ( Comm  c,
bool  request_pio = false 
)
inline

constructor

Parameters
ccommunicator
request_pioturns on parallel I/O, if true and PHDF5 is available, hdf_archive is in parallel collective IO mode if true and PHDF5 is not available, hdf_archive is in master-only IO mode if false, hdf_archive is in independent IO mode

Definition at line 102 of file hdf_archive.h.

References hdf_error_suppression::enabled, and hdf_archive::set_access_plist().

103  : file_id(is_closed), access_id(H5P_DEFAULT), xfer_plist(H5P_DEFAULT), lcpl_id(H5P_DEFAULT)
104  {
106  throw std::runtime_error("HDF5 library warnings and errors not suppressed from output.\n");
107  set_access_plist(c, request_pio);
108  }
hid_t lcpl_id
Link creation property list identifier.
Definition: hdf_archive.h:74
static const hid_t is_closed
Definition: hdf_archive.h:60
hid_t access_id
access id
Definition: hdf_archive.h:70
hid_t file_id
file id
Definition: hdf_archive.h:68
hid_t xfer_plist
transfer property
Definition: hdf_archive.h:72
static bool enabled
status of hdf_error_suppression. An instance of this class changes enabled to true.

◆ hdf_archive() [2/2]

hdf_archive ( )
inline

Definition at line 110 of file hdf_archive.h.

References hdf_error_suppression::enabled, and hdf_archive::set_access_plist().

110  : file_id(is_closed), access_id(H5P_DEFAULT), xfer_plist(H5P_DEFAULT), lcpl_id(H5P_DEFAULT)
111  {
113  throw std::runtime_error("HDF5 library warnings and errors not suppressed from output.\n");
115  }
hid_t lcpl_id
Link creation property list identifier.
Definition: hdf_archive.h:74
static const hid_t is_closed
Definition: hdf_archive.h:60
hid_t access_id
access id
Definition: hdf_archive.h:70
hid_t file_id
file id
Definition: hdf_archive.h:68
hid_t xfer_plist
transfer property
Definition: hdf_archive.h:72
static bool enabled
status of hdf_error_suppression. An instance of this class changes enabled to true.

◆ ~hdf_archive()

destructor

Definition at line 25 of file hdf_archive.cpp.

References hdf_archive::access_id, hdf_archive::close(), hdf_archive::lcpl_id, and hdf_archive::xfer_plist.

26 {
27 #if defined(ENABLE_PHDF5)
28  if (xfer_plist != H5P_DEFAULT)
29  H5Pclose(xfer_plist);
30  if (access_id != H5P_DEFAULT)
31  H5Pclose(access_id);
32 #endif
33  if (lcpl_id != H5P_DEFAULT)
34  H5Pclose(lcpl_id);
35  close();
36 }
hid_t lcpl_id
Link creation property list identifier.
Definition: hdf_archive.h:74
void close()
close all the open groups and file
Definition: hdf_archive.cpp:38
hid_t access_id
access id
Definition: hdf_archive.h:70
hid_t xfer_plist
transfer property
Definition: hdf_archive.h:72

Member Function Documentation

◆ close()

void close ( )

close all the open groups and file

Definition at line 38 of file hdf_archive.cpp.

References hdf_archive::file_id, hdf_archive::group_id, hdf_archive::group_names, and hdf_archive::is_closed.

Referenced by hdf_archive::create(), HybridRepSetReader< SA >::create_spline_set(), SplineSetReader< typename SA::SplineBase >::create_spline_set(), LCAOrbitalBuilder::createBasisSetH5(), QMCGaussianParserBase::createBasisSetWithHDF5(), QMCGaussianParserBase::createCenterH5(), QMCGaussianParserBase::createDeterminantSetWithHDF5(), QMCGaussianParserBase::createIonSet(), QMCGaussianParserBase::createMultiDeterminantSetCIHDF5(), QMCGaussianParserBase::createShellH5(), SplineSetReader< typename SA::SplineBase >::createSplineDataSpaceLookforDumpFile(), QMCGaussianParserBase::createSPOSetsH5(), HDFWalkerOutput::dump(), QMCGaussianParserBase::dump(), LCAOrbitalBuilder::EvalPeriodicImagePhaseFactors(), RMGParser::getCell(), LCAOHDFParser::getCell(), LCAOHDFParser::getGeometry(), LCAOHDFParser::getMO(), LCAOHDFParser::getSuperTwist(), EshdfFile::handleKpt(), LCAOrbitalBuilder::loadBasisSetFromH5(), LCAOSpinorBuilder::loadMO(), LCAOrbitalBuilder::loadMO(), main(), QMCFixedSampleLinearOptimizeBatched::one_shift_run(), hdf_archive::open(), SkParserHDF5::parse(), LCAOHDFParser::parse(), LCAOSpinorBuilder::putFromH5(), LCAOrbitalBuilder::putFromH5(), LCAOrbitalBuilder::putPBCFromH5(), RandomNumberControl::read_parallel(), RandomNumberControl::read_rank_0(), SlaterDetBuilder::readDetListH5(), EshdfFile::readKptGvecs(), QMCCostFunctionBase::reportParametersH5(), EstimatorManagerBase::stop(), TEST_CASE(), qmcplusplus::TEST_CASE(), OneBodyDensityMatricesTests< T >::testRegisterAndWrite(), RandomNumberControl::write_parallel(), RandomNumberControl::write_rank_0(), and hdf_archive::~hdf_archive().

39 {
40  while (!group_id.empty())
41  {
42  hid_t gid = group_id.top();
43  group_id.pop();
44  group_names.pop_back();
45  H5Gclose(gid);
46  }
47  if (file_id != is_closed)
48  H5Fclose(file_id);
50 }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
static const hid_t is_closed
Definition: hdf_archive.h:60
hid_t file_id
file id
Definition: hdf_archive.h:68
std::vector< std::string > group_names
Track group names corresponding to group_id.
Definition: hdf_archive.h:78

◆ closed()

bool closed ( )
inline

return true if the file is closed

Definition at line 153 of file hdf_archive.h.

References hdf_archive::file_id, and hdf_archive::is_closed.

153 { return file_id == is_closed; }
static const hid_t is_closed
Definition: hdf_archive.h:60
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ create()

bool create ( const std::filesystem::path &  fname,
unsigned  flags = H5F_ACC_TRUNC 
)

create a file

Parameters
fnamename of hdf5 file
flagsi/o mode
Returns
true, if creation is successful

Definition at line 143 of file hdf_archive.cpp.

References hdf_archive::access_id, hdf_archive::close(), hdf_archive::file_id, hdf_archive::is_closed, hdf_archive::IS_MASTER, hdf_archive::IS_PARALLEL, hdf_archive::Mode, hdf_archive::NOIO, and hdf_archive::possible_filename_.

Referenced by HybridRepSetReader< SA >::create_spline_set(), SplineSetReader< typename SA::SplineBase >::create_spline_set(), HDFWalkerOutput::dump(), QMCGaussianParserBase::dump(), QMCFixedSampleLinearOptimizeBatched::one_shift_run(), QMCCostFunctionBase::reportParametersH5(), EstimatorManagerBase::start(), TEST_CASE(), qmcplusplus::TEST_CASE(), OneBodyDensityMatricesTests< T >::testRegisterAndWrite(), BranchIO< SFNB >::write(), RandomNumberControl::write(), and VariableSet::writeToHDF().

144 {
145  possible_filename_ = fname;
146  if (Mode[NOIO])
147  return true;
148  if (!(Mode[IS_PARALLEL] || Mode[IS_MASTER]))
149  throw std::runtime_error("Only create file in parallel or by master but not every rank!");
150  close();
151  file_id = H5Fcreate(fname.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, access_id);
152  return file_id != is_closed;
153 }
void close()
close all the open groups and file
Definition: hdf_archive.cpp:38
std::string possible_filename_
Name of file that hdf_archive thinks is open.
Definition: hdf_archive.h:84
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
static const hid_t is_closed
Definition: hdf_archive.h:60
hid_t access_id
access id
Definition: hdf_archive.h:70
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ flush()

void flush ( )
inline

flush a file

Definition at line 146 of file hdf_archive.h.

References hdf_archive::file_id, and hdf_archive::is_closed.

Referenced by EstimatorManagerBase::collectBlockAverages(), SkEstimator::registerCollectables(), TraceBuffer< TraceInt >::write_hdf(), and WalkerLogBuffer< WLog::Real >::writeHDF().

147  {
148  if (file_id != is_closed)
149  H5Fflush(file_id, H5F_SCOPE_LOCAL);
150  }
static const hid_t is_closed
Definition: hdf_archive.h:60
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ getFileID()

hid_t getFileID ( ) const
inline

return file_id. should be only be used for connecting to old codes when porting

Definition at line 126 of file hdf_archive.h.

References hdf_archive::file_id.

Referenced by PWParameterSet::checkVersion(), and SkEstimator::registerCollectables().

126 { return file_id; }
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ getShape()

bool getShape ( const std::string &  aname,
std::vector< int > &  sizes_out 
)
inline

read the shape of multidimensional filespace from the group aname this function can be used to query dataset for preparing containers.

The dimensions contributed by T is excluded. See how exactly user dimensions are calculated in getDataShape function definition.

Returns
true if successful

Definition at line 231 of file hdf_archive.h.

References hdf_archive::file_id, hdf_archive::group_id, hdf_archive::Mode, and hdf_archive::NOIO.

Referenced by EshdfFile::handleDensity(), EshdfFile::handleKpt(), SkParserHDF5::parse(), EshdfFile::readKptGvecs(), RotatedSPOs::readVariationalParameters(), and TEST_CASE().

232  {
233  if (Mode[NOIO])
234  return true;
235  hid_t p = group_id.empty() ? file_id : group_id.top();
236  return getDataShape<T>(p, aname, sizes_out);
237  }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ group_path_as_string()

std::string group_path_as_string ( ) const

Return a string representation of the current group stack.

Definition at line 246 of file hdf_archive.cpp.

References hdf_archive::group_names.

Referenced by hdf_archive::push(), and TEST_CASE().

247 {
248  std::string group_path;
249  for (auto it = group_names.begin(); it != group_names.end(); it++)
250  {
251  group_path += *it;
252  if (it != group_names.end() - 1)
253  group_path += "/";
254  }
255 
256  return group_path;
257 }
std::vector< std::string > group_names
Track group names corresponding to group_id.
Definition: hdf_archive.h:78

◆ is_dataset()

bool is_dataset ( const std::string &  aname)
inline

check if aname is a dataset

Parameters
anamedataset's name
Returns
true, if aname exists and it is a dataset

Definition at line 165 of file hdf_archive.h.

References qmcplusplus::Units::charge::e, hdf_archive::file_id, hdf_archive::group_id, hdf_archive::Mode, and hdf_archive::NOIO.

Referenced by SlaterDetBuilder::readDetListH5(), and TEST_CASE().

166  {
167  if (Mode[NOIO])
168  return true;
169  hid_t p = group_id.empty() ? file_id : group_id.top();
170  int dummy_data;
171  h5data_proxy<int> e(dummy_data);
172  return e.check_existence(p, aname);
173  }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ is_dataset_of_type()

bool is_dataset_of_type ( const std::string &  aname)
inline

check if aname is a dataset of type T

Parameters
anamegroup's name
Returns
true, if aname is a dataset of type T

Definition at line 180 of file hdf_archive.h.

References qmcplusplus::Units::charge::e, hdf_archive::file_id, hdf_archive::group_id, hdf_archive::Mode, and hdf_archive::NOIO.

Referenced by SlaterDetBuilder::readDetListH5(), and TEST_CASE().

181  {
182  if (Mode[NOIO])
183  return true;
184  hid_t p = group_id.empty() ? file_id : group_id.top();
185  T dummy_data;
186  h5data_proxy<T> e(dummy_data);
187  return e.check_type(p, aname);
188  }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ is_group()

bool is_group ( const std::string &  aname)

check if aname is a group

Parameters
anamegroup's name
Returns
true, if aname exists and it is a group

Definition at line 165 of file hdf_archive.cpp.

References hdf_archive::file_id, hdf_archive::group_id, hdf_archive::is_closed, hdf_archive::Mode, and hdf_archive::NOIO.

Referenced by HDFWalkerInput_0_4::read_hdf5(), HDFWalkerInput_0_4::read_hdf5_scatter(), HDFWalkerInput_0_4::read_phdf5(), and RotatedSPOs::readVariationalParameters().

166 {
167  if (Mode[NOIO])
168  return true;
169  if (file_id == is_closed)
170  return false;
171  hid_t p = group_id.empty() ? file_id : group_id.top();
172  p = (aname[0] == '/') ? file_id : p;
173 
174  if (H5Lexists(p, aname.c_str(), H5P_DEFAULT) > 0)
175  {
176 #if H5_VERSION_GE(1, 12, 0)
177  H5O_info2_t oinfo;
178 #else
179  H5O_info_t oinfo;
180 #endif
181  oinfo.type = H5O_TYPE_UNKNOWN;
182 #if H5_VERSION_GE(1, 12, 0)
183  H5Oget_info_by_name3(p, aname.c_str(), &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
184 #else
185  H5Oget_info_by_name(p, aname.c_str(), &oinfo, H5P_DEFAULT);
186 #endif
187 
188  if (oinfo.type != H5O_TYPE_GROUP)
189  return false;
190  return true;
191  }
192  else
193  {
194  return false;
195  }
196 }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
static const hid_t is_closed
Definition: hdf_archive.h:60
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ is_master()

bool is_master ( ) const
inline

return true if master in parallel i/o

Definition at line 123 of file hdf_archive.h.

References hdf_archive::IS_MASTER, and hdf_archive::Mode.

123 { return Mode[IS_MASTER]; }
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66

◆ is_parallel()

bool is_parallel ( ) const
inline

return true if parallel i/o

Definition at line 120 of file hdf_archive.h.

References hdf_archive::IS_PARALLEL, and hdf_archive::Mode.

Referenced by RandomNumberControl::read(), RandomNumberControl::write(), and HDFWalkerOutput::write_configuration().

120 { return Mode[IS_PARALLEL]; }
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66

◆ open()

bool open ( const std::filesystem::path &  fname,
unsigned  flags = H5F_ACC_RDWR 
)

open a file

Parameters
fnamename of hdf5 file
flagsi/o mode
Returns
file_id, if open is successful

Definition at line 155 of file hdf_archive.cpp.

References hdf_archive::access_id, hdf_archive::close(), hdf_archive::file_id, hdf_archive::is_closed, hdf_archive::Mode, hdf_archive::NOIO, and hdf_archive::possible_filename_.

Referenced by HybridRepSetReader< SA >::create_spline_set(), SplineSetReader< typename SA::SplineBase >::create_spline_set(), LCAOrbitalBuilder::createBasisSetH5(), QMCGaussianParserBase::createBasisSetWithHDF5(), QMCGaussianParserBase::createCenterH5(), QMCGaussianParserBase::createDeterminantSetWithHDF5(), QMCGaussianParserBase::createIonSet(), QMCGaussianParserBase::createMultiDeterminantSetCIHDF5(), QMCGaussianParserBase::createShellH5(), SplineSetReader< typename SA::SplineBase >::createSplineDataSpaceLookforDumpFile(), QMCGaussianParserBase::createSPOSetsH5(), LCAOrbitalBuilder::EvalPeriodicImagePhaseFactors(), RMGParser::getCell(), LCAOHDFParser::getCell(), LCAOHDFParser::getGeometry(), PWOrbitalSetBuilder::getH5(), LCAOHDFParser::getMO(), LCAOHDFParser::getSuperTwist(), EshdfFile::handleKpt(), LCAOrbitalBuilder::loadBasisSetFromH5(), LCAOSpinorBuilder::loadMO(), LCAOrbitalBuilder::loadMO(), main(), EshdfFile::openHdfFileForRead(), SkParserHDF5::parse(), RMGParser::parse(), LCAOHDFParser::parse(), GridExternalPotential::put(), LCAOSpinorBuilder::putFromH5(), LCAOrbitalBuilder::putFromH5(), LCAOrbitalBuilder::putPBCFromH5(), RandomNumberControl::read(), HDFWalkerInput_0_4::read_hdf5(), HDFWalkerInput_0_4::read_hdf5_scatter(), HDFWalkerInput_0_4::read_phdf5(), SlaterDetBuilder::readDetListH5(), VariableSet::readFromHDF(), EinsplineSetBuilder::ReadOrbitalInfo(), TEST_CASE(), qmcplusplus::TEST_CASE(), and OneBodyDensityMatricesTests< T >::testRegisterAndWrite().

156 {
157  possible_filename_ = fname;
158  if (Mode[NOIO])
159  return true;
160  close();
161  file_id = H5Fopen(fname.c_str(), flags, access_id);
162  return file_id != is_closed;
163 }
void close()
close all the open groups and file
Definition: hdf_archive.cpp:38
std::string possible_filename_
Name of file that hdf_archive thinks is open.
Definition: hdf_archive.h:84
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
static const hid_t is_closed
Definition: hdf_archive.h:60
hid_t access_id
access id
Definition: hdf_archive.h:70
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ open_groups()

bool open_groups ( )
inline

check if any groups are open group stack will have entries if so

Returns
true if any groups are open

Definition at line 198 of file hdf_archive.h.

References hdf_archive::group_id.

Referenced by TraceBuffer< TraceInt >::register_hdf_data(), and WalkerLogBuffer< WLog::Real >::registerHDFData().

198 { return group_id.empty(); }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76

◆ pop()

void pop ( )
inline

Definition at line 208 of file hdf_archive.h.

References hdf_archive::file_id, hdf_archive::group_id, hdf_archive::group_names, and hdf_archive::is_closed.

Referenced by ObservableHelper::addProperty(), AOBasisBuilder< COT >::createAOSetH5(), LCAOrbitalBuilder::createBasisSetH5(), QMCGaussianParserBase::createIonSet(), QMCGaussianParserBase::createMultiDeterminantSetCIHDF5(), PWOrbitalSetBuilder::createPW(), QMCGaussianParserBase::createShellH5(), QMCGaussianParserBase::dump(), LCAOHDFParser::getGeometry(), LCAOHDFParser::getSuperTwist(), RMGParser::parse(), LCAOHDFParser::parse(), GaussianCombo< T >::putBasisGroupH5(), LCAOrbitalBuilder::putPBCFromH5(), RandomNumberControl::read_parallel(), RandomNumberControl::read_rank_0(), HybridRepCenterOrbitals< SPLINEBASE::DataType >::read_splines(), VariableSet::readFromHDF(), FakeOptimizableObject::readVariationalParameters(), RotatedSPOs::readVariationalParameters(), TraceSamples< std::complex< TraceReal > >::register_hdf_data(), TraceBuffer< TraceInt >::register_hdf_data(), WalkerLogBuffer< WLog::Real >::registerHDFData(), NEReferencePoints::write(), ObservableHelper::write(), NESpaceGrid< REAL >::write(), OperatorEstBase::write(), TraceBuffer< TraceInt >::write_hdf(), RandomNumberControl::write_parallel(), RandomNumberControl::write_rank_0(), HybridRepCenterOrbitals< SPLINEBASE::DataType >::write_splines(), WalkerLogBuffer< WLog::Real >::writeHDF(), VariableSet::writeToHDF(), FakeOptimizableObject::writeVariationalParameters(), and RotatedSPOs::writeVariationalParameters().

209  {
210  if (file_id == is_closed || group_id.empty())
211  return;
212  hid_t g = group_id.top();
213  group_id.pop();
214  group_names.pop_back();
215  herr_t err = H5Gclose(g);
216  if (err < 0)
217  throw std::runtime_error("H5Gclose failed with error.");
218  }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
static const hid_t is_closed
Definition: hdf_archive.h:60
hid_t file_id
file id
Definition: hdf_archive.h:68
std::vector< std::string > group_names
Track group names corresponding to group_id.
Definition: hdf_archive.h:78

◆ push() [1/2]

void push ( const std::string &  gname,
bool  createit = true 
)

push a group to the group stack

Parameters
gnamename of the group
createitif true, group is create when missing

Definition at line 198 of file hdf_archive.cpp.

References hdf_archive::file_id, hdf_archive::group_id, hdf_archive::group_names, hdf_archive::group_path_as_string(), hdf_archive::is_closed, hdf_archive::lcpl_id, hdf_archive::Mode, hdf_archive::NOIO, and hdf_archive::possible_filename_.

Referenced by ObservableHelper::addProperty(), AOBasisBuilder< COT >::createAOSetH5(), LCAOrbitalBuilder::createBasisSetH5(), QMCGaussianParserBase::createBasisSetWithHDF5(), QMCGaussianParserBase::createCenterH5(), QMCGaussianParserBase::createDeterminantSetWithHDF5(), QMCGaussianParserBase::createIonSet(), QMCGaussianParserBase::createMultiDeterminantSetCIHDF5(), PWOrbitalSetBuilder::createPW(), QMCGaussianParserBase::createShellH5(), QMCGaussianParserBase::createSPOSetsH5(), HDFWalkerOutput::dump(), QMCGaussianParserBase::dump(), LCAOrbitalBuilder::EvalPeriodicImagePhaseFactors(), RMGParser::getCell(), LCAOHDFParser::getCell(), LCAOHDFParser::getGeometry(), LCAOHDFParser::getSuperTwist(), LCAOrbitalBuilder::loadBasisSetFromH5(), LCAOSpinorBuilder::loadMO(), LCAOrbitalBuilder::loadMO(), RMGParser::parse(), LCAOHDFParser::parse(), hdf_archive::push(), GaussianCombo< T >::putBasisGroupH5(), LCAOrbitalBuilder::putPBCFromH5(), HDFWalkerInput_0_4::read_hdf5(), HDFWalkerInput_0_4::read_hdf5_scatter(), RandomNumberControl::read_parallel(), HDFWalkerInput_0_4::read_phdf5(), RandomNumberControl::read_rank_0(), HybridRepCenterOrbitals< SPLINEBASE::DataType >::read_splines(), SlaterDetBuilder::readDetListH5(), VariableSet::readFromHDF(), FakeOptimizableObject::readVariationalParameters(), RotatedSPOs::readVariationalParameters(), TraceSamples< std::complex< TraceReal > >::register_hdf_data(), TraceBuffer< TraceInt >::register_hdf_data(), WalkerLogBuffer< WLog::Real >::registerHDFData(), QMCCostFunctionBase::reportParametersH5(), TEST_CASE(), qmcplusplus::TEST_CASE(), BranchIO< SFNB >::write(), NEReferencePoints::write(), ObservableHelper::write(), TraceBuffer< TraceInt >::write_hdf(), RandomNumberControl::write_parallel(), RandomNumberControl::write_rank_0(), HybridRepCenterOrbitals< SPLINEBASE::DataType >::write_splines(), WalkerLogBuffer< WLog::Real >::writeHDF(), VariableSet::writeToHDF(), FakeOptimizableObject::writeVariationalParameters(), and RotatedSPOs::writeVariationalParameters().

199 {
200  hid_t g = is_closed;
201  if (Mode[NOIO])
202  return;
203 
204  if (file_id == is_closed)
205  throw std::runtime_error("Failed to open group \"" + gname +
206  "\" because file is not open. Expected file: " + possible_filename_);
207 
208  hid_t p = group_id.empty() ? file_id : group_id.top();
209 
210 #if H5_VERSION_GE(1, 12, 0)
211  H5O_info2_t oinfo;
212 #else
213  H5O_info_t oinfo;
214 #endif
215  oinfo.type = H5O_TYPE_UNKNOWN;
216  if (H5Lexists(p, gname.c_str(), H5P_DEFAULT) > 0)
217  {
218 #if H5_VERSION_GE(1, 12, 0)
219  H5Oget_info_by_name3(p, gname.c_str(), &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
220 #else
221  H5Oget_info_by_name(p, gname.c_str(), &oinfo, H5P_DEFAULT);
222 #endif
223  }
224 
225  if ((oinfo.type != H5O_TYPE_GROUP) && createit)
226  {
227  g = H5Gcreate2(p, gname.c_str(), lcpl_id, H5P_DEFAULT, H5P_DEFAULT);
228  }
229  else
230  {
231  g = H5Gopen2(p, gname.c_str(), H5P_DEFAULT);
232  }
233  if (g != is_closed)
234  {
235  group_id.push(g);
236  group_names.push_back(gname);
237  }
238 
239  if (!createit && g < 0)
240  throw std::runtime_error("Group \"" + gname + "\" not found in file " + possible_filename_ +
241  ". Group path: " + group_path_as_string());
242 }
hid_t lcpl_id
Link creation property list identifier.
Definition: hdf_archive.h:74
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
std::string possible_filename_
Name of file that hdf_archive thinks is open.
Definition: hdf_archive.h:84
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
static const hid_t is_closed
Definition: hdf_archive.h:60
hid_t file_id
file id
Definition: hdf_archive.h:68
std::string group_path_as_string() const
Return a string representation of the current group stack.
std::vector< std::string > group_names
Track group names corresponding to group_id.
Definition: hdf_archive.h:78

◆ push() [2/2]

void push ( const hdf_path gname,
bool  createit = true 
)

Definition at line 244 of file hdf_archive.cpp.

References hdf_archive::push(), and hdf_path::string().

244 { push(gname.string(), createit); }
void push(const std::string &gname, bool createit=true)
push a group to the group stack

◆ read()

void read ( T &  data,
const std::string &  aname 
)
inline

read the data from the group aname and check status runtime error is issued on I/O error

Definition at line 306 of file hdf_archive.h.

References hdf_archive::readEntry().

Referenced by RadialOrbitalSetBuilder< COT >::addGridH5(), RadialOrbitalSetBuilder< COT >::addRadialOrbitalH5(), PWParameterSet::checkVersion(), AOBasisBuilder< COT >::createAOSetH5(), LCAOrbitalBuilder::createBasisSetH5(), PWOrbitalSetBuilder::createPW(), PWOrbitalSetBuilder::createPWBasis(), LCAOrbitalBuilder::EvalPeriodicImagePhaseFactors(), RMGParser::getCell(), LCAOHDFParser::getCell(), LCAOHDFParser::getGeometry(), LCAOHDFParser::getMO(), LCAOHDFParser::getSuperTwist(), EshdfFile::handleDensity(), PWParameterSet::hasComplexData(), LCAOrbitalBuilder::LoadFullCoefsFromH5(), LCAOSpinorBuilder::loadMO(), LCAOrbitalBuilder::loadMO(), main(), EinsplineSetBuilder::OccupyBands(), EinsplineSetBuilder::OccupyBands_ESHDF(), RMGParser::parse(), LCAOHDFParser::parse(), GridExternalPotential::put(), GaussianCombo< T >::putBasisGroupH5(), LCAOrbitalBuilder::putFromH5(), AOBasisBuilder< COT >::putH5(), LCAOrbitalBuilder::putPBCFromH5(), HDFWalkerInput_0_4::read_hdf5(), HDFWalkerInput_0_4::read_hdf5_scatter(), RandomNumberControl::read_parallel(), HDFWalkerInput_0_4::read_phdf5(), RandomNumberControl::read_rank_0(), PWBasis::readbasis(), SlaterDetBuilder::readCoeffs(), SlaterDetBuilder::readDetListH5(), VariableSet::readFromHDF(), EinsplineSetBuilder::ReadGvectors_ESHDF(), EinsplineSetBuilder::ReadOrbitalInfo(), EinsplineSetBuilder::ReadOrbitalInfo_ESHDF(), LCAOrbitalBuilder::readRealMatrixFromH5(), hdf_archive::readSlabReshaped(), hdf_archive::readSlabSelection(), FakeOptimizableObject::readVariationalParameters(), RotatedSPOs::readVariationalParameters(), and TEST_CASE().

307  {
308  if (!readEntry(data, aname))
309  {
310  throw std::runtime_error("HDF5 read failure in hdf_archive::read " + aname);
311  }
312  }
bool readEntry(T &data, const std::string &aname)
read the data from the group aname and return status use read() for inbuilt error checking ...
Definition: hdf_archive.h:293

◆ readEntry()

bool readEntry ( T &  data,
const std::string &  aname 
)
inline

read the data from the group aname and return status use read() for inbuilt error checking

Returns
true if successful

Definition at line 293 of file hdf_archive.h.

References qmcplusplus::Units::charge::e, hdf_archive::file_id, hdf_archive::group_id, hdf_archive::Mode, hdf_archive::NOIO, and hdf_archive::xfer_plist.

Referenced by AOBasisBuilder< COT >::createAOSetH5(), LCAOrbitalBuilder::createBasisSetH5(), SplineSetReader< typename SA::SplineBase >::createSplineDataSpaceLookforDumpFile(), LCAOrbitalBuilder::loadBasisSetFromH5(), LCAOHDFParser::parse(), LCAOrbitalBuilder::putFromH5(), hdf_archive::read(), HDFWalkerInput_0_4::read_hdf5(), HDFWalkerInput_0_4::read_hdf5_scatter(), HDFWalkerInput_0_4::read_phdf5(), AtomicOrbitals< ST >::read_splines(), SplineR2R< ST >::read_splines(), SplineC2R< ST >::read_splines(), SplineC2C< ST >::read_splines(), SplineC2COMPTarget< ST >::read_splines(), SplineC2ROMPTarget< ST >::read_splines(), HybridRepCenterOrbitals< SPLINEBASE::DataType >::read_splines(), SlaterDetBuilder::readCoeffs(), SlaterDetBuilder::readDetListH5(), EinsplineSetBuilder::ReadGvectors_ESHDF(), SplineSetReader< typename SA::SplineBase >::readOneOrbitalCoefs(), EinsplineSetBuilder::ReadOrbitalInfo_ESHDF(), TEST_CASE(), and qmcplusplus::TEST_CASE().

294  {
295  if (Mode[NOIO])
296  return true;
297  hid_t p = group_id.empty() ? file_id : group_id.top();
298  h5data_proxy<T> e(data);
299  return e.read(data, p, aname, xfer_plist);
300  }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
hid_t file_id
file id
Definition: hdf_archive.h:68
hid_t xfer_plist
transfer property
Definition: hdf_archive.h:72

◆ readSlabReshaped()

void readSlabReshaped ( T &  data,
const std::array< IT, RANK > &  shape,
const std::string &  aname 
)
inline

read file dataset with a specific shape into a container and check status

Parameters
datacontainer, linear storage required.
shapeshape on the hdf file
anamedataset name in the file runtime error is issued on I/O error

Definition at line 321 of file hdf_archive.h.

References hdf_archive::read().

Referenced by EshdfFile::handleDensity(), EshdfFile::handleKpt(), SkParserHDF5::parse(), HDFWalkerInput_0_4::read_hdf5(), HDFWalkerInput_0_4::read_hdf5_scatter(), RandomNumberControl::read_rank_0(), EshdfFile::readKptGvecs(), TEST_CASE(), and OneBodyDensityMatricesTests< T >::testRegisterAndWrite().

322  {
323  std::array<hsize_t, RANK> globals, counts, offsets;
324  for (int dim = 0; dim < RANK; dim++)
325  {
326  globals[dim] = static_cast<hsize_t>(shape[dim]);
327  counts[dim] = static_cast<hsize_t>(shape[dim]);
328  offsets[dim] = 0;
329  }
330 
331  hyperslab_proxy<T, RANK> pxy(data, globals, counts, offsets);
332  read(pxy, aname);
333  }
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

◆ readSlabSelection()

void readSlabSelection ( T &  data,
const std::array< IT, RANK > &  readSpec,
const std::string &  aname 
)
inline

read a portion of the data from the group aname and check status runtime error is issued on I/O error

note the readSpec array must have dimensionality corresponding to the dataset, values for a dimension must be [0,num_entries-1] for that dimension to specify which value to hold and a -1 to grab all elements from that dimension for example, if the dataset was [5,2,6] and the vector contained (2,1,-1), this would grab 6 elements corresponding to [2,1,:]

Definition at line 345 of file hdf_archive.h.

References hdf_archive::read().

Referenced by EshdfFile::handleKpt(), and TEST_CASE().

346  {
347  std::array<hsize_t, RANK> globals, counts, offsets;
348  for (int dim = 0; dim < RANK; dim++)
349  {
350  globals[dim] = 0;
351  if (readSpec[dim] < 0)
352  {
353  counts[dim] = 0;
354  offsets[dim] = 0;
355  }
356  else
357  {
358  counts[dim] = 1;
359  offsets[dim] = static_cast<hsize_t>(readSpec[dim]);
360  }
361  }
362 
363  hyperslab_proxy<T, RANK> pxy(data, globals, counts, offsets);
364  read(pxy, aname);
365  }
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

◆ set_access_plist() [1/2]

void set_access_plist ( Communicate comm,
bool  request_pio 
)
private

set the access property

Definition at line 62 of file hdf_archive.cpp.

References hdf_archive::access_id, qmcplusplus::comm, Communicate::getMPI(), hdf_archive::IS_MASTER, hdf_archive::IS_PARALLEL, hdf_archive::lcpl_id, hdf_archive::Mode, hdf_archive::NOIO, Communicate::rank(), Communicate::size(), and hdf_archive::xfer_plist.

63 {
64  access_id = H5P_DEFAULT;
65  lcpl_id = H5Pcreate(H5P_LINK_CREATE);
66  H5Pset_create_intermediate_group(lcpl_id, true);
67  if (comm && comm->size() > 1) //for parallel communicator
68  {
69  bool use_phdf5 = false;
70 #if defined(ENABLE_PHDF5)
71  if (request_pio)
72  {
73  // enable parallel I/O
74  MPI_Info info = MPI_INFO_NULL;
75  access_id = H5Pcreate(H5P_FILE_ACCESS);
76  H5Pset_all_coll_metadata_ops(access_id, true);
77  H5Pset_coll_metadata_write(access_id, true);
78  H5Pset_fapl_mpio(access_id, comm->getMPI(), info);
79  xfer_plist = H5Pcreate(H5P_DATASET_XFER);
80  // enable parallel collective I/O
81  H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
82  use_phdf5 = true;
83  }
84 #endif
85  Mode.set(IS_PARALLEL, use_phdf5);
86  Mode.set(IS_MASTER, !comm->rank());
87  if (request_pio && !use_phdf5)
88  Mode.set(NOIO, comm->rank()); // master only
89  else
90  Mode.set(NOIO, false); // pio or all.
91  }
92  else
93  {
94  Mode.set(IS_PARALLEL, false);
95  Mode.set(IS_MASTER, true);
96  Mode.set(NOIO, false);
97  }
98 }
int rank() const
return the rank
Definition: Communicate.h:116
hid_t lcpl_id
Link creation property list identifier.
Definition: hdf_archive.h:74
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
int size() const
return the number of tasks
Definition: Communicate.h:118
hid_t access_id
access id
Definition: hdf_archive.h:70
hid_t xfer_plist
transfer property
Definition: hdf_archive.h:72
mpi_comm_type getMPI() const
return the Communicator ID (typically MPI_WORLD_COMM)
Definition: Communicate.h:113

◆ set_access_plist() [2/2]

void set_access_plist ( )
private

Definition at line 52 of file hdf_archive.cpp.

References hdf_archive::access_id, hdf_archive::IS_MASTER, hdf_archive::IS_PARALLEL, hdf_archive::lcpl_id, hdf_archive::Mode, and hdf_archive::NOIO.

Referenced by hdf_archive::hdf_archive().

53 {
54  access_id = H5P_DEFAULT;
55  lcpl_id = H5Pcreate(H5P_LINK_CREATE);
56  H5Pset_create_intermediate_group(lcpl_id, true);
57  Mode.set(IS_PARALLEL, false);
58  Mode.set(IS_MASTER, true);
59  Mode.set(NOIO, false);
60 }
hid_t lcpl_id
Link creation property list identifier.
Definition: hdf_archive.h:74
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
hid_t access_id
access id
Definition: hdf_archive.h:70

◆ top()

hid_t top ( ) const
inline

return the top of the group stack

Definition at line 192 of file hdf_archive.h.

References hdf_archive::file_id, and hdf_archive::group_id.

Referenced by ObservableHelper::write(), TraceBuffer< TraceInt >::write_hdf(), and WalkerLogBuffer< WLog::Real >::writeHDF().

192 { return group_id.empty() ? file_id : group_id.top(); }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ unlink()

void unlink ( const std::string &  aname)
inline

Definition at line 367 of file hdf_archive.h.

References hdf_archive::file_id, hdf_archive::group_id, hdf_archive::Mode, and hdf_archive::NOIO.

368  {
369  if (Mode[NOIO])
370  return;
371  hid_t p = group_id.empty() ? file_id : group_id.top();
372  herr_t status = H5Ldelete(p, aname.c_str(), H5P_DEFAULT);
373  }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
hid_t file_id
file id
Definition: hdf_archive.h:68

◆ write()

void write ( T &  data,
const std::string &  aname 
)
inline

write the data to the group aname and check status runtime error is issued on I/O error

Definition at line 259 of file hdf_archive.h.

References hdf_archive::writeEntry().

Referenced by ObservableHelper::addProperty(), HybridRepSetReader< SA >::create_spline_set(), SplineSetReader< typename SA::SplineBase >::create_spline_set(), QMCGaussianParserBase::createBasisSetWithHDF5(), QMCGaussianParserBase::createCenterH5(), QMCGaussianParserBase::createDeterminantSetWithHDF5(), QMCGaussianParserBase::createIonSet(), QMCGaussianParserBase::createMultiDeterminantSetCIHDF5(), QMCGaussianParserBase::createShellH5(), QMCGaussianParserBase::createSPOSetsH5(), HDFWalkerOutput::dump(), QMCGaussianParserBase::dump(), QMCFixedSampleLinearOptimizeBatched::one_shift_run(), TraceSamples< std::complex< TraceReal > >::register_hdf_data(), WalkerLogBuffer< WLog::Real >::registerHDFData(), QMCCostFunctionBase::reportParametersH5(), TEST_CASE(), BranchIO< SFNB >::write(), NEReferencePoints::write(), HDFWalkerOutput::write_configuration(), RandomNumberControl::write_parallel(), RandomNumberControl::write_rank_0(), hdf_archive::writeSlabReshaped(), VariableSet::writeToHDF(), FakeOptimizableObject::writeVariationalParameters(), and RotatedSPOs::writeVariationalParameters().

260  {
261  if (!writeEntry(data, aname))
262  {
263  throw std::runtime_error("HDF5 write failure in hdf_archive::write " + aname);
264  }
265  }
bool writeEntry(T &data, const std::string &aname)
write the data to the group aname and return status use write() for inbuilt error checking ...
Definition: hdf_archive.h:244

◆ writeEntry()

bool writeEntry ( T &  data,
const std::string &  aname 
)
inline

write the data to the group aname and return status use write() for inbuilt error checking

Returns
true if successful

Definition at line 244 of file hdf_archive.h.

References qmcplusplus::Units::charge::e, hdf_archive::file_id, hdf_archive::group_id, hdf_archive::IS_MASTER, hdf_archive::IS_PARALLEL, hdf_archive::Mode, hdf_archive::NOIO, and hdf_archive::xfer_plist.

Referenced by TEST_CASE(), hdf_archive::write(), SplineR2R< ST >::write_splines(), SplineC2R< ST >::write_splines(), AtomicOrbitals< ST >::write_splines(), SplineC2C< ST >::write_splines(), SplineC2COMPTarget< ST >::write_splines(), SplineC2ROMPTarget< ST >::write_splines(), and HybridRepCenterOrbitals< SPLINEBASE::DataType >::write_splines().

245  {
246  if (Mode[NOIO])
247  return true;
248  if (!(Mode[IS_PARALLEL] || Mode[IS_MASTER]))
249  throw std::runtime_error("Only write data in parallel or by master but not every rank!");
250  hid_t p = group_id.empty() ? file_id : group_id.top();
251  h5data_proxy<typename std::remove_const<T>::type> e(data);
252  return e.write(data, p, aname, xfer_plist);
253  }
std::stack< hid_t > group_id
FILO to handle H5Group.
Definition: hdf_archive.h:76
std::bitset< 4 > Mode
bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed
Definition: hdf_archive.h:66
hid_t file_id
file id
Definition: hdf_archive.h:68
hid_t xfer_plist
transfer property
Definition: hdf_archive.h:72

◆ writeSlabReshaped()

void writeSlabReshaped ( T &  data,
const std::array< IT, RANK > &  shape,
const std::string &  aname 
)
inline

write the container data with a specific shape and check status

Parameters
datacontainer, linear storage required.
shapeshape on the hdf file
anamedataset name in the file runtime error is issued on I/O error

Definition at line 274 of file hdf_archive.h.

References hdf_archive::write().

Referenced by TEST_CASE(), HDFWalkerOutput::write_configuration(), and RandomNumberControl::write_rank_0().

275  {
276  std::array<hsize_t, RANK> globals, counts, offsets;
277  for (int dim = 0; dim < RANK; dim++)
278  {
279  globals[dim] = static_cast<hsize_t>(shape[dim]);
280  counts[dim] = static_cast<hsize_t>(shape[dim]);
281  offsets[dim] = 0;
282  }
283 
284  hyperslab_proxy<T, RANK> pxy(data, globals, counts, offsets);
285  write(pxy, aname);
286  }
void write(T &data, const std::string &aname)
write the data to the group aname and check status runtime error is issued on I/O error ...
Definition: hdf_archive.h:259

Member Data Documentation

◆ access_id

hid_t access_id
private

◆ file_id

◆ group_id

◆ group_names

std::vector<std::string> group_names
private

Track group names corresponding to group_id.

Definition at line 78 of file hdf_archive.h.

Referenced by hdf_archive::close(), hdf_archive::group_path_as_string(), hdf_archive::pop(), and hdf_archive::push().

◆ is_closed

◆ lcpl_id

hid_t lcpl_id
private

Link creation property list identifier.

Definition at line 74 of file hdf_archive.h.

Referenced by hdf_archive::push(), hdf_archive::set_access_plist(), and hdf_archive::~hdf_archive().

◆ Mode

std::bitset<4> Mode
private

bitset of the io mode Mode[IS_PARALLEL] : true, if parallel Mode[IS_MASTER] : true, if the node is master Mode[NOIO] : true, if I/O is not performed

Definition at line 66 of file hdf_archive.h.

Referenced by hdf_archive::create(), hdf_archive::getShape(), hdf_archive::is_dataset(), hdf_archive::is_dataset_of_type(), hdf_archive::is_group(), hdf_archive::is_master(), hdf_archive::is_parallel(), hdf_archive::open(), hdf_archive::push(), hdf_archive::readEntry(), hdf_archive::set_access_plist(), hdf_archive::unlink(), and hdf_archive::writeEntry().

◆ possible_filename_

std::string possible_filename_
private

Name of file that hdf_archive thinks is open.

This may not correspond to the actual file because the open call failed, or the file was closed. This information is useful for debugging.

Definition at line 84 of file hdf_archive.h.

Referenced by hdf_archive::create(), hdf_archive::open(), and hdf_archive::push().

◆ xfer_plist

hid_t xfer_plist
private

The documentation for this class was generated from the following files: