container.txt File Format Specification¶
Audience: Developers working on the FMU Container runtime (C) or the Python tooling.
The container.txt file is the runtime configuration file that describes how a container FMU orchestrates its embedded FMUs. It is generated by the Python tooling (package fmu_manipulation_toolbox.container: builder.py and txt.py, value references allocated by layout.py), consumed by the C runtime (container/config.c), and read back by fmusplit (split.py). The file is located at resources/container.txt inside the .fmu archive.
The list of types and the conversion functions are defined once, in fmu_manipulation_toolbox/container/types.py (ALL_TYPES, CONVERSION_FUNCTION), shared by the writer and by split.py; every conversion name is implemented by a CASE(...) of container/convert.c.
General Syntax Rules¶
- The first line is the version header
# Version <N>: it is mandatory and checked by the C runtime. - The other lines starting with
#are comments and are skipped by the parser. - Each non-comment line contains space-separated tokens.
- The lines have no length limit (the runtime grows its line buffer as needed; before 2.0 a line longer than 4095 characters was cut, which shifted the reading of the rest of the file).
- The parser reads lines sequentially; the order of sections is fixed.
File Structure Overview¶
The file is organized into the following sections, in order:
- Version Header
- Container Flags
- Internal Time Step
- Embedded FMU Declarations
- Initialization Order (version ≥ 7)
- Local Variables Count
- Container I/O Table
- Per-FMU I/O Sections (repeated for each embedded FMU)
- Importer Clocks
1. Version Header¶
The first line indicates the file format version. The version number N determines how subsequent sections are parsed.
The version is defined twice, with the same value: CONTAINER_TXT_VERSION of fmu_manipulation_toolbox/container/types.py, written by the builder, and CONTAINER_TXT_VERSION of container/container.h, read by the runtime (a unit test checks that they are equal). The runtime only reads its own version: it is always shipped with the container.txt of its builder. A missing header or another version is refused when the container is instantiated, with one of the errors:
container.txt has no format version header: the container was built by an incompatible version of FMU Manipulation Toolbox.container.txt format version <N>, this runtime reads version <M>: build the container again with the version of FMU Manipulation Toolbox that provides this runtime.
fmusplit (split.py) reads every version of the table below.
| Version | Introduced In | Key Changes |
|---|---|---|
| 0 (implicit) | ≤ 1.8.4 | Legacy format: 3-token I/O lines (<VR> <FMU_ID> <FMU_VR>), single flag line, FMI-2 types only |
| 1 | ~1.8.x | Separate MT and Profiling flag lines; multi-target I/O lines (<VR> <NB> <FMU_ID> <FMU_VR> [...]) |
| 2 | 1.9 | Merged flags into a single line (<MT> <Profiling> <Sequential>); added all FMI-3 types (except binary/clock); added conversion tables |
| 3 | 1.9.2 | Added binary and clock types; added clocked I/O sections; added importer clocks section |
| 4 | 1.9.3 | Added <DIM> (dimension) field in I/O lines to support array variables |
| 5 | 1.9.4 | Local variables addressed by their storage offset: <LOCAL_OFFSET> instead of the local VR in the per-FMU I/O lines, and as <FMU_VR> of the local lines of the container I/O table (an array occupies several slots) |
| 6 | 2.0b1 | Model-Exchange support: FMU count split into <nb_fmu_cs> <nb_fmu_me>, ME entries carry <nx> <nz>; reserved integer32 slot for the ME solver |
| 7 | 2.0b2 | Reset trigger of each embedded FMU (container.<fmu>.reset), after its conversion table; initialization order of the embedded FMUs, after their declarations |
| 8 | 2.1 | Importer clocks: all the time-based clocks, with <VARIABILITY> <INTERVAL> <SHIFT> |
| 9 | 2.1 | <has_configuration_mode> of each embedded FMU (CS and ME lines); start values <RESET>=2 of the structural parameters, set in Configuration Mode (FMI-LS-XCP) |
| 10 | 2.1 | <MT_THRESHOLD_US> on the flags line: the hybrid multi-thread mode |
2. Container Flags¶
# Container flags <MT> <Profiling> <Sequential> <MT_THRESHOLD_US>
<MT> <Profiling> <Sequential> <MT_THRESHOLD_US>
Three integer flags (0 or 1) and an integer:
| Flag | Meaning |
|---|---|
MT | Enable multi-threaded parallel execution of embedded FMUs |
Profiling | Enable profiling (RT ratio outputs per FMU) |
Sequential | Use sequential scheduling (each FMU computes one after another with immediate output propagation) |
MT_THRESHOLD_US | Microseconds (50 by default; the API and the CLI give seconds, rounded to the µs): with MT=1, a Co-Simulation FMU whose mean doStep over the first MT_WARMUP (20) internal steps takes at least this duration is stepped by a worker thread |
Execution mode logic (C runtime): - If Sequential=1: sequential mode (set inputs → doStep → get outputs per FMU, in order) - Else if MT=1: hybrid multi-thread mode. The first MT_WARMUP internal steps run as the single-thread parallel mode, timing the doStep of each CS FMU; then the heavy FMUs (mean at least MT_THRESHOLD_US) are stepped by min(heavy FMUs, cores - 1) worker threads (longest first, to the least loaded worker), the light ones by the main thread meanwhile; the inputs and outputs are exchanged by the main thread, as in the single-thread parallel mode. Without heavy FMU, the single-thread parallel mode goes on. - Else: parallel mode with a single thread (set all inputs → doStep all → get all outputs)
Version differences¶
- Version 0/1: The MT flag and profiling flag were on separate lines.
- Version ≥ 2: All three flags are on a single space-separated line.
- Version ≥ 10:
<MT_THRESHOLD_US>follows the three flags.
3. Internal Time Step¶
A floating-point value representing the fundamental internal time step in seconds (e.g., 0.001).
4. Embedded FMU Declarations¶
# NB of embedded FMU's
<nb_fmu_cs> <nb_fmu_me>
<fmu_filename> <fmi_version> <has_event_mode> <has_configuration_mode>
<model_identifier>
<guid>
...
<fmu_filename> <fmi_version> <nx> <nz> <has_configuration_mode>
<model_identifier>
<guid>
...
<nb_fmu_cs> <nb_fmu_me>: Number of Co-Simulation FMUs, then number of Model-Exchange FMUs. Co-Simulation entries come first, followed by the Model-Exchange entries.- For each Co-Simulation FMU (repeated
nb_fmu_cstimes): - Line 1:
<fmu_filename> <fmi_version> <has_event_mode> <has_configuration_mode>fmu_filename: Name of the.fmufile (e.g.,model.fmu)fmi_version: Integer (2or3)has_event_mode: Integer (0or1) — whether the FMU supports FMI-3 event modehas_configuration_mode: Integer (0or1, version ≥ 9) — the container sets structural parameters of this FMI-3 FMU (start values<RESET>=2, section 7.2): see Configuration Mode
- Line 2:
<model_identifier>— the CoSimulationmodelIdentifier - Line 3:
<guid>— the GUID (FMI-2) or instantiation token (FMI-3) - For each Model-Exchange FMU (repeated
nb_fmu_metimes): - Line 1:
<fmu_filename> <fmi_version> <nx> <nz> <has_configuration_mode>— no event mode flagfmu_filename: Name of the.fmufile (e.g.,model.fmu)fmi_version: Integer (2or3)nxis deduced from<Derivatives>(FMI-2) or from the<ContinuousStateDerivative>entries (FMI-3, array variables counted per element).nzis thenumberOfEventIndicatorsattribute (FMI-2) or the number of<EventIndicator>entries (FMI-3, array variables counted per element).
- Line 2:
<model_identifier>— the ModelExchangemodelIdentifier - Line 3:
<guid>
An FMU providing both interfaces is always embedded as a Co-Simulation FMU.
The FMU's resources are stored in subdirectories named by index: resources/00/, resources/01/, etc.
Version differences¶
- Version 0/1: Only
<fmu_filename>on the first line (no FMI version or event mode flag). - Version 2 to 5: Single count
<nb_fmu>and full triplet<fmu_filename> <fmi_version> <has_event_mode>. - Version ≥ 6: Split count
<nb_fmu_cs> <nb_fmu_me>and dedicated Model-Exchange entries carrying<nx> <nz>on the same line as<fmu_filename> <fmi_version>(instead of<has_event_mode>). - Version ≥ 9:
<has_configuration_mode>at the end of the CS and ME lines.
Configuration Mode (version 9)¶
FMI-3 forbids fmi3EnterConfigurationMode on an FMU without structural parameter: the runtime puts in Configuration Mode only the FMUs with <has_configuration_mode> = 1, once after their instantiation and after each reset:
- when the importer calls
fmi3EnterConfigurationMode/fmi3ExitConfigurationModeon the container, they are forwarded to these FMUs; their start values<RESET>=2are set when they enter it, then the values that the importer sets; - otherwise (FMI-2 container, or importer without Configuration Mode), the container configures them before their other start values:
fmi3EnterConfigurationMode, start values<RESET>=2, values set on the container meanwhile,fmi3ExitConfigurationMode.
A value set on a container port linked to a structural parameter while its FMU is not in Configuration Mode is only kept in the cache of the container, and set when the FMU is configured.
4b. Initialization Order¶
Version ≥ 7. Every index of the embedded FMUs (their order in section 4, from 0) once, in the order in which they propagate their links during the initialization of the container: a topological sort of the graph of the embedded FMUs, with an edge from the FMU of an output to the FMU of each input it is linked to. The clocks, the clocked variables and the container.reset triggers make no edge. Inside a loop, and between independent FMUs, the order of section 4 decides.
5. Local Variables Count¶
# NB local variables: real64, real32, integer8, uinteger8, integer16, uinteger16, integer32, uinteger32, integer64, uinteger64, boolean, boolean1, string, binary, clock
<n_real64> <n_real32> <n_int8> <n_uint8> <n_int16> <n_uint16> <n_int32> <n_uint32> <n_int64> <n_uint64> <n_bool> <n_bool1> <n_string> <n_binary> <n_clock>
15 space-separated unsigned integers indicating the storage size (number of scalar slots) required for each type. This determines the size of the container's internal buffers.
Version differences¶
- Version 0/1: Only 4 values (real64, integer32, boolean, string — matching FMI-2 types).
- Version 2: 13 values (all types except binary and clock).
- Version ≥ 3: All 15 values.
6. Container I/O Table¶
For each type (in the order: real64, real32, integer8, uinteger8, integer16, uinteger16, integer32, uinteger32, integer64, uinteger64, boolean, boolean1, string, binary, clock):
# <type_name>
<nb_ports> <nb_links>
<VR> <DIM> <NB> <FMU_INDEX> <FMU_VR> [<FMU_INDEX> <FMU_VR> ...]
...
<nb_ports>: Number of distinct container-level ports of this type.<nb_links>: Total number of FMU connections across all ports of this type.- Each port line:
<VR>: Container value reference (with type mask in upper 8 bits, masked with& 0xFFFFFFat read time).<DIM>: Dimension of the variable (1 for scalar, >1 for arrays).<NB>: Number of connected FMU ports (fan-out for inputs, always 1 for outputs/locals).-
<FMU_INDEX> <FMU_VR>pairs: For each connection, the FMU index and the value reference within that FMU. Special FMU indices:-1: Refers to a local (internal) variable.-2: Refers to a profiling port.
With a negative
<FMU_INDEX>,<FMU_VR>is the offset of the variable in the local storage of its type (version ≥ 5), not a value reference.
Lines come in this order for each type: reserved slots, container inputs, container outputs, local variables (values of the links and their converted copies).
Reserved slots (allocated first, so their value references are fixed): - real64: time, 0 1 1 -1 0; with profiling, one entry per embedded FMU, <VR> 1 1 -2 <offset> (value references 1 to n, offsets 1 to n). - integer32: container.ts_multiplier, 100663296 1 1 -1 0 (6 << 24), then the ME solver, 100663297 1 1 -1 1 (version ≥ 6). Both are always present, even when the container does not expose them.
Version differences¶
- Version 0: Each line has only 3 tokens:
<VR> <FMU_INDEX> <FMU_VR>(no DIM, no fan-out support). - Version ½/3:
<VR> <NB> <FMU_INDEX> <FMU_VR> [...](no DIM field). - Version 4:
<VR> <DIM> <NB> <FMU_INDEX> <FMU_VR> [...](DIM field added for array support). - Version ≥ 5: same line;
<FMU_VR>of the local lines is the storage offset. - Version ≥ 6: second reserved
integer32slot (ME solver).
7. Per-FMU I/O Sections¶
For each embedded FMU (in declaration order), the following sub-sections appear:
7.1 Inputs¶
For each type:
# Inputs of <fmu_name> - <type>: <LOCAL_OFFSET> <DIM> <FMU_VR>
<nb_inputs>
<LOCAL_OFFSET> <DIM> <FMU_VR>
...
<nb_inputs>: Number of input mappings for this type.- Each line maps a container local variable, given by its offset in the local storage of the type (
LOCAL_OFFSET, version ≥ 5; the masked local VR before), of dimensionDIMto an FMU input port (FMU_VR). An FMI-2 array aggregate (name[1],name[2], ...) gives one line per element, with the value reference of each element (not necessarily consecutive).
Clocked Inputs (Version ≥ 3, not for type clock)¶
# Clocked Inputs of <fmu_name> - <type>: <FMU_VR_CLOCK> <n> <LOCAL_OFFSET> <DIM> <FMU_VR>
<nb_clock_groups> <nb_total_clocked_inputs>
<CLOCK_VR> <n> <LOCAL_OFFSET> <DIM> <FMU_VR> [<LOCAL_OFFSET> <DIM> <FMU_VR> ...]
...
<nb_clock_groups>: Number of distinct clocks gating inputs of this type.<nb_total_clocked_inputs>: Total number of clocked input mappings.- Each line: a clock local VR, the count
nof gated inputs, thenntriplets of<LOCAL_OFFSET> <DIM> <FMU_VR>.
7.2 Start Values¶
For each type (except binary and clock):
# Start values of <fmu_name> - <type>: <FMU_VR> <DIM> <RESET> <VALUE>
<nb_start_lines> <nb_start_values>
<FMU_VR> <DIM> <RESET> <VALUE> [<VALUE> ...]
...
<nb_start_lines>: Number of start value entries.<nb_start_values>: Total number of scalar values (sum of all dimensions).- Each entry:
<FMU_VR>: The FMU's value reference for this port.<DIM>: Dimension of the variable.<RESET>: when the value is set:0: before the Initialization Mode (beforefmi2SetupExperimentfor an FMI-2 FMU);1: also set again after entering the Initialization Mode (inputcausality);2(version ≥ 9): in Configuration Mode (structuralParametercausality), see Configuration Mode.
<VALUE>: One or more space-separated values (count = DIM).
Special case for string type: Each value is on a separate line (not space-separated).
7.3 Outputs¶
For each type:
# Outputs of <fmu_name> - <type>: <LOCAL_OFFSET> <DIM> <FMU_VR>
<nb_outputs>
<LOCAL_OFFSET> <DIM> <FMU_VR>
...
Same structure as inputs: maps FMU output ports to container local variables.
Clocked Outputs (Version ≥ 3, not for type clock)¶
# Clocked Outputs of <fmu_name> - <type>: <FMU_VR_CLOCK> <n> <LOCAL_OFFSET> <DIM> <FMU_VR>
<nb_clock_groups> <nb_total_clocked_outputs>
<CLOCK_VR> <n> <LOCAL_OFFSET> <DIM> <FMU_VR> [<LOCAL_OFFSET> <DIM> <FMU_VR> ...]
...
Same structure as clocked inputs.
7.4 Conversion Table¶
# Conversion table of <fmu_name>: <VR_FROM> <VR_TO> <CONVERSION>
<nb_conversions>
<VR_FROM> <VR_TO> <CONVERSION_NAME>
...
<nb_conversions>: Number of type conversion entries. They are listed under the FMU that produces the value (the source of the link).- Each entry:
<VR_FROM>: Local VR of the link value (output of this FMU).<VR_TO>: Local VR of the converted copy, read by the inputs of the other type.<CONVERSION_NAME>: Identifier of the conversion function.- A link has one converted copy per target type, whatever the number of inputs of that type it feeds (before 2.0, the copy and its conversion were repeated for each input, which produced an invalid file).
The conversion functions are listed in CONVERSION_FUNCTION (fmu_manipulation_toolbox/container/types.py), keyed by "<from type>/<to type>": 132 functions between all the numeric types and the booleans. Their name is <FROM>_<TO> with F32/F64 for reals, D8...D64 for signed and U8...U64 for unsigned integers, B/B1 for boolean/boolean1 (e.g. D8_D16, B_F64). Lossy conversions (narrowing, sign change, to boolean, e.g. _F64_F32, _D32_U32, _F64_B) start with _; the tool warns when it creates one.
7.5 Reset Trigger (Version ≥ 7)¶
<LOCAL_OFFSET>: offset of thecontainer.<fmu>.resetvariable in the local storage ofboolean(FMI-2 container) orboolean1(FMI-3 container);-1when the FMU is never reset.- The runtime reads all the triggers at the start of each internal step: when one is
true, it writes a datalog row, resets the FMU (fmi2Reset/fmi3Reset) and initializes it again at the current time (start values, values set by the importer, current inputs, event iteration). At the end of the step, it writesfalseinto the triggers of the FMUs it reset, whoever set them: an FMU that keeps its outputtrueresets the target every other step. - Several FMUs may share one trigger (one link or one container input). An exposed trigger is a local variable without value reference: its container input line is
<VR> 1 <NB> -1 <LOCAL_OFFSET> [<FMU_INDEX> <FMU_VR> ...], the other pairs being the regular inputs the same container input feeds. - The reset of an FMU with clocks scheduled by the container (section 8) is not supported: the runtime returns an error.
Version differences for Per-FMU I/O¶
- Version 0/1: Only FMI-2 types (real64, integer32, boolean, string). No clocked sections. No DIM field. Lines are
<VR> <FMU_VR>. - Version 2: All types except binary/clock. No clocked sections. Conversion table added. Lines are
<VR> <FMU_VR>. - Version 3: All 15 types. Clocked sections added. Conversion table present. Lines are
<VR> <FMU_VR>. - Version 4: All 15 types. Clocked sections added. Lines are
<VR> <DIM> <FMU_VR>. - Version ≥ 5: Lines are
<LOCAL_OFFSET> <DIM> <FMU_VR>. - Version ≥ 7: Reset trigger after the conversion table.
- Version ≥ 9:
<RESET>=2for the start values of the structural parameters.
8. Importer Clocks¶
# importer CLOCKS: <FMU_INDEX> <NB> <FMU_VR> <VR> <VARIABILITY> <INTERVAL> <SHIFT> [...]
<nb_fmu_with_clocks> <nb_total_clocks>
<FMU_INDEX> <NB> <FMU_VR> <LOCAL_VR> <VARIABILITY> <INTERVAL> <SHIFT> [<FMU_VR> <LOCAL_VR> <VARIABILITY> <INTERVAL> <SHIFT> ...]
...
<nb_fmu_with_clocks>: Number of FMUs that have importer-scheduled clocks.<nb_total_clocks>: Total number of clock entries across all FMUs.- Each line:
<FMU_INDEX>: Index of the FMU.<NB>: Number of clocks for this FMU.- For each clock:
<FMU_VR>,<LOCAL_VR>: The FMU's clock value reference and the corresponding container-local clock VR.<VARIABILITY>:intervalVariabilityof the clock:constant,fixed,tunable,changingorcountdown.<INTERVAL>,<SHIFT>:intervalDecimalandshiftDecimalof themodelDescription.xml,-1if not declared.
This section lists the time-based input clocks linked to another clock: the container runtime acts as an FMI importer and schedules them. It reads from the FMU the interval and the shift that are not declared, and stores the time of the next tick of each clock.
Version differences¶
- Version < 3: This section does not exist.
- Version ≥ 3: Always present (even if
0 0). - Version < 8: Only
countdownclocks, without<VARIABILITY> <INTERVAL> <SHIFT>.
Value Reference Encoding¶
Value references in container.txt use a type-encoded scheme:
Where type_index is the position (0-based) in the type list:
| Index | Type |
|---|---|
| 0 | real64 |
| 1 | real32 |
| 2 | integer8 |
| 3 | uinteger8 |
| 4 | integer16 |
| 5 | uinteger16 |
| 6 | integer32 |
| 7 | uinteger32 |
| 8 | integer64 |
| 9 | uinteger64 |
| 10 | boolean |
| 11 | boolean1 |
| 12 | string |
| 13 | binary |
| 14 | clock |
The C runtime masks VRs with & 0xFFFFFF to extract the local index when indexing into type-specific arrays.
Complete Example (Version 6)¶
Bouncing ball: bb_velocity.fmu feeds the velocity input of bb_position.fmu, whose is_ground output (boolean) feeds the reset input of bb_velocity.fmu; position1 and velocity are exposed as container outputs. Sections without content are elided (...).
# Version 6
# Container flags <MT> <Profiling> <Sequential>
1 0 0
# Internal time step in seconds
0.001
# NB of embedded FMU's
2 0
bb_position.fmu 2 0
bb_position
{8fbd9f16-ceaa-97ed-127f-987a60b25648}
bb_velocity.fmu 2 0
bb_velocity
{abf5f61d-b459-3641-3a2c-1e594b990280}
# NB local variables: real64, real32, integer8, uinteger8, integer16, uinteger16, integer32, uinteger32, integer64, uinteger64, boolean, boolean1, string, binary, clock
2 0 0 0 0 0 2 0 0 0 1 0 0 0 0
# CONTAINER I/O: <VR> <DIM> <NB> <FMU_INDEX> <FMU_VR> [<FMU_INDEX> <FMU_VR>]
# real64
4 4
0 1 1 -1 0
2 1 1 0 1
3 1 1 1 0
1 1 1 -1 1
# real32
0 0
...
# integer32
2 2
100663296 1 1 -1 0
100663297 1 1 -1 1
...
# boolean
1 1
167772160 1 1 -1 0
...
# Inputs of bb_position.fmu - real64: <LOCAL_OFFSET> <DIM> <FMU_VR>
1
1 1 0
# Clocked Inputs of bb_position.fmu - real64: <FMU_VR_CLOCK> <n> <LOCAL_OFFSET> <DIM> <FMU_VR>
0 0
...
# Start values of bb_position.fmu - real64: <FMU_VR> <DIM> <RESET> <VALUE>
0 0
...
# Outputs of bb_position.fmu - boolean: <LOCAL_OFFSET> <DIM> <FMU_VR>
1
0 1 0
...
# Conversion table of bb_position.fmu: <VR_FROM> <VR_TO> <CONVERSION>
0
# Inputs of bb_velocity.fmu - real64: <LOCAL_OFFSET> <DIM> <FMU_VR>
0
...
# Conversion table of bb_velocity.fmu: <VR_FROM> <VR_TO> <CONVERSION>
0
# importer CLOCKS: <FMU_INDEX> <NB> <FMU_VR> <VR> [<FMU_VR> <VR>]
0 0
In real64: 0 is the time, 2 and 3 the container outputs (position1 of FMU 0, velocity of FMU 1), 1 the local variable of the velocity link, stored at offset 1 (offset 0 is the time).
Version History Summary¶
| Format Version | Tool Version | Notable Changes |
|---|---|---|
| 0 | ≤ 1.8.4 | Initial format. FMI-2 types only. Simple 1:1 port mapping. |
| 1 | ~1.8.x | Multi-target fan-out for inputs. Separate MT/profiling lines. |
| 2 | 1.9 | FMI-3 numeric types added. Flags merged. Conversion tables. Sequential mode. |
| 3 | 1.9.2 | Binary and clock types. Clocked I/O sections. Importer clocks (LS-BUS). Event mode. |
| 4 | 1.9.3 | Array variable support via DIM field in all I/O lines. |
| 5 | 1.9.4 | Local variables addressed by their storage offset (<LOCAL_OFFSET>). |
| 6 | 2.0b1 | Model-Exchange support: FMU count split into <nb_fmu_cs> <nb_fmu_me>, ME entries carry <nx> <nz>; ME solver slot. |
| 7 | 2.0b2 | Reset trigger of each embedded FMU after its conversion table. Initialization order of the embedded FMUs. |
| 8 | 2.1 | Importer clocks: all the time-based clocks. |
| 9 | 2.1 | <has_configuration_mode> of each embedded FMU; start values of Configuration Mode (<RESET>=2). |