Skip to content

Commit a7a5821

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 5ec1262 commit a7a5821

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
@@ -2332,23 +2332,22 @@ contains
23322332
subroutine s_finalize_boundary_common_module()
23332333

23342334
if (bc_io) then
2335-
deallocate (bc_buffers(1, 1)%sf)
2336-
deallocate (bc_buffers(1, 2)%sf)
2335+
@:DEALLOCATE(bc_buffers(1, 1)%sf)
2336+
@:DEALLOCATE(bc_buffers(1, 2)%sf)
23372337
#:if not MFC_CASE_OPTIMIZATION or num_dims > 1
23382338
if (n > 0) then
2339-
deallocate (bc_buffers(2, 1)%sf)
2340-
deallocate (bc_buffers(2, 2)%sf)
2339+
@:DEALLOCATE(bc_buffers(2, 1)%sf)
2340+
@:DEALLOCATE(bc_buffers(2, 2)%sf)
23412341
#:if not MFC_CASE_OPTIMIZATION or num_dims > 2
23422342
if (p > 0) then
2343-
deallocate (bc_buffers(3, 1)%sf)
2344-
deallocate (bc_buffers(3, 2)%sf)
2343+
@:DEALLOCATE(bc_buffers(3, 1)%sf)
2344+
@:DEALLOCATE(bc_buffers(3, 2)%sf)
23452345
end if
23462346
#:endif
23472347
end if
23482348
#:endif
23492349
end if
2350-
2351-
deallocate (bc_buffers)
2350+
@:DEALLOCATE(bc_buffers)
23522351

23532352
end subroutine s_finalize_boundary_common_module
23542353

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
@@ -1086,6 +1086,9 @@ contains
10861086
end if
10871087
end do
10881088

1089+
! NOTE: gpu_ntrs, gpu_trs_v, gpu_trs_n, gpu_boundary_edge_count, gpu_total_vertices, gpu_boundary_v are program-lifetime
1090+
! allocations;
1091+
! no s_finalize_* subroutine exists for this module.
10891092
if (max_ntrs > 0) then
10901093
@:ALLOCATE(gpu_ntrs(1:num_ibs))
10911094
@:ALLOCATE(gpu_trs_v(1:3, 1:3, 1:max_ntrs, 1:num_ibs))

src/common/m_mpi_common.fpp

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

15101510
#ifdef MFC_MPI
1511+
#ifndef __NVCOMPILER_GPU_UNIFIED_MEM
1512+
@:DEALLOCATE(buff_send, buff_recv)
1513+
#else
1514+
$:GPU_EXIT_DATA(delete='[buff_send, buff_recv]')
15111515
deallocate (buff_send, buff_recv)
1516+
#endif
15121517
#endif
15131518

15141519
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
@@ -1235,6 +1235,9 @@ contains
12351235
if (bubbles_euler) then
12361236
@:DEALLOCATE(bubrs_vc)
12371237
end if
1238+
if (viscous) then
1239+
@:DEALLOCATE(Res_vc)
1240+
end if
12381241
#else
12391242
@:DEALLOCATE(gammas, gs_min, pi_infs, ps_inf, cvs, qvs, qvps, Gs_vc)
12401243
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
@@ -873,6 +873,10 @@ contains
873873
874874
Nf = max(Nx, Ny, Nz)
875875
876+
! NOTE: data_in, data_out, data_cmplx, data_cmplx_y, data_cmplx_z,
877+
! En_real, En are program-lifetime allocations; no s_finalize_start_up_module exists.
878+
879+
@:ALLOCATE(data_in(Nx*Nyloc*Nzloc))
876880
@:ALLOCATE(data_in(Nx*Nyloc*Nzloc))
877881
@:ALLOCATE(data_out(Nx*Nyloc*Nzloc))
878882

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
@@ -55,6 +55,7 @@ contains
5555
$:GPU_UPDATE(device='[nterms]')
5656
#:endif
5757

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

@@ -382,6 +383,7 @@ contains
382383

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

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

387389
do j = 1, nmom

src/simulation/m_rhs.fpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,8 +1838,14 @@ contains
18381838
end do
18391839
18401840
@:DEALLOCATE(flux_n, flux_src_n, flux_gsrc_n)
1841-
@:DEALLOCATE(qL_prim)
1842-
@:DEALLOCATE(qR_prim)
1841+
do i = 1, num_dims
1842+
do l = eqn_idx%mom%beg, eqn_idx%mom%end
1843+
@:DEALLOCATE(qL_prim(i)%vf(l)%sf)
1844+
@:DEALLOCATE(qR_prim(i)%vf(l)%sf)
1845+
end do
1846+
@:DEALLOCATE(qL_prim(i)%vf, qR_prim(i)%vf)
1847+
end do
1848+
@:DEALLOCATE(qL_prim, qR_prim)
18431849
end if
18441850
18451851
if (alt_soundspeed) then

0 commit comments

Comments
 (0)