Skip to content

Commit 5fbc676

Browse files
committed
fix: remove dead subroutines, dead stores, and more unused variables
Dead subroutines (zero call sites, verified case-insensitive across entire repo): - s_convert_cylindrical_to_spherical_coord in m_ib_patches.fpp and m_icpp_patches.fpp - s_compute_fd_divergence in m_finite_differences.fpp - s_solve_linear_system in post_process/m_derived_variables.fpp Dead stores (assigned but never read): - pres_mag, loc in m_assign_variables.fpp - M11 in simulation/m_data_output.fpp - flg in post_process/m_derived_variables.fpp - str_MOK, NVARS_MOK in pre_process and simulation m_start_up.fpp Unused locals: - theta1, theta2, En_tot, dirname, dir_exists in post_process/m_start_up.fpp - i in m_perturbation.fpp s_prng - t_step_ib_dir in post_process/m_data_input.f90
1 parent 6594f4d commit 5fbc676

11 files changed

Lines changed: 6 additions & 148 deletions

src/common/m_finite_differences.fpp

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,6 @@ module m_finite_differences
1313

1414
contains
1515

16-
!> Accumulate the finite-difference divergence of a vector field onto a scalar field.
17-
subroutine s_compute_fd_divergence(div, fields, ix_s, iy_s, iz_s)
18-
19-
type(scalar_field), intent(inout) :: div
20-
type(scalar_field), intent(in) :: fields(1:3)
21-
type(int_bounds_info), intent(in) :: ix_s, iy_s, iz_s
22-
integer :: x, y, z !< Generic loop iterators
23-
real(wp) :: divergence
24-
25-
$:GPU_PARALLEL_LOOP(collapse=3, private='[x, y, z, divergence]')
26-
do x = ix_s%beg, ix_s%end
27-
do y = iy_s%beg, iy_s%end
28-
do z = iz_s%beg, iz_s%end
29-
if (x == ix_s%beg) then
30-
divergence = (-3._wp*fields(1)%sf(x, y, z) + 4._wp*fields(1)%sf(x + 1, y, z) - fields(1)%sf(x + 2, y, &
31-
& z))/(x_cc(x + 2) - x_cc(x))
32-
else if (x == ix_s%end) then
33-
divergence = (+3._wp*fields(1)%sf(x, y, z) - 4._wp*fields(1)%sf(x - 1, y, z) + fields(1)%sf(x - 2, y, &
34-
& z))/(x_cc(x) - x_cc(x - 2))
35-
else
36-
divergence = (fields(1)%sf(x + 1, y, z) - fields(1)%sf(x - 1, y, z))/(x_cc(x + 1) - x_cc(x - 1))
37-
end if
38-
39-
if (n > 0) then
40-
if (y == iy_s%beg) then
41-
divergence = divergence + (-3._wp*fields(2)%sf(x, y, z) + 4._wp*fields(2)%sf(x, y + 1, &
42-
& z) - fields(2)%sf(x, y + 2, z))/(y_cc(y + 2) - y_cc(y))
43-
else if (y == iy_s%end) then
44-
divergence = divergence + (+3._wp*fields(2)%sf(x, y, z) - 4._wp*fields(2)%sf(x, y - 1, &
45-
& z) + fields(2)%sf(x, y - 2, z))/(y_cc(y) - y_cc(y - 2))
46-
else
47-
divergence = divergence + (fields(2)%sf(x, y + 1, z) - fields(2)%sf(x, y - 1, &
48-
& z))/(y_cc(y + 1) - y_cc(y - 1))
49-
end if
50-
end if
51-
52-
if (p > 0) then
53-
if (z == iz_s%beg) then
54-
divergence = divergence + (-3._wp*fields(3)%sf(x, y, z) + 4._wp*fields(3)%sf(x, y, &
55-
& z + 1) - fields(3)%sf(x, y, z + 2))/(z_cc(z + 2) - z_cc(z))
56-
else if (z == iz_s%end) then
57-
divergence = divergence + (+3._wp*fields(3)%sf(x, y, z) - 4._wp*fields(3)%sf(x, y, &
58-
& z - 1) + fields(3)%sf(x, y, z - 2))/(z_cc(z) - z_cc(z - 2))
59-
else
60-
divergence = divergence + (fields(3)%sf(x, y, z + 1) - fields(3)%sf(x, y, &
61-
& z - 1))/(z_cc(z + 1) - z_cc(z - 1))
62-
end if
63-
end if
64-
65-
div%sf(x, y, z) = div%sf(x, y, z) + divergence
66-
end do
67-
end do
68-
end do
69-
$:END_GPU_PARALLEL_LOOP()
70-
71-
end subroutine s_compute_fd_divergence
72-
7316
!> Compute the centered finite-difference coefficients for first-order spatial derivatives in the s-coordinate direction (x, y,
7417
!! or z). Supports up to 4th order accuracy.
7518
!! @param fd_coeff_s Finite-diff. coefficients in the s-coordinate direction

src/post_process/m_data_input.f90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ impure subroutine s_read_serial_data_files(t_step)
190190
character(LEN=len_trim(case_dir) + 2*name_len) :: t_step_dir
191191
character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc
192192
character(LEN=int(floor(log10(real(sys_size, wp)))) + 1) :: file_num
193-
character(LEN=len_trim(case_dir) + 2*name_len) :: t_step_ib_dir
194193
logical :: dir_check
195194
logical :: file_check
196195
integer :: i

src/post_process/m_derived_variables.fpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ module m_derived_variables
2828
real(wp), allocatable, dimension(:,:), public :: fd_coeff_z
2929
!> @}
3030

31-
integer, private :: flg !< Dimensionality flag: 1 = 3D dataset, 0 = otherwise
32-
3331
contains
3432

3533
!> Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the module
@@ -54,12 +52,6 @@ contains
5452
allocate (fd_coeff_z(-fd_number:fd_number,-offset_z%beg:p + offset_z%end))
5553
end if
5654

57-
if (p > 0) then
58-
flg = 1
59-
else
60-
flg = 0
61-
end if
62-
6355
end subroutine s_initialize_derived_variables_module
6456

6557
!> Derive the specific heat ratio from the specific heat ratio function gamma_sf. The latter is stored in the derived flow
@@ -207,42 +199,6 @@ contains
207199

208200
end subroutine s_derive_flux_limiter
209201

210-
!> Solve Ax=b via Gaussian elimination with partial pivoting
211-
subroutine s_solve_linear_system(A, b, sol, ndim)
212-
213-
integer, intent(in) :: ndim
214-
real(wp), dimension(ndim, ndim), intent(inout) :: A
215-
real(wp), dimension(ndim), intent(inout) :: b
216-
real(wp), dimension(ndim), intent(out) :: sol
217-
integer :: i, j, k
218-
219-
! Forward elimination with partial pivoting
220-
221-
do i = 1, ndim
222-
j = i - 1 + maxloc(abs(A(i:ndim,i)), 1)
223-
sol = A(i,:)
224-
A(i,:) = A(j,:)
225-
A(j,:) = sol
226-
sol(1) = b(i)
227-
b(i) = b(j)
228-
b(j) = sol(1)
229-
b(i) = b(i)/A(i, i)
230-
A(i,:) = A(i,:)/A(i, i)
231-
do k = i + 1, ndim
232-
b(k) = b(k) - A(k, i)*b(i)
233-
A(k,:) = A(k,:) - A(k, i)*A(i,:)
234-
end do
235-
end do
236-
237-
do i = ndim, 1, -1
238-
sol(i) = b(i)
239-
do k = i + 1, ndim
240-
sol(i) = sol(i) - A(i, k)*sol(k)
241-
end do
242-
end do
243-
244-
end subroutine s_solve_linear_system
245-
246202
!> Compute the specified component of the vorticity from the primitive variables. From those inputs, it proceeds to calculate
247203
!! values of the desired vorticity component, which are subsequently stored in derived flow quantity storage variable, q_sf.
248204
subroutine s_derive_vorticity_component(i, q_prim_vf, q_sf)

src/post_process/m_start_up.fpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,14 @@ contains
171171
integer, intent(inout) :: t_step
172172
character(LEN=name_len), intent(inout) :: varname
173173
real(wp), intent(inout) :: pres, c, H
174-
real(wp) :: theta1, theta2
175174
176175
real(wp), dimension(-offset_x%beg:m + offset_x%end,-offset_y%beg:n + offset_y%end, &
177176
& -offset_z%beg:p + offset_z%end) :: liutex_mag
178177
real(wp), dimension(-offset_x%beg:m + offset_x%end,-offset_y%beg:n + offset_y%end,-offset_z%beg:p + offset_z%end, &
179178
& 3) :: liutex_axis
180179
integer :: i, j, k, l, kx, ky, kz, kf, j_glb, k_glb, l_glb
181-
real(wp) :: En_tot
182-
character(50) :: filename, dirname
183-
logical :: file_exists, dir_exists
180+
character(50) :: filename
181+
logical :: file_exists
184182
integer :: x_beg, x_end, y_beg, y_end, z_beg, z_end
185183
186184
if (output_partial_domain) then

src/pre_process/m_assign_variables.fpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,10 @@ contains
139139
integer, intent(in) :: j, k, l
140140
type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf
141141
integer :: i
142-
real(wp) :: pres_mag, loc, n_tait, B_tait, p0
142+
real(wp) :: n_tait, B_tait, p0
143143
real(wp) :: R3bar, n0, ratio, nH, vfH, velH, rhoH, deno
144144

145145
p0 = 101325._wp
146-
pres_mag = 1.e-1_wp
147-
loc = x_cc(177)
148146
n_tait = gs_min(1)
149147
B_tait = ps_inf(1)
150148

src/pre_process/m_icpp_patches.fpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,17 +1403,6 @@ contains
14031403

14041404
end function f_convert_cyl_to_cart
14051405

1406-
!> Compute the spherical azimuthal angle from cylindrical (x, r) coordinates.
1407-
subroutine s_convert_cylindrical_to_spherical_coord(cyl_x, cyl_y)
1408-
1409-
$:GPU_ROUTINE(parallelism='[seq]')
1410-
1411-
real(wp), intent(in) :: cyl_x, cyl_y
1412-
1413-
sph_phi = atan(cyl_y/cyl_x)
1414-
1415-
end subroutine s_convert_cylindrical_to_spherical_coord
1416-
14171406
!> Archimedes spiral function
14181407
elemental function f_r(myth, offset, a)
14191408

src/pre_process/m_perturbation.fpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,13 @@ contains
6363

6464
type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf
6565
integer :: i, j, k
66-
real(wp) :: perturb_alpha
6766
real(wp) :: rand_real
6867

6968
call random_seed()
7069

7170
do k = 0, p
7271
do j = 0, n
7372
do i = 0, m
74-
perturb_alpha = q_prim_vf(E_idx + perturb_flow_fluid)%sf(i, j, k)
7573
call random_number(rand_real)
7674
rand_real = rand_real*perturb_flow_mag
7775
q_prim_vf(mom_idx%end)%sf(i, j, k) = rand_real*q_prim_vf(mom_idx%beg)%sf(i, j, k)
@@ -353,7 +351,6 @@ contains
353351

354352
integer, intent(inout) :: seed
355353
real(wp), intent(out) :: var
356-
integer :: i
357354

358355
seed = mod(modmul(seed), modulus)
359356
var = seed/real(modulus, wp)

src/pre_process/m_start_up.fpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,7 @@ contains
417417
integer, dimension(MPI_STATUS_SIZE) :: status
418418
integer(KIND=MPI_OFFSET_KIND) :: disp
419419
integer(KIND=MPI_OFFSET_KIND) :: m_MOK, n_MOK, p_MOK
420-
integer(KIND=MPI_OFFSET_KIND) :: WP_MOK, var_MOK, str_MOK
421-
integer(KIND=MPI_OFFSET_KIND) :: NVARS_MOK
420+
integer(KIND=MPI_OFFSET_KIND) :: WP_MOK, var_MOK
422421
integer(KIND=MPI_OFFSET_KIND) :: MOK
423422
character(LEN=path_len + 2*name_len) :: file_loc
424423
logical :: file_exist
@@ -445,8 +444,6 @@ contains
445444
p_MOK = int(p_glb + 1, MPI_OFFSET_KIND)
446445
WP_MOK = int(storage_size(0._stp)/8, MPI_OFFSET_KIND)
447446
MOK = int(1._wp, MPI_OFFSET_KIND)
448-
str_MOK = int(name_len, MPI_OFFSET_KIND)
449-
NVARS_MOK = int(sys_size, MPI_OFFSET_KIND)
450447
451448
do i = 1, sys_size
452449
var_MOK = int(i, MPI_OFFSET_KIND)

src/simulation/m_data_output.fpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ contains
979979
real(wp) :: pi_inf
980980
real(wp) :: qv
981981
real(wp) :: c
982-
real(wp) :: M00, M10, M01, M20, M11, M02
982+
real(wp) :: M00, M10, M01, M20, M02
983983
real(wp) :: varR, varV
984984
real(wp), dimension(Nb) :: nR, R, nRdot, Rdot
985985
real(wp) :: nR3
@@ -1029,7 +1029,6 @@ contains
10291029
M10 = 0._wp
10301030
M01 = 0._wp
10311031
M20 = 0._wp
1032-
M11 = 0._wp
10331032
M02 = 0._wp
10341033
varR = 0._wp; varV = 0._wp
10351034
alf = 0._wp
@@ -1116,13 +1115,11 @@ contains
11161115
M10 = q_cons_vf(bub_idx%moms(1, 2))%sf(j - 2, k, l)/nbub
11171116
M01 = q_cons_vf(bub_idx%moms(1, 3))%sf(j - 2, k, l)/nbub
11181117
M20 = q_cons_vf(bub_idx%moms(1, 4))%sf(j - 2, k, l)/nbub
1119-
M11 = q_cons_vf(bub_idx%moms(1, 5))%sf(j - 2, k, l)/nbub
11201118
M02 = q_cons_vf(bub_idx%moms(1, 6))%sf(j - 2, k, l)/nbub
11211119

11221120
M10 = M10/M00
11231121
M01 = M01/M00
11241122
M20 = M20/M00
1125-
M11 = M11/M00
11261123
M02 = M02/M00
11271124

11281125
varR = M20 - M10**2._wp

src/simulation/m_ib_patches.fpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -981,17 +981,6 @@ contains
981981

982982
end function f_convert_cyl_to_cart
983983

984-
!> Convert cylindrical coordinates (x, r) to the spherical azimuthal angle phi
985-
subroutine s_convert_cylindrical_to_spherical_coord(cyl_x, cyl_y)
986-
987-
$:GPU_ROUTINE(parallelism='[seq]')
988-
989-
real(wp), intent(in) :: cyl_x, cyl_y
990-
991-
sph_phi = atan(cyl_y/cyl_x)
992-
993-
end subroutine s_convert_cylindrical_to_spherical_coord
994-
995984
subroutine get_bounding_indices(left_bound, right_bound, cell_centers, left_index, right_index)
996985

997986
real(wp), intent(in) :: left_bound, right_bound

0 commit comments

Comments
 (0)