Skip to content

engine: INITIAL in a macro output reads inf during initialization #584

Closed

Description

@bpowers

When a module (or a macro, which compiles to one) has an output defined as INITIAL(x), and the parent model reads that output while initializing, the module did not compute the output during initialization.
The parent read an unwritten slot (inf) and kept it for the whole run.

Example

C-LEARN defines

:MACRO: INIT(x)
INIT = INITIAL(x)
:END OF MACRO:

and calls it about 177 times, for example volumetric heat capacity = INITIAL(mass heat cap*...).
Simlin gave volumetric heat capacity = inf (Vensim: 0.1327), and the climate sector went inf/NaN from there.

Status

Fixed on main.
A pass-through macro like the one above now compiles straight to the INITIAL opcode at the call site (#600), and a model used as a module now evaluates every value-bearing variable during initialization, because a parent can read any of its outputs then (#1028, closed).
C-LEARN's volumetric heat capacity matches Vensim.

Pointers

Activity

  1. added
    bug
    engine
    on May 19, 2026
  2. changed the title [-]engine: INITIAL()-backed module/macro primary output omitted from the initials runlist (spurious inf)[/-] [+]engine: INITIAL in a macro output reads inf during initialization[/+] on Oct 12, 2026
  3. bpowers commented on Oct 12, 2026

    @bpowers
    OwnerAuthor

    Closing: already fixed on main.

    The initials runlist seeds INITIAL-backed variables and every value-bearing variable of a model instantiated as a module or macro (src/simlin-engine/src/db/dep_graph.rs:2603-2660, GH #584/#1028). Pinned by issue_584_initial_backed_macro_output_is_written_during_initials (src/macro_expansion_tests.rs:1093) and by simulates_clearn, whose residual exclusion list does not include volumetric heat capacity.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugengine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions