Binary field I/O specification (MPI-IO)¶
This document describes the raw binary files produced by pfc::BinaryWriter (including the JSON-driven path in add_result_writers_from_json). Those headerless MPI-IO bricks remain the scheduled ResultsWriter / BinaryWriter format for periodic field dumps and post-processing when you are not using VTK or PNG.
Durable versioned restart bundles use
pfc::checkpoint::publish_checkpoint_directory instead — a directory with
metadata.json plus accepted field bricks, published atomically. See
docs/development/checkpoint_publish.md.
Do not treat a lone headerless BinaryWriter file as the full checkpoint /
restart contract.
Implementation references: include/openpfc/frontend/io/binary_writer.hpp, include/openpfc/kernel/simulation/binary_reader.hpp, include/openpfc/frontend/utils/utils.hpp (format_with_number).
File contents¶
Property |
Value |
|---|---|
Layout |
A single global 3D array in Fortran (column-major) order ( |
Element type |
Real fields: |
MPI filetype / etype |
|
Byte order |
Native ( |
Header / magic |
None. The file is only the raw payload for the MPI file view (no metadata block, no version tag). |
Per-rank data |
Each MPI rank writes its local brick; together the ranks cover the global grid without overlap. The view is built from |
Domain geometry |
|
Local buffer contract |
Each rank’s buffer element count must equal the local brick product |
Local count limit |
Classic MPI-IO count parameters are |
Each write(increment, field) call:
Builds the output filename from the template and
increment(see below).Opens the file (truncate), sets the MPI-IO file view, performs
MPI_File_write_all, closes the file.Is collective over the writer’s communicator (default
MPI_COMM_WORLD): every rank in that communicator must participate inwrite()with a consistent domain layout, or the job can deadlock.
Filename template and increment¶
The JSON fields[].data string is passed to BinaryWriter as the filename template.
If the string contains
%, it is passed toprintf-style formatting with the integerincrementsupplied by the simulator (seesimulation_wiring_writers.hppandBinaryWriter::write_mpi_binary).
Examples:./psi_%d.bin,./data/u_%04d.bin.If there is no
%, the same path is used on every write (overwrites each time).
The increment value is advanced by the simulator according to configuration (see app_pipeline.md and the simulator section in JSON).
Reading back (BinaryReader)¶
BinaryReader uses the same Fortran-ordered 3D subarray view and MPI_File_read_all at displacement 0.
API |
Element type |
|---|---|
|
|
|
|
Implications:
Files written as pure
doublereal fields with the same(global, local, offset)decomposition can be read back for restart orFileReaderinitial conditions.Files written as
std::complex<double>round-trip throughBinaryReader::read(..., ComplexField&)with the same decomposition.Match communicator, decomposition, and datatype when reading: a file written on N ranks is not automatically loadable on a different N without re-decomposition logic outside this low-level format. Do not read a complex file with the real
readoverload (or vice versa).
JSON configuration surface¶
When saveat > 0 and fields is present, add_result_writers_from_json registers one BinaryWriter per fields[] entry:
name— field label used by the simulator when dispatching the writer.data— filename template as above.
Rank 0 may create parent directories for data. See io_results.md and configuration.md.
Post-processing without OpenPFC¶
Because there is no file header, external tools need out-of-band metadata: global Lx, Ly, Lz, dtype (float64 or complex-of-two-float64), Fortran ordering, and how ranks map to subdomains if you concatenate manually. In practice, teams either:
Read with OpenPFC (
BinaryReaderor existing tooling), orRecord metadata alongside runs (JSON/YAML sidecar), or
Use VTK export for visualization (
VTKWriter; seetutorials/vtk_paraview_workflow.md).
Longer offline sketch (metadata, NumPy layout): postprocess_binary_fields.md.
See also¶
checkpoint_publish.md— atomic accepted-state restart bundlesio_results.md— writers overviewpostprocess_binary_fields.md— reasoning about raw bytes outside OpenPFCtutorials/end_to_end_visualization.md— run that produces binariesapp_pipeline.md— when writers are wired