← Documentation
ADS-IDAC Engine 5.0.0
RestartTrim.h File Reference

Slice a RELAP5 restart buffer down to the one record a transfer needs. More...

#include <cstdint>
#include <cstring>
#include <vector>
Include dependency graph for RestartTrim.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  adsidac::RestartLayout
 Byte offsets of the structural landmarks in a restart buffer. An offset is meaningful only when its have_* flag is true. More...
 

Namespaces

namespace  adsidac
 

Functions

RestartLayout adsidac::scan_restart (const std::vector< char > &buf, std::int32_t want)
 Walk the record chain and locate the header, the base dump and the target dump. More...
 
bool adsidac::has_complete_restart (const std::vector< char > &buf)
 Does this buffer contain a complete restart dump (the base)? More...
 
std::vector< char > adsidac::extract_header_and_base (const std::vector< char > &buf)
 [header][complete base], the run-wide constant that is cached per rank and published as <project>/restart_base.bin. More...
 
std::vector< char > adsidac::extract_record_no_base (const std::vector< char > &buf, std::int32_t want)
 [header][target], the wire payload with the base omitted. More...
 
std::vector< char > adsidac::splice_base (const std::vector< char > &hdr_base, const std::vector< char > &body)
 Put the cached base back in front of a base-less transfer. More...
 
std::vector< char > adsidac::extract_restart_record (const std::vector< char > &buf, std::int32_t want)
 [header][complete base][target]: self-contained, no cache needed. More...
 

Detailed Description

Slice a RELAP5 restart buffer down to the one record a transfer needs.

A captured buffer accumulates one restart dump per branch point for the whole lineage. In MPI every branch of a branch point is transferred separately, and an untrimmed transfer carries all of it, while the receiver restores from exactly one record. The helpers here cut a buffer down to [header][target] and put the shared [header][base] prefix back at the receiver. The engine applies them only when the environment variable ADS_RESTART_TRIM is "1" (AdsidacCallback::onBranchingPoint; default off).

MPI-only by construction: the serial engine shares one buffer across every child of a sequence and genuinely needs all the dumps.

All functions are pure (no I/O, no globals) and tolerate a malformed buffer: the record walk stops at the first record that does not fit, and the extractors return an empty vector when a needed landmark is missing.

Buffer layout (src/Relap/restart_membuf.f90), little-endian int32:

[reclen][payload: reclen bytes][reclen]      repeated

A dump opens with a header record (payload 8 B, membuf_write_hdr) followed by membuf_write_r8(rshead,3) — payload 24 B whose first 8 bytes are the text restart. Within that payload (rstrec.f:134, ishead equivalenced onto rshead):

bytes  0..7   'restart'
bytes  8..11  flag word; bit 4 (16) = iscompleterestart4
bytes 16..19  ncount   <- the number card 103 selects on

Two facts drive the design:

  1. rrestf.f does if (frst .and. .not.fl) call fabend: the FIRST restart record the reader sees must be a COMPLETE restart. The per-branch-point dumps are not; only the base one is. Omitting it aborts RELAP in fabend.
  2. [header + base] is byte-identical across the lineages of a run. It is a run-wide constant, so it can be cached once per rank and left off the wire.

Definition in file RestartTrim.h.