Skip to content

Commit 8f98be8

Browse files
committed
fix: initialize unset intent(out) args and remove unused variables
Initialize intent(out) arguments unconditionally before #ifdef blocks: - m_mpi_common.fpp: icfl_max_glb, vcfl_max_glb, Rc_min_glb - m_variables_conversion.fpp: rho_K, gamma_K, pi_inf_K, qv_K, Re_K, G_K - m_mpi_common.fpp: change intent(out) to intent(inout) for aliased allreduce Remove unused local variables verified across all build targets.
1 parent 336487c commit 8f98be8

10 files changed

Lines changed: 52 additions & 51 deletions

File tree

src/common/m_helper.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ contains
169169
impure subroutine s_initialize_nonpoly()
170170

171171
integer :: ir
172-
real(wp), dimension(nb) :: chi_vw0, cp_m0, k_m0, rho_m0, x_vw, omegaN, rhol0
172+
real(wp), dimension(nb) :: chi_vw0, cp_m0, k_m0, rho_m0, x_vw, omegaN
173173
real(wp), parameter :: k_poly = 1._wp !< polytropic index used to compute isothermal natural frequency
174174
! Chapman-Enskog transport coefficients for vapor-gas mixture, Ando JAS (2010)
175175

src/common/m_mpi_common.fpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ contains
101101
type(integer_field), optional, intent(in) :: ib_markers
102102
type(scalar_field), intent(in), optional :: beta
103103
integer, dimension(num_dims) :: sizes_glb, sizes_loc
104-
integer, dimension(1) :: airfoil_glb, airfoil_loc, airfoil_start
105104

106105
#ifdef MFC_MPI
107106
integer :: i, j
@@ -180,11 +179,11 @@ contains
180179
subroutine s_initialize_mpi_data_ds(q_cons_vf)
181180

182181
type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf
183-
integer, dimension(num_dims) :: sizes_glb, sizes_loc
182+
integer, dimension(num_dims) :: sizes_loc
184183
integer, dimension(3) :: sf_start_idx
185184

186185
#ifdef MFC_MPI
187-
integer :: i, j, q, k, l, m_ds, n_ds, p_ds, ierr
186+
integer :: i, m_ds, n_ds, p_ds, ierr
188187

189188
sf_start_idx = (/0, 0, 0/)
190189

@@ -297,16 +296,22 @@ contains
297296
real(wp), intent(out) :: vcfl_max_glb
298297
real(wp), intent(out) :: Rc_min_glb
299298

299+
icfl_max_glb = icfl_max_loc
300+
vcfl_max_glb = vcfl_max_loc
301+
Rc_min_glb = Rc_min_loc
302+
300303
#ifdef MFC_SIMULATION
301304
#ifdef MFC_MPI
302-
integer :: ierr !< Generic flag used to identify and report MPI errors
305+
block
306+
integer :: ierr
303307

304-
call MPI_REDUCE(icfl_max_loc, icfl_max_glb, 1, mpi_p, MPI_MAX, 0, MPI_COMM_WORLD, ierr)
308+
call MPI_REDUCE(icfl_max_loc, icfl_max_glb, 1, mpi_p, MPI_MAX, 0, MPI_COMM_WORLD, ierr)
305309

306-
if (viscous) then
307-
call MPI_REDUCE(vcfl_max_loc, vcfl_max_glb, 1, mpi_p, MPI_MAX, 0, MPI_COMM_WORLD, ierr)
308-
call MPI_REDUCE(Rc_min_loc, Rc_min_glb, 1, mpi_p, MPI_MIN, 0, MPI_COMM_WORLD, ierr)
309-
end if
310+
if (viscous) then
311+
call MPI_REDUCE(vcfl_max_loc, vcfl_max_glb, 1, mpi_p, MPI_MAX, 0, MPI_COMM_WORLD, ierr)
312+
call MPI_REDUCE(Rc_min_loc, Rc_min_glb, 1, mpi_p, MPI_MIN, 0, MPI_COMM_WORLD, ierr)
313+
end if
314+
end block
310315
#else
311316
icfl_max_glb = icfl_max_loc
312317

@@ -336,9 +341,9 @@ contains
336341
!> Reduce an array of vectors to their global sums across all MPI ranks.
337342
impure subroutine s_mpi_allreduce_vectors_sum(var_loc, var_glb, num_vectors, vector_length)
338343

339-
integer, intent(in) :: num_vectors, vector_length
340-
real(wp), dimension(:,:), intent(in) :: var_loc
341-
real(wp), dimension(:,:), intent(out) :: var_glb
344+
integer, intent(in) :: num_vectors, vector_length
345+
real(wp), dimension(:,:), intent(in) :: var_loc
346+
real(wp), dimension(:,:), intent(inout) :: var_glb
342347

343348
#ifdef MFC_MPI
344349
integer :: ierr !< Generic flag used to identify and report MPI errors

src/common/m_variables_conversion.fpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,14 @@ contains
260260
real(wp), optional, intent(out) :: G_K
261261
real(wp) :: alpha_K_sum
262262
integer :: i, j !< Generic loop iterators
263+
264+
rho_K = 0._wp
265+
gamma_K = 0._wp
266+
pi_inf_K = 0._wp
267+
qv_K = 0._wp
268+
Re_K = dflt_real
269+
if (present(G_K)) G_K = 0._wp
270+
263271
#ifdef MFC_SIMULATION
264272
! Constrain partial densities and volume fractions within physical bounds
265273
if (num_fluids == 1 .and. bubbles_euler) then

src/post_process/m_data_output.fpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -720,12 +720,12 @@ contains
720720
integer, dimension(MPI_STATUS_SIZE) :: status
721721
integer(KIND=MPI_OFFSET_KIND) :: disp
722722
integer :: view
723-
logical :: lg_bub_file, file_exist
723+
logical :: file_exist
724724
integer, dimension(2) :: gsizes, lsizes, start_idx_part
725725
integer :: ifile
726726
integer :: ierr
727727
real(wp) :: file_time, file_dt
728-
integer :: file_num_procs, file_tot_part, tot_part
728+
integer :: file_num_procs, file_tot_part
729729
integer :: i
730730
integer, dimension(:), allocatable :: proc_bubble_counts
731731
real(wp), dimension(1:1,1:lag_io_vars) :: lag_io_null
@@ -868,22 +868,21 @@ contains
868868
integer :: id
869869
870870
#ifdef MFC_MPI
871-
real(wp), dimension(20) :: inputvals
872871
real(wp) :: time_real
873872
integer, dimension(MPI_STATUS_SIZE) :: status
874873
integer(KIND=MPI_OFFSET_KIND) :: disp
875874
integer :: view
876-
logical :: lg_bub_file, file_exist
875+
logical :: file_exist
877876
integer, dimension(2) :: gsizes, lsizes, start_idx_part
878-
integer :: ifile, ierr, tot_data, valid_data, nBub
877+
integer :: ifile, ierr, nBub
879878
real(wp) :: file_time, file_dt
880879
integer :: file_num_procs, file_tot_part
881880
integer, dimension(:), allocatable :: proc_bubble_counts
882881
real(wp), dimension(1:1,1:lag_io_vars) :: dummy
883882
character(LEN=4*name_len), dimension(num_procs) :: meshnames
884883
integer, dimension(num_procs) :: meshtypes
885884
real(wp) :: dummy_data
886-
integer :: i, j
885+
integer :: i
887886
real(wp), dimension(:), allocatable :: bub_id
888887
real(wp), dimension(:), allocatable :: px, py, pz, ppx, ppy, ppz, vx, vy, vz
889888
real(wp), dimension(:), allocatable :: radius, rvel, rnot, rmax, rmin, dphidt

src/pre_process/m_icpp_patches.fpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module m_icpp_patches
3232
integer :: smooth_patch_id
3333
real(wp) :: smooth_coeff !< Smoothing coefficient (mirrors ic_patch_parameters%smooth_coeff)
3434
real(wp) :: eta !< Pseudo volume fraction for patch boundary smoothing
35-
real(wp) :: cart_x, cart_y, cart_z
35+
real(wp) :: cart_y, cart_z
3636
real(wp) :: sph_phi !< Spherical phi for Cartesian conversion in cylindrical coordinates
3737
type(bounds_info) :: x_boundary, y_boundary, z_boundary !< Patch boundary locations in x, y, z
3838
character(len=5) :: istr !< string to store int to string result for error checking
@@ -1268,20 +1268,18 @@ contains
12681268
type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf
12691269

12701270
! Variables for IBM+STL
1271-
real(wp) :: normals(1:3) !< Boundary normal buffer
1272-
integer :: boundary_vertex_count, boundary_edge_count, total_vertices !< Boundary vertex
1271+
real(wp) :: normals(1:3) !< Boundary normal buffer
1272+
integer :: boundary_vertex_count, boundary_edge_count, total_vertices !< Boundary vertex
12731273
real(wp), allocatable, dimension(:,:,:) :: boundary_v !< Boundary vertex buffer
1274-
real(wp) :: distance !< Levelset distance buffer
1275-
logical :: interpolate !< Logical variable to determine whether or not the model should be interpolated
1276-
integer :: i, j, k !< Generic loop iterators
1277-
type(t_bbox) :: bbox, bbox_old
1278-
type(t_model) :: model
1279-
type(ic_model_parameters) :: params
1280-
real(wp), dimension(1:3) :: point, model_center
1281-
real(wp) :: grid_mm(1:3,1:2)
1282-
integer :: cell_num
1283-
integer :: ncells
1284-
real(wp), dimension(1:4,1:4) :: transform, transform_n
1274+
integer :: i, j, k !< Generic loop iterators
1275+
type(t_bbox) :: bbox, bbox_old
1276+
type(t_model) :: model
1277+
type(ic_model_parameters) :: params
1278+
real(wp), dimension(1:3) :: point, model_center
1279+
real(wp) :: grid_mm(1:3,1:2)
1280+
integer :: cell_num
1281+
integer :: ncells
1282+
real(wp), dimension(1:4,1:4) :: transform, transform_n
12851283

12861284
if (proc_rank == 0) then
12871285
print *, " * Reading model: " // trim(patch_icpp(patch_id)%model_filepath)

src/simulation/m_bubbles_EL.fpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ contains
229229
integer, intent(in) :: bub_id
230230
integer :: i
231231
real(wp) :: pliq, volparticle, concvap, totalmass, kparticle, cpparticle
232-
real(wp) :: omegaN_local, PeG, PeT, rhol, pcrit, qv, gamma, pi_inf, dynP
232+
real(wp) :: omegaN_local, PeG, PeT, rhol, qv, gamma, pi_inf, dynP
233233
integer, dimension(3) :: cell
234234
real(wp), dimension(2) :: Re
235235
real(wp) :: massflag, heatflag, Re_trans, Im_trans
@@ -288,10 +288,7 @@ contains
288288
! Initial particle pressure
289289
gas_p(bub_id, 1) = pliq + 2._wp*(1._wp/Web)/bub_R0(bub_id)
290290
if (.not. f_approx_equal((1._wp/Web), 0._wp)) then
291-
pcrit = pv - 4._wp*(1._wp/Web)/(3._wp*sqrt(3._wp*gas_p(bub_id, 1)*bub_R0(bub_id)**3._wp/(2._wp*(1._wp/Web))))
292291
pref = gas_p(bub_id, 1)
293-
else
294-
pcrit = 0._wp
295292
end if
296293
297294
! Initial particle mass

src/simulation/m_compute_cbc.fpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ contains
149149
real(wp), dimension(num_dims), intent(in) :: dvel_ds
150150
#:endif
151151
real(wp), intent(in) :: rho, c, dpres_ds
152-
integer :: i
153152

154153
L(1) = f_base_L1(lambda, rho, c, dpres_ds, dvel_ds)
155154
L(2:advxe - 1) = 0._wp

src/simulation/m_compute_levelset.fpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ contains
8080

8181
type(ghost_point), intent(inout) :: gp
8282
real(wp) :: radius, dist
83-
real(wp), dimension(2) :: center
8483
real(wp), dimension(3) :: dist_vec
8584
integer :: i, j, ib_patch_id !< Loop index variables
8685
ib_patch_id = gp%ib_patch_id
@@ -188,13 +187,12 @@ contains
188187
$:GPU_ROUTINE(parallelism='[seq]')
189188
190189
type(ghost_point), intent(inout) :: gp
191-
real(wp) :: dist, dist_surf, dist_side, global_dist
190+
real(wp) :: dist_surf, dist_side, global_dist
192191
integer :: global_id
193192
real(wp) :: lz, z_max, z_min
194193
real(wp), dimension(3) :: dist_vec
195194
real(wp), dimension(1:3) :: xyz_local, center, offset, normal !< x, y, z coordinates in local IB frame
196195
real(wp), dimension(1:3,1:3) :: rotation, inverse_rotation
197-
real(wp) :: length_z
198196
integer :: i, j, k, l, ib_patch_id !< Loop index variables
199197
ib_patch_id = gp%ib_patch_id
200198
i = gp%loc(1)
@@ -360,8 +358,7 @@ contains
360358
real(wp), dimension(1:3) :: xy_local, normal_vector !< x and y coordinates in local IB frame
361359
real(wp), dimension(2) :: center !< x and y coordinates in local IB frame
362360
real(wp), dimension(1:3,1:3) :: rotation, inverse_rotation
363-
integer :: i, j, k !< Loop index variables
364-
integer :: idx !< Shortest path direction indicator
361+
integer :: i, j !< Loop index variables
365362
integer :: ib_patch_id !< patch ID
366363
ib_patch_id = gp%ib_patch_id
367364
i = gp%loc(1)
@@ -601,7 +598,7 @@ contains
601598
$:GPU_ROUTINE(parallelism='[seq]')
602599

603600
type(ghost_point), intent(inout) :: gp
604-
integer :: i, j, k, patch_id, boundary_edge_count, total_vertices
601+
integer :: i, j, k, patch_id, boundary_edge_count
605602
real(wp), dimension(1:3) :: center, xyz_local
606603
real(wp) :: normals(1:3) !< Boundary normal buffer
607604
real(wp) :: distance
@@ -614,7 +611,6 @@ contains
614611

615612
! load in model values
616613
boundary_edge_count = gpu_boundary_edge_count(patch_id)
617-
total_vertices = gpu_total_vertices(patch_id)
618614

619615
center = 0._wp
620616
if (.not. f_is_default(patch_ib(patch_id)%x_centroid)) center(1) = patch_ib(patch_id)%x_centroid + real(gp%x_periodicity, &

src/simulation/m_ibm.fpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ contains
837837
impure subroutine s_update_mib(num_ibs)
838838

839839
integer, intent(in) :: num_ibs
840-
integer :: i, j, k, ierr, z_gp_layers
840+
integer :: i, j, k, z_gp_layers
841841

842842
call nvtxStartRange("UPDATE-MIBM")
843843

@@ -884,11 +884,11 @@ contains
884884

885885
type(scalar_field), dimension(1:sys_size), intent(in) :: q_prim_vf
886886
type(physical_parameters), dimension(1:num_fluids), intent(in) :: fluid_pp
887-
integer :: gp_id, i, j, k, l, q, ib_idx, fluid_idx
887+
integer :: i, j, k, l, ib_idx, fluid_idx
888888
real(wp), dimension(num_ibs, 3) :: forces, torques
889889
real(wp), dimension(1:3,1:3) :: viscous_stress_div, viscous_stress_div_1, &
890890
& viscous_stress_div_2 ! viscous stress tensor with temp vectors to hold divergence calculations
891-
real(wp), dimension(1:3) :: local_force_contribution, radial_vector, local_torque_contribution, vel
891+
real(wp), dimension(1:3) :: local_force_contribution, radial_vector, local_torque_contribution
892892
real(wp) :: cell_volume, dx, dy, dz, dynamic_viscosity
893893

894894
#:if not MFC_CASE_OPTIMIZATION and USING_AMD

src/simulation/m_start_up.fpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,8 @@ contains
830830
!> Initialize all simulation sub-modules in the required dependency order
831831
impure subroutine s_initialize_modules
832832

833-
integer :: m_ds, n_ds, p_ds
834-
integer :: i, j, k, l, x_id, y_id, z_id, ix, iy, iz
835-
real(wp) :: temp1, temp2, temp3, temp4
833+
integer :: m_ds, n_ds, p_ds
834+
integer :: i
836835

837836
call s_initialize_global_parameters_module()
838837
#:if USING_AMD

0 commit comments

Comments
 (0)