Skip to content

bug: m_cbc.fpp AMD local arrays hardcoded to dimension(3), overflow when num_fluids > 3 #1368

@sbryngelson

Description

@sbryngelson

Summary

In src/simulation/m_pressure_relaxation.fpp, the non-case-optimization AMD branch (#:if not MFC_CASE_OPTIMIZATION and USING_AMD) declares local arrays with a hardcoded upper bound of 2:

#:if not MFC_CASE_OPTIMIZATION and USING_AMD
    real(wp), dimension(2) :: alpha_rho, alpha
#:else
    real(wp), dimension(num_fluids) :: alpha_rho, alpha
#:endif

These arrays are then written inside a loop up to num_fluids:

do i = 1, num_fluids
    alpha_rho(i) = q_cons_vf(i)%sf(j, k, l)
    alpha(i) = q_cons_vf(eqn_idx%E + i)%sf(j, k, l)
end do

Impact

When num_fluids > 2 in an AMD GPU build without case optimization, both arrays overflow. The existing PROHIBIT checks do not specifically guard num_fluids <= 2 on AMD paths.

(Note: m_cbc.fpp has a similar AMD-specific hardcoded-dimension pattern but uses dimension(3) there.)

Fix

Replace the hardcoded dimension(2) with dimension(max(2, num_fluids)) or add a @:PROHIBIT(num_fluids > 2 ...) guard, or use the same dimension(num_fluids) path as non-AMD.

Discovered

Found during review of PR #1365. Pre-existing in master.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working or doesn't seem right

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions