Summary
In src/simulation/m_rhs.fpp, tau_Re_vf is allocated inside if (viscous) but deallocated only when cyl_coord is also true:
! Allocation (inside if (viscous)):
@:ALLOCATE(tau_Re_vf(1:sys_size))
do i = 1, Re_size(1)
@:ALLOCATE(tau_Re_vf(eqn_idx%cont%end + i)%sf(...))
end do
@:ALLOCATE(tau_Re_vf(eqn_idx%E)%sf(...))
! Deallocation (inside if (cyl_coord)):
if (cyl_coord) then
do i = 1, num_dims
@:DEALLOCATE(tau_re_vf(eqn_idx%cont%end + i)%sf)
end do
@:DEALLOCATE(tau_re_vf(eqn_idx%E)%sf)
@:DEALLOCATE(tau_re_vf)
end if
Any run with viscous = .true. and cyl_coord = .false. (i.e., every Cartesian viscous simulation) leaks all tau_Re_vf GPU and host allocations. Violates the @:ALLOCATE/@:DEALLOCATE pairing rule.
Fix
The deallocation guard should be if (viscous), not if (cyl_coord). The number of sf sub-arrays to free mirrors the allocation loop (one per viscous fluid, plus the energy slot).
Discovered
Found during review of PR #1365. Pre-existing in master.
Summary
In
src/simulation/m_rhs.fpp,tau_Re_vfis allocated insideif (viscous)but deallocated only whencyl_coordis also true:Any run with
viscous = .true.andcyl_coord = .false.(i.e., every Cartesian viscous simulation) leaks alltau_Re_vfGPU and host allocations. Violates the@:ALLOCATE/@:DEALLOCATEpairing rule.Fix
The deallocation guard should be
if (viscous), notif (cyl_coord). The number ofsfsub-arrays to free mirrors the allocation loop (one per viscous fluid, plus the energy slot).Discovered
Found during review of PR #1365. Pre-existing in
master.