Skip to content

HDF5 tables: files written field by field in HDF5 format (.h5) (#1560) - #1582

Open
carlocamilloni wants to merge 4 commits into
masterfrom
hdf5-tables
Open

carlocamilloni wants to merge 4 commits into
masterfrom
hdf5-tables

Conversation

@carlocamilloni

Copy link
Copy Markdown
Member
  • tools/H5Table: writer and reader of tables in HDF5 files (libhdf5 C API, optional). Layout (version 1): root attribute plumed_format=plumed-table; groups block_0, block_1, ... (a new block when the fields change); one extendable chunked 1-D dataset per field (double, int64 or string; deflate when available), in the order of the attribute plumed_columns; constant fields as attributes listed in plumed_constants. Full precision, FMT ignored. The reader gives the lines of the equivalent text file (numbers with %.17g), so IFile reads .h5 files wherever it reads text files.
  • OFile: a file whose name ends with .h5 is written with the HDF5 writer on the writing process (fp is the null device); fields keep their typed value; printf on such a file is an error (free text); rewind is not supported. The trimming at the restart step is done at open. FileBase::closeBackend.
  • Restarts: trimming at the restart step (Checkpointing::trimAtRestart reads the table as text lines, keeps rows by block, removed rows go to bck.trimmed.N.name.h5), CHECKPOINT stores the rows of every block (h5rows) and truncates to them. METAD: no incomplete-line removal for .h5, WALKERS_N with .h5 hills is an error.
  • New cltool h5convert (text <-> HDF5).
  • configure: libhdf5 enabled by default (autodetected), hdf5.h located with pkg-config when needed (Debian/Ubuntu).
  • Regtests basic/rt-h5-tables, basic/rt-h5-mpi, opes/rt-h5-opes; docs in the Files page; CHANGES.

Claude-Session: https://claude.ai/code/session_016vwxtVYJZTnryBhjdtFbvH

Description
Target release

I would like my code to appear in release XXXXX

Type of contribution
  • changes to code or doc authored by PLUMED developers, or additions of code in the core or within the default modules
  • changes to a module not authored by you
  • new module contribution or edit of a module authored by you
Copyright
  • I agree to transfer the copyright of the code I have written to the PLUMED developers or to the author of the code I am modifying.
  • the module I added or modified contains a COPYRIGHT file with the correct license information. Code should be released under an open source license. I also used the command cd src && ./header.sh mymodulename in order to make sure the headers of the module are correct.
Tests
  • I added a new regtest or modified an existing regtest to validate my changes.
  • I verified that all regtests are passed successfully on GitHub Actions.

- tools/H5Table: writer and reader of tables in HDF5 files (libhdf5 C API,
  optional). Layout (version 1): root attribute plumed_format=plumed-table;
  groups block_0, block_1, ... (a new block when the fields change); one
  extendable chunked 1-D dataset per field (double, int64 or string; deflate
  when available), in the order of the attribute plumed_columns; constant
  fields as attributes listed in plumed_constants. Full precision, FMT
  ignored. The reader gives the lines of the equivalent text file (numbers
  with %.17g), so IFile reads .h5 files wherever it reads text files.
- OFile: a file whose name ends with .h5 is written with the HDF5 writer on
  the writing process (fp is the null device); fields keep their typed value;
  printf on such a file is an error (free text); rewind is not supported.
  The trimming at the restart step is done at open. FileBase::closeBackend.
- Restarts: trimming at the restart step (Checkpointing::trimAtRestart reads
  the table as text lines, keeps rows by block, removed rows go to
  bck.trimmed.N.name.h5), CHECKPOINT stores the rows of every block
  (h5rows) and truncates to them. METAD: no incomplete-line removal for .h5,
  WALKERS_N with .h5 hills is an error.
- New cltool h5convert (text <-> HDF5).
- configure: libhdf5 enabled by default (autodetected), hdf5.h located with
  pkg-config when needed (Debian/Ubuntu).
- Regtests basic/rt-h5-tables, basic/rt-h5-mpi, opes/rt-h5-opes; docs in
  the Files page; CHANGES.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016vwxtVYJZTnryBhjdtFbvH
…HDF5 tables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016vwxtVYJZTnryBhjdtFbvH
…F5 table)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016vwxtVYJZTnryBhjdtFbvH
Comment thread src/tools/OFile.cpp Fixed
Comment thread src/tools/OFile.cpp
#ifdef _WIN32
fp=std::fopen("NUL","w");
#else
fp=std::fopen("/dev/null","w");
- OFile: files rewritten at every write (rewind) can be HDF5 tables: the
  previous table is kept as bck.last.name, a new one is created at the next
  row. The writer is created at the first row (so that a file rewound
  before its first row is never trimmed, as with text files); before that
  the rows of the table are read from the file (checkpoint). Blank lines
  printed with printf (between the rows of a grid) are ignored; any other
  text is still an error.
- So METAD grids (GRID_WFILE/GRID_RFILE), DUMPGRID and the OPES state
  (STATE_WFILE/STATE_RFILE) can be HDF5 tables, one row per grid point as
  in text; restarts from them keep the full precision.
- New regtest opes/rt-h5-grids: grid, state and histogram tables equal to
  their text twins; restart from the HDF5 grid and state gives the biases
  of the uninterrupted run (except at the restart step, where the grid and
  state already contain the hill/kernel of that step, as with text files).
- conda recipe: hdf5 in host (run export), -lhdf5, test of libhdf5.
- Docs (Files page), CHANGES.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016vwxtVYJZTnryBhjdtFbvH
Comment thread src/tools/H5Table.cpp
const std::size_t n=H5Tget_size(t);
std::string buf(n,'\0');
err=H5Aread(a,t,buf.data());
v.s=buf.c_str();

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants