Mirrors solver_runtime (1D) for the coexisting euler_2d solver: a run
context bundling state + time/iteration bookkeeping, a bounded advance-N
step loop extracted 1:1 from run_euler_2d's original time loop, a global
L2 residual reduction (resid_glob, the 2D analogue of the 1D
state % resid_glob), and a result-write wrapper. euler_driver_2d and
(phase P2) the dim-aware solver_session both drive this runtime, so the
CLI and the attached IPC worker observe the SAME numerical run.
Bit-for-bit contract: init_run_context_2d + run_solver_steps_2d +
write_solution_file_2d reproduce the pre-P1 run_euler_2d behaviour —
same setup order, same log lines, same checkpoint/print cadence. Time
accumulation is Kahan-compensated since Q2b (authorized behavior change,
spec 2026-07-10-q2-2d-machinery-alignment-design.md §6), matching the
1D runtime. The only other additions are the per-step residual
reduction (pure observation, no state change) and the polling boundary.
There are deliberately NO snapshot files here (spec 2026-07-03 §2.3).
Aggregate context for one 2D solver run (2D analogue of
solver_run_context_t). Populated by init_run_context_2d; callers set
nml_file BEFORE init (it feeds the config: loaded log line).
t, t_comp, iter, and run_complete are inherited from
run_loop_ctx_t (Q2c) under their historical names.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | public | :: | t | = | 0.0_wp | ||
| real(kind=wp), | public | :: | t_comp | = | 0.0_wp | ||
| integer, | public | :: | iter | = | 0 | ||
| logical, | public | :: | run_complete | = | .false. | ||
| type(solver_state_2d_t), | public | :: | state | ||||
| real(kind=wp), | public | :: | resid_glob | = | 0.0_wp |
Global L2 residual norm of the last-substage residual, reduced across
ranks each step (2D analogue of the 1D |
|
| character(len=512), | public | :: | nml_file | = | 'input.nml' | ||
| procedure(stepper_2d_iface), | public, | pointer, nopass | :: | stepper | => | null() |
| procedure, public :: begin_work => hook_noop | |
| procedure, public :: write_snapshot_now => hook_noop | |
| procedure, public :: finish_work => hook_noop | |
| procedure, public :: progress_residual => hook_zero | (it is referenced inside the on_progress argument list). |
| procedure, public :: raw_dt => ctx2d_raw_dt | |
| procedure, public :: set_dt => ctx2d_set_dt | |
| procedure, public :: step => ctx2d_step | |
| procedure, public :: write_checkpoint_now => ctx2d_checkpoint | |
| procedure, public :: log_iteration_line => ctx2d_log_line | |
| procedure, public :: observe => ctx2d_observe |
2D raw_dt hook: recompute and store state % dt from the adaptive
CFL condition, then return it (Q2c; body lifted verbatim from the
pre-engine run_solver_steps_2d loop).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(solver_run_context_2d_t), | intent(inout) | :: | ctx |
Whole-domain point count (FVM cells / FDM nodes), identical on all ranks.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(solver_run_context_2d_t), | intent(in) | :: | ctx |
Bring a 2D run context to ready-to-step state.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(solver_run_context_2d_t), | intent(inout) | :: | ctx |
Context to initialise ( |
||
| type(config_2d_t), | intent(in) | :: | cfg |
Validated 2D configuration. |
||
| integer, | intent(out) | :: | status |
0 on success, 1 on failure (logger already finalised). |
||
| character(len=*), | intent(out) | :: | message |
Human-readable error when status /= 0. |
Advance the 2D time loop by at most max_steps iterations.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(solver_run_context_2d_t), | intent(inout) | :: | ctx | |||
| integer, | intent(in) | :: | max_steps | |||
| integer, | intent(out) | :: | steps_taken | |||
| logical, | intent(out) | :: | finished | |||
| integer, | intent(out) | :: | status | |||
| character(len=*), | intent(out) | :: | message |
2D set_dt hook: store the engine's time_stop-clipped dt.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(solver_run_context_2d_t), | intent(inout) | :: | ctx | |||
| real(kind=wp), | intent(in) | :: | dt |
2D step hook: advance one step via the bound integrator.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(solver_run_context_2d_t), | intent(inout) | :: | ctx |
2D write_checkpoint_now hook: write the checkpoint and own the
failure policy.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(solver_run_context_2d_t), | intent(inout) | :: | ctx |
2D log_iteration_line hook: one iteration summary line.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(solver_run_context_2d_t), | intent(inout) | :: | ctx |
2D observe hook: reduce the global L2 residual norm (collective,
observation only — no state change).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(solver_run_context_2d_t), | intent(inout) | :: | ctx |
Reduce the global L2 norm of the last-substage residual into
ctx % resid_glob (2D analogue of the 1D compute_resid_glob):
resid_glob = sqrt( par_sum(sum resid^2) / (nx_g*ny_g * neq2d) )
The denominator uses GLOBAL counts so the norm is decomposition-
independent (np=1 == np=2 up to summation reordering, ~1e-13).
Collective: every rank must call.
Dummy widened type -> class (Q2c): called from the ctx2d_observe
hook, whose own dummy is class(solver_run_context_2d_t) per the
abstract run_loop_ctx_t interface, so the actual argument here is
polymorphic and the callee must accept it as such.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(solver_run_context_2d_t), | intent(inout) | :: | ctx |
Gather to root and write the standard 6-column x y rho u v p result
(plus any tec/plt/vtk formats the config requests). Collective.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(solver_run_context_2d_t), | intent(inout) | :: | ctx | |||
| character(len=*), | intent(in) | :: | filename | |||
| logical, | intent(out) | :: | is_ok | |||
| character(len=*), | intent(out) | :: | message |
Release runtime handles and finalise the logger. The state's allocatable
arrays are released by intrinsic assignment when the owner resets the
context (ctx = solver_run_context_2d_t()), mirroring the 1D session.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(solver_run_context_2d_t), | intent(inout) | :: | ctx |