Skip to content

Commit 839a4b6

Browse files
SVS87sbryngelson
andauthored
fix: add missing @:DEALLOCATE in simulation modules (#1476)
Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com> Co-authored-by: Spencer Bryngelson <shb@gatech.edu>
1 parent 492f4c5 commit 839a4b6

10 files changed

Lines changed: 83 additions & 28 deletions

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_mpi_common.fpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,12 @@ contains
15051505
impure subroutine s_finalize_mpi_common_module
15061506

15071507
#ifdef MFC_MPI
1508+
#ifndef __NVCOMPILER_GPU_UNIFIED_MEM
1509+
@:DEALLOCATE(buff_send, buff_recv)
1510+
#else
1511+
$:GPU_EXIT_DATA(delete='[buff_send, buff_recv]')
15081512
deallocate (buff_send, buff_recv)
1513+
#endif
15091514
#endif
15101515

15111516
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/simulation/m_derived_variables.fpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -508,22 +508,24 @@ contains
508508
end if
509509
end if
510510

511-
if (probe_wrt) then
512-
deallocate (accel_mag, x_accel)
511+
if (probe_wrt .or. ib) then
512+
@:DEALLOCATE(accel_mag)
513+
@:DEALLOCATE(x_accel)
513514
if (n > 0) then
514-
deallocate (y_accel)
515+
@:DEALLOCATE(y_accel)
515516
if (p > 0) then
516-
deallocate (z_accel)
517+
@:DEALLOCATE(z_accel)
517518
end if
518519
end if
520+
@:DEALLOCATE(fd_coeff_x)
521+
if (n > 0) then
522+
@:DEALLOCATE(fd_coeff_y)
523+
end if
524+
if (p > 0) then
525+
@:DEALLOCATE(fd_coeff_z)
526+
end if
519527
end if
520528

521-
! Deallocating the variables that might have been used to bookkeep the finite-difference coefficients in the x-, y- and
522-
! z-directions
523-
if (allocated(fd_coeff_x)) deallocate (fd_coeff_x)
524-
if (allocated(fd_coeff_y)) deallocate (fd_coeff_y)
525-
if (allocated(fd_coeff_z)) deallocate (fd_coeff_z)
526-
527529
end subroutine s_finalize_derived_variables_module
528530

529531
end module m_derived_variables

src/simulation/m_global_parameters.fpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ contains
934934
@:DEALLOCATE(fluid_inv_re)
935935

936936
if (bubbles_euler) then
937+
@:DEALLOCATE(ptil)
937938
@:DEALLOCATE(qbmm_idx%rs, qbmm_idx%vs, qbmm_idx%ps, qbmm_idx%ms)
938939
if (qbmm) then
939940
@:DEALLOCATE(qbmm_idx%moms)

src/simulation/m_hyperelastic.fpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ contains
256256
do i = 1, b_size
257257
@:DEALLOCATE(btensor%vf(i)%sf)
258258
end do
259+
@:DEALLOCATE(Gs_hyper)
259260
@:DEALLOCATE(fd_coeff_x_hyper)
260261
if (n > 0) then
261262
@:DEALLOCATE(fd_coeff_y_hyper)

src/simulation/m_ibm.fpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,17 +1519,13 @@ contains
15191519
@:DEALLOCATE(ib_airfoil_grids(i)%lower)
15201520
end if
15211521
end do
1522-
15231522
if (allocated(models)) then
1524-
if (size(models) > 0) then
1525-
@:DEALLOCATE(models)
1526-
else
1527-
deallocate (models)
1528-
end if
1523+
@:DEALLOCATE(models)
1524+
end if
1525+
if (allocated(ghost_points)) then
1526+
@:DEALLOCATE(ghost_points)
15291527
end if
1530-
15311528
if (collision_model > 0) call s_finalize_collisions_module()
1532-
15331529
#ifdef MFC_MPI
15341530
if (num_procs > 1) then
15351531
@:DEALLOCATE(send_ids, send_ft)

src/simulation/m_rhs.fpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,8 +1794,7 @@ contains
17941794
end if
17951795
17961796
if (mpp_lim .and. bubbles_euler) then
1797-
$:GPU_EXIT_DATA(delete='[alf_sum%sf]')
1798-
deallocate (alf_sum%sf)
1797+
@:DEALLOCATE(alf_sum%sf)
17991798
end if
18001799
18011800
if (.not. igr) then
@@ -1839,6 +1838,32 @@ contains
18391838
end do
18401839
18411840
@:DEALLOCATE(flux_n, flux_src_n, flux_gsrc_n)
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)
1849+
end if
1850+
1851+
if (alt_soundspeed) then
1852+
@:DEALLOCATE(blkmod1)
1853+
end if
1854+
1855+
if (qbmm) then
1856+
do i = 0, 2
1857+
do j = 0, 2
1858+
do l = 1, nb
1859+
@:DEALLOCATE(mom_3d(i, j, l)%sf)
1860+
end do
1861+
end do
1862+
end do
1863+
do i = 1, nmomsp
1864+
@:DEALLOCATE(mom_sp(i)%sf)
1865+
end do
1866+
@:DEALLOCATE(mom_sp, mom_3d)
18421867
end if
18431868
18441869
end subroutine s_finalize_rhs_module

src/simulation/m_time_steppers.fpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,29 @@ contains
977977
call s_close_run_time_information_file()
978978
end if
979979

980+
if (chemistry) then
981+
@:DEALLOCATE(q_T_sf%sf)
982+
end if
983+
@:DEALLOCATE(pb_ts(1)%sf)
984+
@:DEALLOCATE(pb_ts(2)%sf)
985+
@:DEALLOCATE(rhs_pb)
986+
@:DEALLOCATE(pb_ts)
987+
@:DEALLOCATE(mv_ts(1)%sf)
988+
@:DEALLOCATE(mv_ts(2)%sf)
989+
@:DEALLOCATE(rhs_mv)
990+
@:DEALLOCATE(mv_ts)
991+
if (cfl_dt) then
992+
@:DEALLOCATE(max_dt)
993+
end if
994+
do i = 1, num_dims
995+
@:DEALLOCATE(bc_type(i,1)%sf)
996+
@:DEALLOCATE(bc_type(i,2)%sf)
997+
end do
998+
@:DEALLOCATE(bc_type)
999+
if (any(time_stepper == (/1, 2, 3/))) then
1000+
@:DEALLOCATE(rk_coef)
1001+
end if
1002+
9801003
end subroutine s_finalize_time_steppers_module
9811004

9821005
end module m_time_steppers

tests/coverage_map.json.gz

-16.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)