Skip to content

src_compressible_stag: define vel_decomp before the step-0 plotfile call uses it - #282

Merged
isriva merged 1 commit into
AMReX-FHD:mainfrom
isriva:fix-compstag-vel-decomp-use-before-define
Sep 22, 2026
Merged

isriva merged 1 commit into
AMReX-FHD:mainfrom
isriva:fix-compstag-vel-decomp-use-before-define

Conversation

@isriva

@isriva isriva commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

On a fresh start with plot_int > 0 and turbForcing > 0, main_driver passed
vel_decomp to EvaluateWritePlotFileVelGrad / ...Tiny from inside the
non-restart branch, ~40 lines before vel_decomp.define() is reached below the
branch. vel_decomp is declared with no arguments, so it was an unbuilt
MultiFab at that point.

EvaluateWritePlotFileVelGrad dereferences it immediately
(vel_decomp.ParallelCopy(vel_decomp_in,0,0,6)); ParallelCopy from a MultiFab
with an empty BoxArray/DistributionMap is undefined behaviour -- an assertion
failure in a debug build, a garbage dereference in release. This broke every
fresh-start forced-turbulence run with plotfiles enabled, before the time loop
even started. Restart runs were unaffected because they do not call these.

Move the step-0 call below the define block and gate it on the fresh-start
condition it previously inherited from its enclosing branch.

…all uses it

On a fresh start with plot_int > 0 and turbForcing > 0, main_driver passed
vel_decomp to EvaluateWritePlotFileVelGrad / ...Tiny from inside the
non-restart branch, ~40 lines before vel_decomp.define() is reached below the
branch.  vel_decomp is declared with no arguments, so it was an unbuilt
MultiFab at that point.

EvaluateWritePlotFileVelGrad dereferences it immediately
(vel_decomp.ParallelCopy(vel_decomp_in,0,0,6)); ParallelCopy from a MultiFab
with an empty BoxArray/DistributionMap is undefined behaviour -- an assertion
failure in a debug build, a garbage dereference in release.  This broke every
fresh-start forced-turbulence run with plotfiles enabled, before the time loop
even started.  Restart runs were unaffected because they do not call these.

Move the step-0 call below the define block and gate it on the fresh-start
condition it previously inherited from its enclosing branch.
@isriva
isriva merged commit 2e9b02c into AMReX-FHD:main Sep 22, 2026
18 checks passed
@isriva
isriva deleted the fix-compstag-vel-decomp-use-before-define branch September 22, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant