Skip to content

Commit 5255b3c

Browse files
committed
fix: address remaining files in deallocate audit
- m_rhs: fix incomplete qL_prim/qR_prim teardown by walking nested %vf/%sf structure before deallocating containers - m_boundary_common: replace plain deallocate with @:DEALLOCATE - m_mpi_common: replace plain deallocate with @:DEALLOCATE, mirror unified memory path in finalization - m_variables_conversion: add missing @:DEALLOCATE for Res_vc - m_start_up (post_process): annotate FFT arrays as program-lifetime - m_helper, m_model, m_acoustic_src, m_bubbles_EE, m_qbmm: annotate allocations as program-lifetime (no finalize subroutine) Part of #1459
1 parent fd4c314 commit 5255b3c

10 files changed

Lines changed: 41 additions & 10 deletions

File tree

src/common/m_boundary_common.fpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,23 +171,22 @@ contains
171171
subroutine s_finalize_boundary_common_module()
172172

173173
if (bc_io) then
174-
deallocate (bc_buffers(1, 1)%sf)
175-
deallocate (bc_buffers(1, 2)%sf)
174+
@:DEALLOCATE(bc_buffers(1, 1)%sf)
175+
@:DEALLOCATE(bc_buffers(1, 2)%sf)
176176
#:if not MFC_CASE_OPTIMIZATION or num_dims > 1
177177
if (n > 0) then
178-
deallocate (bc_buffers(2, 1)%sf)
179-
deallocate (bc_buffers(2, 2)%sf)
178+
@:DEALLOCATE(bc_buffers(2, 1)%sf)
179+
@:DEALLOCATE(bc_buffers(2, 2)%sf)
180180
#:if not MFC_CASE_OPTIMIZATION or num_dims > 2
181181
if (p > 0) then
182-
deallocate (bc_buffers(3, 1)%sf)
183-
deallocate (bc_buffers(3, 2)%sf)
182+
@:DEALLOCATE(bc_buffers(3, 1)%sf)
183+
@:DEALLOCATE(bc_buffers(3, 2)%sf)
184184
end if
185185
#:endif
186186
end if
187187
#:endif
188188
end if
189-
190-
deallocate (bc_buffers)
189+
@:DEALLOCATE(bc_buffers)
191190

192191
end subroutine s_finalize_boundary_common_module
193192

src/common/m_helper.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ contains
8686
impure subroutine s_initialize_bubbles_model()
8787

8888
! Allocate memory
89+
! NOTE: weight, pb0, Re_trans_T are program-lifetime allocations;
90+
! no s_finalize_bubbles_model or s_finalize_* subroutine exists for this module.
8991
if (bubbles_euler) then
9092
@:ALLOCATE(weight(nb), R0(nb))
9193
if (.not. polytropic) then

src/common/m_model.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,9 @@ contains
970970
end if
971971
end do
972972

973+
! NOTE: gpu_ntrs, gpu_trs_v, gpu_trs_n, gpu_boundary_edge_count, gpu_total_vertices, gpu_boundary_v are program-lifetime
974+
! allocations;
975+
! no s_finalize_* subroutine exists for this module.
973976
if (max_ntrs > 0) then
974977
@:ALLOCATE(gpu_ntrs(1:num_stl_models))
975978
@:ALLOCATE(gpu_trs_v(1:3, 1:3, 1:max_ntrs, 1:num_stl_models))

src/common/m_mpi_common.fpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,12 @@ contains
15091509
impure subroutine s_finalize_mpi_common_module
15101510

15111511
#ifdef MFC_MPI
1512+
#ifndef __NVCOMPILER_GPU_UNIFIED_MEM
1513+
@:DEALLOCATE(buff_send, buff_recv)
1514+
#else
1515+
$:GPU_EXIT_DATA(delete='[buff_send, buff_recv]')
15121516
deallocate (buff_send, buff_recv)
1517+
#endif
15131518
#endif
15141519

15151520
end subroutine s_finalize_mpi_common_module

src/common/m_variables_conversion.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,9 @@ contains
12371237
if (bubbles_euler) then
12381238
@:DEALLOCATE(bubrs_vc)
12391239
end if
1240+
if (viscous) then
1241+
@:DEALLOCATE(Res_vc)
1242+
end if
12401243
#else
12411244
@:DEALLOCATE(gammas, gs_min, pi_infs, ps_inf, cvs, qvs, qvps, Gs_vc)
12421245
if (bubbles_euler) then

src/post_process/m_start_up.fpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,10 @@ contains
875875
876876
Nf = max(Nx, Ny, Nz)
877877
878+
! NOTE: data_in, data_out, data_cmplx, data_cmplx_y, data_cmplx_z,
879+
! En_real, En are program-lifetime allocations; no s_finalize_start_up_module exists.
880+
881+
@:ALLOCATE(data_in(Nx*Nyloc*Nzloc))
878882
@:ALLOCATE(data_in(Nx*Nyloc*Nzloc))
879883
@:ALLOCATE(data_out(Nx*Nyloc*Nzloc))
880884

src/simulation/m_acoustic_src.fpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ contains
6464

6565
integer :: i, j !< generic loop variables
6666

67+
! NOTE: loc_acoustic, mass_src, mom_src, E_src, source_spatials, source_spatials_num_points are program-lifetime
68+
! allocations;
69+
! no s_finalize_acoustic_src subroutine exists for this module.
70+
6771
@:ALLOCATE(loc_acoustic(1:3, 1:num_source), mag(1:num_source), dipole(1:num_source), support(1:num_source), &
6872
& length(1:num_source), height(1:num_source), wavelength(1:num_source), frequency(1:num_source), &
6973
& gauss_sigma_dist(1:num_source), gauss_sigma_time(1:num_source), foc_length(1:num_source), &

src/simulation/m_bubbles_EE.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ contains
3232

3333
integer :: l
3434

35+
! NOTE: rs, vs, ps, ms, divu%sf, bub_adv_src, bub_r_src, bub_v_src, bub_p_src, bub_m_src are program-lifetime allocations;
36+
! no s_finalize_bubbles_EE_module subroutine exists.
37+
3538
@:ALLOCATE(rs(1:nb))
3639
@:ALLOCATE(vs(1:nb))
3740
@:ALLOCATE(ps(1:nb))

src/simulation/m_qbmm.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ contains
5656
$:GPU_UPDATE(device='[nterms]')
5757
#:endif
5858

59+
! NOTE: momrhs is a program-lifetime allocation; no s_finalize_* subroutine exists for this module.
5960
@:ALLOCATE(momrhs(1:3, 0:2, 0:2, 1:nterms, 1:nb))
6061
momrhs = 0._wp
6162

@@ -383,6 +384,7 @@ contains
383384

384385
$:GPU_UPDATE(device='[momrhs]')
385386

387+
! NOTE: bubmoms is a program-lifetime allocation; no s_finalize_* subroutine exists for this module.
386388
@:ALLOCATE(bubmoms(1:nb, 1:nmom))
387389

388390
do j = 1, nmom

src/simulation/m_rhs.fpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,8 +1840,14 @@ contains
18401840
end do
18411841
18421842
@:DEALLOCATE(flux_n, flux_src_n, flux_gsrc_n)
1843-
@:DEALLOCATE(qL_prim)
1844-
@:DEALLOCATE(qR_prim)
1843+
do i = 1, num_dims
1844+
do l = eqn_idx%mom%beg, eqn_idx%mom%end
1845+
@:DEALLOCATE(qL_prim(i)%vf(l)%sf)
1846+
@:DEALLOCATE(qR_prim(i)%vf(l)%sf)
1847+
end do
1848+
@:DEALLOCATE(qL_prim(i)%vf, qR_prim(i)%vf)
1849+
end do
1850+
@:DEALLOCATE(qL_prim, qR_prim)
18451851
end if
18461852
18471853
if (alt_soundspeed) then

0 commit comments

Comments
 (0)