Skip to content

Registry-driven default values for case parameters #1574

Description

@sbryngelson

Motivation

s_assign_default_values_to_user_inputs is still a hand-maintained ~200-line assignment list per executable (a shared core was factored in #1552, but the values themselves remain Fortran literals divorced from the registry). This is another manual mirror: a parameter's existence, its Fortran declaration, its namelist binding, and its broadcast are now all generated from toolchain/mfc/params/definitions.py — but its default lives elsewhere, in three places, with nothing keeping new parameters from silently defaulting to whatever the compiler leaves in memory if the author forgets the assignment line.

This was considered during the parameter-pipeline work and deliberately deferred ("registry-driven default VALUES would need per-param default metadata — a separate proposal"). The pipeline is mature now; this is its natural completion.

Proposal

  1. Add a default= field to the registry's parameter definitions (_r(...)), with the existing sentinel conventions (dflt_real, dflt_int, .false., literals) expressible symbolically.
  2. Generate a per-target generated_defaults.fpp include containing the assignments, emitted by the existing generator into the existing include machinery (15 generated files become 18).
  3. The hand-written routines shrink to the genuinely computed/per-target residue (the same residue classification approach that worked for the MPI broadcast lists in Share the global-parameters core across executables; generate MPI broadcasts; build hygiene #1552).

Execution sketch

  • Step 1 (mechanical, large-ish): transcribe current defaults from the three s_assign_default_values_to_user_inputs into the registry — scriptable by parsing the existing assignments; the script's output should be reviewed against all three targets since defaults occasionally differ per target (e.g. precision differs between pre and post — per-target overrides need a representation, e.g. default={"pre": 2, "post": "dflt_int"}).
  • Step 2: generate_defaults_fpp(target) + tests, mirroring generate_bcast_fpp exactly (that generator's structure, residue handling, and equivalence-verification method transfer one-to-one).
  • Step 3: equivalence gate — the emitted assignment set per target must equal the deleted hand-written set, statement-for-statement (the established seed-pinned multiset comparison), followed by the full golden suite.
  • Effort: moderate. Risk: low-moderate (the per-target-divergent defaults are the trap; the equivalence check catches them).

Evidence base: #1564 (an allocation-guard/default interaction) and the rank-0-vs-defaults semantics that made #1559 subtle both trace to defaults being hand-scattered.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions