Skip to content

shore.io.proc_input ​

Xall proc.input writer + merger.

proc.input is the runtime work-distribution descriptor Xall reads at MPI startup. It maps each block to an MPI rank and carries the per-block group (rigid-body group) and body (corpo) indices the solver's force/moment integration needs.

This file is a sibling of the chimera descriptor cc.par, not a downstream artefact: cc.par is consumed by the overset preprocessor (which emits the runtime artefacts the solver actually uses), while proc.input is consumed directly by Xall.

File format ​

Plain ASCII, free-format, parsed by Fortran list-directed read(*,*). 7-line header + N block records:

<line 1: free-form comment, e.g. "generated by SHORE">
<blank>
<blank>
<N>  number of blocks
<blank>
<blank>
<column-header line, free-form>
<block_idx>  <group>  <body>  <proc>  ! optional comment
...                                        x N

Block records carry exactly 4 numeric columns; the trailing ! ... comment is advisory (the Fortran reader stops at column 4).

References

Reader (authoritative): Xnavis-projects/Xnavis/Solver/src/input.f90, lines 45-119.

Writers in the wild (for context): LoadBalance/src/Lib_Balance.F90 (save_proc_input) and overset-exploded/src/lib/overset_exploded_library.F90 (save_proc_input).

Block indexing comes from the .grd file order — block 1 in proc.input is block 1 in the .grd. See :func:shore.io.grd.read_grd_metadata for the per-block cell counts this module uses as load-balancing weights.

BalanceSummary dataclass ​

python
BalanceSummary(
    n_blocks: int,
    np: int,
    per_rank_blocks: list[int],
    per_rank_cells: list[int],
    imbalance: float,
    cells_known: bool = True,
)

source

One-screen report of the load distribution in a generated proc.input.

Returned by :func:write_proc_input and used by the CLI to print the balance summary on stderr for parallel runs.

Attributes

  • n_blocks — Total block count.
  • np — Total MPI rank count.
  • per_rank_blocks — Block count per rank, indexed by 0-based rank.
  • per_rank_cells — Interior-cell-count (FV work) per rank, indexed by 0-based rank. Each block contributes ni * nj * nk cells, where the .grd header already stores those as node-1 per axis. Set to all-zero by :func:merge_proc_input when no .grd is given, since proc.input doesn't store per-block weights.
  • imbalance — (max - min) / mean of per_rank_cells, in fractional units. 0.0 = perfect balance. Computed only when np > 1 and cells_known; 0.0 for serial (np == 1) runs.
  • cells_known — True for :func:write_proc_input (which reads weights from the .grd); False for :func:merge_proc_input (which only sees block-to-rank assignments). When False, the format() rendering omits the cell count and imbalance so it doesn't suggest a wrong work-balance picture.

BalanceSummary.format method ​

python
format() -> str

source

Render a human-readable multi-line summary.

With cell-count weights available:

proc.input: 11 blocks across 4 ranks
  rank 0: 3 blocks, 1.84M cells (28.1%)
  ...
  imbalance: 4.5%

Without (e.g. the merger output):

proc.input: 11 blocks across 4 ranks
  rank 0: 3 blocks
  rank 1: 4 blocks
  ...

write_proc_input function ​

python
write_proc_input(
    grd_path: str | Path,
    out_path: str | Path,
    *,
    np: int = 1,
    proc_assignment: dict[int, int] | None = None,
    group_assignment: dict[int, int] | None = None,
    body_assignment: dict[int, int] | None = None,
    header_comment: str = 'generated by SHORE',
) -> tuple[Path, BalanceSummary]

source

Write a proc.input file from a SHORE-generated .grd.

Block ordering and weights come from grd_path — block 1 in the output is block 1 in the .grd, with weight ni * nj * nk. :func:shore.io.grd.read_grd_metadata already returns per-block interior-cell counts (the .grd header stores node-1 per axis), so ni * nj * nk is the cell-work weight a cell-centred FV solver actually balances — not a node count. When proc_assignment is omitted and np > 1, blocks are distributed across range(np) by a greedy LPT seed (descending weight onto the least-loaded rank) followed by a local-search refinement (move/swap steps that shrink the peak-to-trough span).

Parameters

  • grd_path — Path to a SHORE / Xall .grd file. Header is read for the block count and per-block (ni, nj, nk) cell counts; the coordinate payload is not touched.
  • out_path — Output proc.input path.
  • np — Total MPI rank count. Default 1 (serial). Must be >= 1.
  • proc_assignment — Optional explicit {block_idx (1-based) → proc (0-based)} map. Any block not listed gets the greedy-balanced default. Procs outside range(np) are rejected.
  • group_assignment — Optional {block_idx → group} map. Default 0 for every block.
  • body_assignment — Optional {block_idx → body} map. Default 0 for every block.
  • header_comment — Free-form text written on header line 1. Default "generated by SHORE".

Returns

  • tuple[Path, BalanceSummary] — The actual output path and the per-rank load summary.

Raises

  • ParameterError — If np < 1, an assignment dict references an unknown block index, or proc_assignment references a rank outside range(np).
  • FileNotFoundError, ValueError — Forwarded from :func:read_grd_metadata.

merge_proc_input function ​

python
merge_proc_input(
    inputs: list[str | Path],
    out: str | Path,
    *,
    grd_path: str | Path | None = None,
    header_comment: str = 'merged by SHORE',
) -> tuple[Path, BalanceSummary]

source

Concatenate multiple proc.input files into one.

Block indices shift by the cumulative block count of preceding inputs, mirroring :func:shore.io.grd.merge_grd. group, body, and proc columns pass through verbatim — the merger does not re-run load balancing or renumber bodies / groups across components; collisions are the user's choice.

Invoke merge_proc_input and :func:shore.io.grd.merge_grdas a pair, with the same input ordering — block-indices in proc.input are 1-based positions into the merged .grd's block list.

Parameters

  • inputs — Two-or-more input proc.input paths.
  • out — Output path.
  • grd_path — Optional path to the merged .grd. When supplied, the returned :class:BalanceSummary carries real cell counts and the meaningful imbalance figure (cells_known=True); when None, the summary falls back to per-rank block counts only (cells_known=False) because proc.input itself doesn't store per-block weights.
  • header_comment — Free-form text written on header line 1 of the merged file.

Returns

  • tuple[Path, BalanceSummary] — The actual output path and the per-rank load summary across all merged blocks.

Raises

  • ValueError — If inputs has fewer than 2 entries.
  • FileNotFoundError — If any input path does not exist, or grd_path is supplied and missing.
  • ParameterError — If any input file is malformed, or the merged block count disagrees with the grd_path block count.

Released under the MIT License.