From 8f98be86e96e06f73e20968427440aee6d089c02 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Tue, 31 Mar 2026 20:56:34 -0400 Subject: [PATCH 1/7] 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. --- src/common/m_helper.fpp | 2 +- src/common/m_mpi_common.fpp | 29 ++++++++++++++++----------- src/common/m_variables_conversion.fpp | 8 ++++++++ src/post_process/m_data_output.fpp | 11 +++++----- src/pre_process/m_icpp_patches.fpp | 26 +++++++++++------------- src/simulation/m_bubbles_EL.fpp | 5 +---- src/simulation/m_compute_cbc.fpp | 1 - src/simulation/m_compute_levelset.fpp | 10 +++------ src/simulation/m_ibm.fpp | 6 +++--- src/simulation/m_start_up.fpp | 5 ++--- 10 files changed, 52 insertions(+), 51 deletions(-) diff --git a/src/common/m_helper.fpp b/src/common/m_helper.fpp index 4074530a8f..f643f55eed 100644 --- a/src/common/m_helper.fpp +++ b/src/common/m_helper.fpp @@ -169,7 +169,7 @@ contains impure subroutine s_initialize_nonpoly() integer :: ir - real(wp), dimension(nb) :: chi_vw0, cp_m0, k_m0, rho_m0, x_vw, omegaN, rhol0 + real(wp), dimension(nb) :: chi_vw0, cp_m0, k_m0, rho_m0, x_vw, omegaN real(wp), parameter :: k_poly = 1._wp !< polytropic index used to compute isothermal natural frequency ! Chapman-Enskog transport coefficients for vapor-gas mixture, Ando JAS (2010) diff --git a/src/common/m_mpi_common.fpp b/src/common/m_mpi_common.fpp index 8a719f5758..f6a729b166 100644 --- a/src/common/m_mpi_common.fpp +++ b/src/common/m_mpi_common.fpp @@ -101,7 +101,6 @@ contains type(integer_field), optional, intent(in) :: ib_markers type(scalar_field), intent(in), optional :: beta integer, dimension(num_dims) :: sizes_glb, sizes_loc - integer, dimension(1) :: airfoil_glb, airfoil_loc, airfoil_start #ifdef MFC_MPI integer :: i, j @@ -180,11 +179,11 @@ contains subroutine s_initialize_mpi_data_ds(q_cons_vf) type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf - integer, dimension(num_dims) :: sizes_glb, sizes_loc + integer, dimension(num_dims) :: sizes_loc integer, dimension(3) :: sf_start_idx #ifdef MFC_MPI - integer :: i, j, q, k, l, m_ds, n_ds, p_ds, ierr + integer :: i, m_ds, n_ds, p_ds, ierr sf_start_idx = (/0, 0, 0/) @@ -297,16 +296,22 @@ contains real(wp), intent(out) :: vcfl_max_glb real(wp), intent(out) :: Rc_min_glb + icfl_max_glb = icfl_max_loc + vcfl_max_glb = vcfl_max_loc + Rc_min_glb = Rc_min_loc + #ifdef MFC_SIMULATION #ifdef MFC_MPI - integer :: ierr !< Generic flag used to identify and report MPI errors + block + integer :: ierr - call MPI_REDUCE(icfl_max_loc, icfl_max_glb, 1, mpi_p, MPI_MAX, 0, MPI_COMM_WORLD, ierr) + call MPI_REDUCE(icfl_max_loc, icfl_max_glb, 1, mpi_p, MPI_MAX, 0, MPI_COMM_WORLD, ierr) - if (viscous) then - call MPI_REDUCE(vcfl_max_loc, vcfl_max_glb, 1, mpi_p, MPI_MAX, 0, MPI_COMM_WORLD, ierr) - call MPI_REDUCE(Rc_min_loc, Rc_min_glb, 1, mpi_p, MPI_MIN, 0, MPI_COMM_WORLD, ierr) - end if + if (viscous) then + call MPI_REDUCE(vcfl_max_loc, vcfl_max_glb, 1, mpi_p, MPI_MAX, 0, MPI_COMM_WORLD, ierr) + call MPI_REDUCE(Rc_min_loc, Rc_min_glb, 1, mpi_p, MPI_MIN, 0, MPI_COMM_WORLD, ierr) + end if + end block #else icfl_max_glb = icfl_max_loc @@ -336,9 +341,9 @@ contains !> Reduce an array of vectors to their global sums across all MPI ranks. impure subroutine s_mpi_allreduce_vectors_sum(var_loc, var_glb, num_vectors, vector_length) - integer, intent(in) :: num_vectors, vector_length - real(wp), dimension(:,:), intent(in) :: var_loc - real(wp), dimension(:,:), intent(out) :: var_glb + integer, intent(in) :: num_vectors, vector_length + real(wp), dimension(:,:), intent(in) :: var_loc + real(wp), dimension(:,:), intent(inout) :: var_glb #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors diff --git a/src/common/m_variables_conversion.fpp b/src/common/m_variables_conversion.fpp index 9fdae1258b..d74095c5ab 100644 --- a/src/common/m_variables_conversion.fpp +++ b/src/common/m_variables_conversion.fpp @@ -260,6 +260,14 @@ contains real(wp), optional, intent(out) :: G_K real(wp) :: alpha_K_sum integer :: i, j !< Generic loop iterators + + rho_K = 0._wp + gamma_K = 0._wp + pi_inf_K = 0._wp + qv_K = 0._wp + Re_K = dflt_real + if (present(G_K)) G_K = 0._wp + #ifdef MFC_SIMULATION ! Constrain partial densities and volume fractions within physical bounds if (num_fluids == 1 .and. bubbles_euler) then diff --git a/src/post_process/m_data_output.fpp b/src/post_process/m_data_output.fpp index 0ac093288f..1398d59859 100644 --- a/src/post_process/m_data_output.fpp +++ b/src/post_process/m_data_output.fpp @@ -720,12 +720,12 @@ contains integer, dimension(MPI_STATUS_SIZE) :: status integer(KIND=MPI_OFFSET_KIND) :: disp integer :: view - logical :: lg_bub_file, file_exist + logical :: file_exist integer, dimension(2) :: gsizes, lsizes, start_idx_part integer :: ifile integer :: ierr real(wp) :: file_time, file_dt - integer :: file_num_procs, file_tot_part, tot_part + integer :: file_num_procs, file_tot_part integer :: i integer, dimension(:), allocatable :: proc_bubble_counts real(wp), dimension(1:1,1:lag_io_vars) :: lag_io_null @@ -868,14 +868,13 @@ contains integer :: id #ifdef MFC_MPI - real(wp), dimension(20) :: inputvals real(wp) :: time_real integer, dimension(MPI_STATUS_SIZE) :: status integer(KIND=MPI_OFFSET_KIND) :: disp integer :: view - logical :: lg_bub_file, file_exist + logical :: file_exist integer, dimension(2) :: gsizes, lsizes, start_idx_part - integer :: ifile, ierr, tot_data, valid_data, nBub + integer :: ifile, ierr, nBub real(wp) :: file_time, file_dt integer :: file_num_procs, file_tot_part integer, dimension(:), allocatable :: proc_bubble_counts @@ -883,7 +882,7 @@ contains character(LEN=4*name_len), dimension(num_procs) :: meshnames integer, dimension(num_procs) :: meshtypes real(wp) :: dummy_data - integer :: i, j + integer :: i real(wp), dimension(:), allocatable :: bub_id real(wp), dimension(:), allocatable :: px, py, pz, ppx, ppy, ppz, vx, vy, vz real(wp), dimension(:), allocatable :: radius, rvel, rnot, rmax, rmin, dphidt diff --git a/src/pre_process/m_icpp_patches.fpp b/src/pre_process/m_icpp_patches.fpp index a565a1b0b3..c2c310edfa 100644 --- a/src/pre_process/m_icpp_patches.fpp +++ b/src/pre_process/m_icpp_patches.fpp @@ -32,7 +32,7 @@ module m_icpp_patches integer :: smooth_patch_id real(wp) :: smooth_coeff !< Smoothing coefficient (mirrors ic_patch_parameters%smooth_coeff) real(wp) :: eta !< Pseudo volume fraction for patch boundary smoothing - real(wp) :: cart_x, cart_y, cart_z + real(wp) :: cart_y, cart_z real(wp) :: sph_phi !< Spherical phi for Cartesian conversion in cylindrical coordinates type(bounds_info) :: x_boundary, y_boundary, z_boundary !< Patch boundary locations in x, y, z character(len=5) :: istr !< string to store int to string result for error checking @@ -1268,20 +1268,18 @@ contains type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf ! Variables for IBM+STL - real(wp) :: normals(1:3) !< Boundary normal buffer - integer :: boundary_vertex_count, boundary_edge_count, total_vertices !< Boundary vertex + real(wp) :: normals(1:3) !< Boundary normal buffer + integer :: boundary_vertex_count, boundary_edge_count, total_vertices !< Boundary vertex real(wp), allocatable, dimension(:,:,:) :: boundary_v !< Boundary vertex buffer - real(wp) :: distance !< Levelset distance buffer - logical :: interpolate !< Logical variable to determine whether or not the model should be interpolated - integer :: i, j, k !< Generic loop iterators - type(t_bbox) :: bbox, bbox_old - type(t_model) :: model - type(ic_model_parameters) :: params - real(wp), dimension(1:3) :: point, model_center - real(wp) :: grid_mm(1:3,1:2) - integer :: cell_num - integer :: ncells - real(wp), dimension(1:4,1:4) :: transform, transform_n + integer :: i, j, k !< Generic loop iterators + type(t_bbox) :: bbox, bbox_old + type(t_model) :: model + type(ic_model_parameters) :: params + real(wp), dimension(1:3) :: point, model_center + real(wp) :: grid_mm(1:3,1:2) + integer :: cell_num + integer :: ncells + real(wp), dimension(1:4,1:4) :: transform, transform_n if (proc_rank == 0) then print *, " * Reading model: " // trim(patch_icpp(patch_id)%model_filepath) diff --git a/src/simulation/m_bubbles_EL.fpp b/src/simulation/m_bubbles_EL.fpp index 437dbe0db2..ab7dcd6366 100644 --- a/src/simulation/m_bubbles_EL.fpp +++ b/src/simulation/m_bubbles_EL.fpp @@ -229,7 +229,7 @@ contains integer, intent(in) :: bub_id integer :: i real(wp) :: pliq, volparticle, concvap, totalmass, kparticle, cpparticle - real(wp) :: omegaN_local, PeG, PeT, rhol, pcrit, qv, gamma, pi_inf, dynP + real(wp) :: omegaN_local, PeG, PeT, rhol, qv, gamma, pi_inf, dynP integer, dimension(3) :: cell real(wp), dimension(2) :: Re real(wp) :: massflag, heatflag, Re_trans, Im_trans @@ -288,10 +288,7 @@ contains ! Initial particle pressure gas_p(bub_id, 1) = pliq + 2._wp*(1._wp/Web)/bub_R0(bub_id) if (.not. f_approx_equal((1._wp/Web), 0._wp)) then - 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)))) pref = gas_p(bub_id, 1) - else - pcrit = 0._wp end if ! Initial particle mass diff --git a/src/simulation/m_compute_cbc.fpp b/src/simulation/m_compute_cbc.fpp index cbeac697af..152589ca6d 100644 --- a/src/simulation/m_compute_cbc.fpp +++ b/src/simulation/m_compute_cbc.fpp @@ -149,7 +149,6 @@ contains real(wp), dimension(num_dims), intent(in) :: dvel_ds #:endif real(wp), intent(in) :: rho, c, dpres_ds - integer :: i L(1) = f_base_L1(lambda, rho, c, dpres_ds, dvel_ds) L(2:advxe - 1) = 0._wp diff --git a/src/simulation/m_compute_levelset.fpp b/src/simulation/m_compute_levelset.fpp index da1dcd9109..96fdebb357 100644 --- a/src/simulation/m_compute_levelset.fpp +++ b/src/simulation/m_compute_levelset.fpp @@ -80,7 +80,6 @@ contains type(ghost_point), intent(inout) :: gp real(wp) :: radius, dist - real(wp), dimension(2) :: center real(wp), dimension(3) :: dist_vec integer :: i, j, ib_patch_id !< Loop index variables ib_patch_id = gp%ib_patch_id @@ -188,13 +187,12 @@ contains $:GPU_ROUTINE(parallelism='[seq]') type(ghost_point), intent(inout) :: gp - real(wp) :: dist, dist_surf, dist_side, global_dist + real(wp) :: dist_surf, dist_side, global_dist integer :: global_id real(wp) :: lz, z_max, z_min real(wp), dimension(3) :: dist_vec real(wp), dimension(1:3) :: xyz_local, center, offset, normal !< x, y, z coordinates in local IB frame real(wp), dimension(1:3,1:3) :: rotation, inverse_rotation - real(wp) :: length_z integer :: i, j, k, l, ib_patch_id !< Loop index variables ib_patch_id = gp%ib_patch_id i = gp%loc(1) @@ -360,8 +358,7 @@ contains real(wp), dimension(1:3) :: xy_local, normal_vector !< x and y coordinates in local IB frame real(wp), dimension(2) :: center !< x and y coordinates in local IB frame real(wp), dimension(1:3,1:3) :: rotation, inverse_rotation - integer :: i, j, k !< Loop index variables - integer :: idx !< Shortest path direction indicator + integer :: i, j !< Loop index variables integer :: ib_patch_id !< patch ID ib_patch_id = gp%ib_patch_id i = gp%loc(1) @@ -601,7 +598,7 @@ contains $:GPU_ROUTINE(parallelism='[seq]') type(ghost_point), intent(inout) :: gp - integer :: i, j, k, patch_id, boundary_edge_count, total_vertices + integer :: i, j, k, patch_id, boundary_edge_count real(wp), dimension(1:3) :: center, xyz_local real(wp) :: normals(1:3) !< Boundary normal buffer real(wp) :: distance @@ -614,7 +611,6 @@ contains ! load in model values boundary_edge_count = gpu_boundary_edge_count(patch_id) - total_vertices = gpu_total_vertices(patch_id) center = 0._wp if (.not. f_is_default(patch_ib(patch_id)%x_centroid)) center(1) = patch_ib(patch_id)%x_centroid + real(gp%x_periodicity, & diff --git a/src/simulation/m_ibm.fpp b/src/simulation/m_ibm.fpp index 785bf2dec3..b724a724fa 100644 --- a/src/simulation/m_ibm.fpp +++ b/src/simulation/m_ibm.fpp @@ -837,7 +837,7 @@ contains impure subroutine s_update_mib(num_ibs) integer, intent(in) :: num_ibs - integer :: i, j, k, ierr, z_gp_layers + integer :: i, j, k, z_gp_layers call nvtxStartRange("UPDATE-MIBM") @@ -884,11 +884,11 @@ contains type(scalar_field), dimension(1:sys_size), intent(in) :: q_prim_vf type(physical_parameters), dimension(1:num_fluids), intent(in) :: fluid_pp - integer :: gp_id, i, j, k, l, q, ib_idx, fluid_idx + integer :: i, j, k, l, ib_idx, fluid_idx real(wp), dimension(num_ibs, 3) :: forces, torques real(wp), dimension(1:3,1:3) :: viscous_stress_div, viscous_stress_div_1, & & viscous_stress_div_2 ! viscous stress tensor with temp vectors to hold divergence calculations - real(wp), dimension(1:3) :: local_force_contribution, radial_vector, local_torque_contribution, vel + real(wp), dimension(1:3) :: local_force_contribution, radial_vector, local_torque_contribution real(wp) :: cell_volume, dx, dy, dz, dynamic_viscosity #:if not MFC_CASE_OPTIMIZATION and USING_AMD diff --git a/src/simulation/m_start_up.fpp b/src/simulation/m_start_up.fpp index c3f38ef500..db6b19d566 100644 --- a/src/simulation/m_start_up.fpp +++ b/src/simulation/m_start_up.fpp @@ -830,9 +830,8 @@ contains !> Initialize all simulation sub-modules in the required dependency order impure subroutine s_initialize_modules - integer :: m_ds, n_ds, p_ds - integer :: i, j, k, l, x_id, y_id, z_id, ix, iy, iz - real(wp) :: temp1, temp2, temp3, temp4 + integer :: m_ds, n_ds, p_ds + integer :: i call s_initialize_global_parameters_module() #:if USING_AMD From ab00a28228056eecf161f44057626d21736153bd Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Tue, 31 Mar 2026 21:27:46 -0400 Subject: [PATCH 2/7] fix: remove unused module-level and local variables in simulation Remove dead CCFL variables from m_data_output.fpp (ccfl_sf, ccfl_max_loc, ccfl_max_glb, ccfl_max). Remove dead gradient magnitude variables from m_rhs.fpp (gm_alpha_qp, gm_alphaL_n, gm_alphaR_n, nbub) including their GPU_DECLARE and ALLOCATE. Remove 13 unused module-level variables from m_ib_patches.fpp and 7 unused local variables from its subroutines. Remove unused idist/odist from m_fftw.fpp and dest from m_time_steppers.fpp. --- src/simulation/m_data_output.fpp | 9 +++----- src/simulation/m_fftw.fpp | 2 +- src/simulation/m_ib_patches.fpp | 35 ++++++------------------------ src/simulation/m_rhs.fpp | 25 --------------------- src/simulation/m_time_steppers.fpp | 1 - 5 files changed, 11 insertions(+), 61 deletions(-) diff --git a/src/simulation/m_data_output.fpp b/src/simulation/m_data_output.fpp index 086a218289..864e090471 100644 --- a/src/simulation/m_data_output.fpp +++ b/src/simulation/m_data_output.fpp @@ -32,23 +32,20 @@ module m_data_output integer :: ib_state_unit = -1 !< I/O unit for IB state binary file real(wp), allocatable, dimension(:,:,:) :: icfl_sf !< ICFL stability criterion real(wp), allocatable, dimension(:,:,:) :: vcfl_sf !< VCFL stability criterion - real(wp), allocatable, dimension(:,:,:) :: ccfl_sf !< CCFL stability criterion real(wp), allocatable, dimension(:,:,:) :: Rc_sf !< Rc stability criterion real(wp), public, allocatable, dimension(:,:) :: c_mass - $:GPU_DECLARE(create='[icfl_sf, vcfl_sf, ccfl_sf, Rc_sf, c_mass]') + $:GPU_DECLARE(create='[icfl_sf, vcfl_sf, Rc_sf, c_mass]') real(wp) :: icfl_max_loc, icfl_max_glb !< ICFL stability extrema on local and global grids real(wp) :: vcfl_max_loc, vcfl_max_glb !< VCFL stability extrema on local and global grids - real(wp) :: ccfl_max_loc, ccfl_max_glb !< CCFL stability extrema on local and global grids real(wp) :: Rc_min_loc, Rc_min_glb !< Rc stability extrema on local and global grids $:GPU_DECLARE(create='[icfl_max_loc, icfl_max_glb, vcfl_max_loc, vcfl_max_glb]') - $:GPU_DECLARE(create='[ccfl_max_loc, ccfl_max_glb, Rc_min_loc, Rc_min_glb]') + $:GPU_DECLARE(create='[Rc_min_loc, Rc_min_glb]') - !> @name ICFL, VCFL, CCFL and Rc stability criteria extrema over all the time-steps + !> @name ICFL, VCFL, and Rc stability criteria extrema over all the time-steps !> @{ real(wp) :: icfl_max !< ICFL criterion maximum real(wp) :: vcfl_max !< VCFL criterion maximum - real(wp) :: ccfl_max !< CCFL criterion maximum real(wp) :: Rc_min !< Rc criterion maximum !> @} diff --git a/src/simulation/m_fftw.fpp b/src/simulation/m_fftw.fpp index 38005f76ca..ff94f3a138 100644 --- a/src/simulation/m_fftw.fpp +++ b/src/simulation/m_fftw.fpp @@ -53,7 +53,7 @@ module m_fftw !> @endcond integer, allocatable :: gpu_fft_size(:), iembed(:), oembed(:) - integer :: istride, ostride, idist, odist, rank + integer :: istride, ostride, rank #endif contains diff --git a/src/simulation/m_ib_patches.fpp b/src/simulation/m_ib_patches.fpp index a7d8e45eee..6f6e7140b6 100644 --- a/src/simulation/m_ib_patches.fpp +++ b/src/simulation/m_ib_patches.fpp @@ -24,31 +24,11 @@ module m_ib_patches private; public :: s_apply_ib_patches, s_update_ib_rotation_matrix, f_convert_cyl_to_cart, s_instantiate_STL_models, & & s_decode_patch_periodicity - real(wp) :: x_centroid, y_centroid, z_centroid - real(wp) :: length_x, length_y, length_z - $:GPU_DECLARE(create='[x_centroid, y_centroid, z_centroid]') - $:GPU_DECLARE(create='[length_x, length_y, length_z]') - - integer :: smooth_patch_id - real(wp) :: smooth_coeff - $:GPU_DECLARE(create='[smooth_patch_id, smooth_coeff]') - ! These variables are analogous in both meaning and use to the similarly named components in the ic_patch_parameters type (see - ! m_derived_types.f90 for additional details). They are employed as a means to more concisely perform the actions necessary to - ! lay out a particular patch on the grid. - - real(wp) :: cart_x, cart_y, cart_z + real(wp) :: cart_y, cart_z real(wp) :: sph_phi - $:GPU_DECLARE(create='[cart_x, cart_y, cart_z, sph_phi]') + $:GPU_DECLARE(create='[cart_y, cart_z, sph_phi]') ! Variables to be used to hold cell locations in Cartesian coordinates if 3D simulation is using cylindrical coordinates - type(bounds_info) :: x_boundary, y_boundary, z_boundary - $:GPU_DECLARE(create='[x_boundary, y_boundary, z_boundary]') - ! These variables combine the centroid and length parameters associated with a particular patch to yield the locations of the - ! patch boundaries in the x-, y- and z-coordinate directions. They are used as a means to concisely perform the actions - ! necessary to lay out a particular patch on the grid. - - character(len=5) :: istr !< string to store int to string result for error checking - contains !> Apply all immersed boundary patch geometries to mark interior cells in the IB marker array @@ -773,15 +753,15 @@ contains integer, intent(in) :: patch_id type(integer_field), intent(inout) :: ib_markers - integer, intent(in) :: xp, yp !< integers containing the periodicity projection information - integer :: i, j, k, il, ir, jl, jr !< Generic loop iterators + integer, intent(in) :: xp, yp !< integers containing the periodicity projection information + integer :: i, j, il, ir, jl, jr !< Generic loop iterators integer :: spc, encoded_patch_id integer :: cx, cy real(wp) :: lx(2), ly(2) real(wp), dimension(1:2) :: bbox_min, bbox_max real(wp), dimension(1:3) :: local_corner, world_corner real(wp) :: eta, threshold - real(wp), dimension(1:3) :: point, local_point, offset + real(wp), dimension(1:3) :: offset real(wp), dimension(1:3) :: center, xy_local real(wp), dimension(1:3,1:3) :: inverse_rotation, rotation @@ -853,8 +833,8 @@ contains integer, intent(in) :: xp, yp, zp !< integers containing the periodicity projection information integer :: i, j, k, il, ir, jl, jr, kl, kr !< Generic loop iterators integer :: spc, encoded_patch_id - real(wp) :: eta, threshold, corner_distance - real(wp), dimension(1:3) :: point, local_point, offset + real(wp) :: eta, threshold + real(wp), dimension(1:3) :: offset real(wp), dimension(1:3) :: center, xyz_local real(wp), dimension(1:3,1:3) :: inverse_rotation, rotation integer :: cx, cy, cz @@ -936,7 +916,6 @@ contains subroutine s_update_ib_rotation_matrix(patch_id) integer, intent(in) :: patch_id - integer :: i real(wp), dimension(3, 3, 3) :: rotation real(wp) :: angle diff --git a/src/simulation/m_rhs.fpp b/src/simulation/m_rhs.fpp index 1f347a0289..72471f4892 100644 --- a/src/simulation/m_rhs.fpp +++ b/src/simulation/m_rhs.fpp @@ -67,19 +67,6 @@ module m_rhs type(scalar_field), allocatable, dimension(:) :: tau_Re_vf $:GPU_DECLARE(create='[tau_Re_vf]') - type(vector_field) :: gm_alpha_qp !< Volume fraction gradient magnitudes at cell-interior quadrature points - $:GPU_DECLARE(create='[gm_alpha_qp]') - - !> @name The left and right WENO-reconstructed cell-boundary values of the cell- average gradient magnitude of volume fractions, - !! located in gm_alpha_qp. - !> @{ - type(vector_field), allocatable, dimension(:) :: gm_alphaL_n - type(vector_field), allocatable, dimension(:) :: gm_alphaR_n -#if defined(MFC_OpenACC) - $:GPU_DECLARE(create='[gm_alphaL_n, gm_alphaR_n]') -#endif - !> @} - !> @name The cell-boundary values of the fluxes (src - source, gsrc - geometrical source). These are computed by applying the !! chosen Riemann problem solver .on the left and right cell-boundary values of the primitive variables !> @{ @@ -122,9 +109,6 @@ module m_rhs $:GPU_DECLARE(create='[qL_rsx_vf, qL_rsy_vf, qL_rsz_vf, qR_rsx_vf, qR_rsy_vf, qR_rsz_vf]') $:GPU_DECLARE(create='[dqL_rsx_vf, dqL_rsy_vf, dqL_rsz_vf, dqR_rsx_vf, dqR_rsy_vf, dqR_rsz_vf]') - real(wp), allocatable, dimension(:,:,:) :: nbub !< Bubble number density - $:GPU_DECLARE(create='[nbub]') - contains !> Initialize the RHS module @@ -513,11 +497,6 @@ contains if (mpp_lim .and. bubbles_euler) then @:ALLOCATE(alf_sum%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, idwbuff(3)%beg:idwbuff(3)%end)) end if - if (.not. igr) then - @:ALLOCATE(gm_alphaL_n(1:num_dims)) - @:ALLOCATE(gm_alphaR_n(1:num_dims)) - end if - if (alt_soundspeed) then @:ALLOCATE(blkmod1(0:m, 0:n, 0:p), blkmod2(0:m, 0:n, 0:p), alpha1(0:m, 0:n, 0:p), alpha2(0:m, 0:n, 0:p), Kterm(0:m, & & 0:n, 0:p)) @@ -525,10 +504,6 @@ contains call s_initialize_pressure_relaxation_module - if (bubbles_euler) then - @:ALLOCATE(nbub(0:m, 0:n, 0:p)) - end if - end subroutine s_initialize_rhs_module !> Compute the right-hand side of the semi-discrete governing equations for a single time stage diff --git a/src/simulation/m_time_steppers.fpp b/src/simulation/m_time_steppers.fpp index 4a741a4068..94a74d946e 100644 --- a/src/simulation/m_time_steppers.fpp +++ b/src/simulation/m_time_steppers.fpp @@ -463,7 +463,6 @@ contains integer, intent(in) :: nstage integer :: i, j, k, l, q, s !< Generic loop iterator real(wp) :: start, finish - integer :: dest call cpu_time(start) call nvtxStartRange("TIMESTEP") From 6594f4d4086c8a6c145c93ba60593ab16b74a0f6 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Tue, 31 Mar 2026 21:58:25 -0400 Subject: [PATCH 3/7] fix: remove more unused variables and dead code Remove unused locals in m_boundary_common.fpp (status, i, offset), m_model.fpp (theta, ndot, norm_mag, c, total_vertices, eta, max_iv1/2), m_data_input.f90 (delx, dely, delz), and m_time_steppers.fpp (gm_alpha_qp). Remove dead module-level bubrs_qbmm from m_qbmm.fpp (allocated and GPU-updated but never read by any code). --- src/common/m_boundary_common.fpp | 11 +---------- src/common/m_model.fpp | 22 ++++++++++------------ src/post_process/m_data_input.f90 | 1 - src/simulation/m_qbmm.fpp | 9 +-------- src/simulation/m_time_steppers.fpp | 2 -- 5 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/common/m_boundary_common.fpp b/src/common/m_boundary_common.fpp index 918b0daea5..f2c0173f30 100644 --- a/src/common/m_boundary_common.fpp +++ b/src/common/m_boundary_common.fpp @@ -1573,7 +1573,7 @@ contains type(integer_field), dimension(1:num_dims,1:2), intent(in) :: bc_type logical, intent(in) :: old_grid_in character(LEN=*), intent(in) :: step_dirpath - integer :: dir, loc, i + integer :: dir, loc character(len=path_len) :: file_path character(len=10) :: status @@ -1612,12 +1612,10 @@ contains type(integer_field), dimension(1:num_dims,1:2), intent(in) :: bc_type integer :: dir, loc character(len=path_len) :: file_loc, file_path - character(len=10) :: status #ifdef MFC_MPI integer :: ierr integer :: file_id - integer :: offset character(len=7) :: proc_rank_str logical :: dir_check integer :: nelements @@ -1642,8 +1640,6 @@ contains file_path = trim(file_loc) // '/bc_' // trim(proc_rank_str) // '.dat' call MPI_File_open(MPI_COMM_SELF, trim(file_path), MPI_MODE_CREATE + MPI_MODE_WRONLY, MPI_INFO_NULL, file_id, ierr) - offset = 0 - ! Write bc_types do dir = 1, num_dims do loc = 1, 2 @@ -1678,7 +1674,6 @@ contains integer :: dir, loc logical :: file_exist character(len=path_len) :: file_path - character(len=10) :: status ! Read bc_types @@ -1721,12 +1716,10 @@ contains type(integer_field), dimension(1:num_dims,1:2), intent(inout) :: bc_type integer :: dir, loc character(len=path_len) :: file_loc, file_path - character(len=10) :: status #ifdef MFC_MPI integer :: ierr integer :: file_id - integer :: offset character(len=7) :: proc_rank_str logical :: dir_check integer :: nelements @@ -1750,8 +1743,6 @@ contains file_path = trim(file_loc) // '/bc_' // trim(proc_rank_str) // '.dat' call MPI_File_open(MPI_COMM_SELF, trim(file_path), MPI_MODE_RDONLY, MPI_INFO_NULL, file_id, ierr) - offset = 0 - ! Read bc_types do dir = 1, num_dims do loc = 1, 2 diff --git a/src/common/m_model.fpp b/src/common/m_model.fpp index c88bffa7e6..0dab036f9b 100644 --- a/src/common/m_model.fpp +++ b/src/common/m_model.fpp @@ -488,7 +488,7 @@ contains real(wp), dimension(1:3), intent(in) :: point real(wp), dimension(1:3), intent(in) :: spacing integer, intent(in) :: spc - real(wp) :: phi, theta + real(wp) :: phi integer :: rand_seed real(wp) :: fraction type(t_ray) :: ray @@ -779,7 +779,7 @@ contains real(wp) :: v1(1:3), v2(1:3), v3(1:3) real(wp) :: e0(1:3), e1(1:3), pv(1:3) real(wp) :: n(1:3), proj(1:3), norm_vec(1:3) - real(wp) :: d, ndot, denom, norm_mag + real(wp) :: d, denom, norm_mag real(wp) :: u, v_bary, w real(wp) :: l00, l01, l11, l20, l21 real(wp) :: edge(1:3), pe(1:3) @@ -905,9 +905,9 @@ contains real(wp), dimension(1:3), intent(out) :: normals real(wp), intent(out) :: distance integer :: i - real(wp) :: dist_min, dist, t, norm_mag + real(wp) :: dist_min, dist, t real(wp) :: v1(1:2), v2(1:2), edge(1:2), pv(1:2) - real(wp) :: edge_len_sq, proj(1:2), norm(1:2), c + real(wp) :: edge_len_sq, proj(1:2), norm(1:2) dist_min = initial_distance_buffer normals = 0._wp @@ -967,16 +967,15 @@ contains subroutine s_instantiate_STL_models() ! Variables for IBM+STL - real(wp) :: normals(1:3) !< Boundary normal buffer - integer :: boundary_vertex_count, boundary_edge_count, total_vertices !< Boundary vertex - real(wp), allocatable, dimension(:,:,:) :: boundary_v !< Boundary vertex buffer - real(wp) :: dx_local, dy_local, dz_local !< Levelset distance buffer - integer :: i, j, k !< Generic loop iterators + real(wp) :: normals(1:3) !< Boundary normal buffer + integer :: boundary_vertex_count, boundary_edge_count !< Boundary vertex + real(wp), allocatable, dimension(:,:,:) :: boundary_v !< Boundary vertex buffer + real(wp) :: dx_local, dy_local, dz_local !< Levelset distance buffer + integer :: i, j, k !< Generic loop iterators integer :: patch_id type(t_bbox) :: bbox, bbox_old type(t_model) :: model type(ic_model_parameters) :: params - real(wp) :: eta real(wp), dimension(1:3) :: point, model_center real(wp) :: grid_mm(1:3,1:2) real(wp), dimension(1:4,1:4) :: transform, transform_n @@ -1066,11 +1065,10 @@ contains ! Pack and upload flat arrays for GPU (AFTER the loop) block integer :: pid, max_ntrs - integer :: max_bv1, max_bv2, max_bv3, max_iv1, max_iv2 + integer :: max_bv1, max_bv2, max_bv3 max_ntrs = 0 max_bv1 = 0; max_bv2 = 0; max_bv3 = 0 - max_iv1 = 0; max_iv2 = 0 do pid = 1, num_ibs if (allocated(models(pid)%model)) then diff --git a/src/post_process/m_data_input.f90 b/src/post_process/m_data_input.f90 index 3a75c391f2..fb19f03404 100644 --- a/src/post_process/m_data_input.f90 +++ b/src/post_process/m_data_input.f90 @@ -258,7 +258,6 @@ impure subroutine s_read_parallel_data_files(t_step) integer(KIND=MPI_OFFSET_KIND) :: NVARS_MOK integer(KIND=MPI_OFFSET_KIND) :: MOK integer(kind=MPI_OFFSET_KIND) :: offset - real(wp) :: delx, dely, delz character(LEN=path_len + 2*name_len) :: file_loc logical :: file_exist character(len=10) :: t_step_string diff --git a/src/simulation/m_qbmm.fpp b/src/simulation/m_qbmm.fpp index e32fd92954..9ee945ba6d 100644 --- a/src/simulation/m_qbmm.fpp +++ b/src/simulation/m_qbmm.fpp @@ -32,9 +32,8 @@ module m_qbmm type(int_bounds_info) :: is1_qbmm, is2_qbmm, is3_qbmm $:GPU_DECLARE(create='[is1_qbmm, is2_qbmm, is3_qbmm]') - integer, allocatable, dimension(:) :: bubrs_qbmm integer, allocatable, dimension(:,:) :: bubmoms - $:GPU_DECLARE(create='[bubrs_qbmm, bubmoms]') + $:GPU_DECLARE(create='[bubmoms]') contains @@ -383,14 +382,8 @@ contains $:GPU_UPDATE(device='[momrhs]') - @:ALLOCATE(bubrs_qbmm(1:nb)) @:ALLOCATE(bubmoms(1:nb, 1:nmom)) - do i = 1, nb - bubrs_qbmm(i) = bub_idx%rs(i) - end do - $:GPU_UPDATE(device='[bubrs_qbmm]') - do j = 1, nmom do i = 1, nb bubmoms(i, j) = bub_idx%moms(i, j) diff --git a/src/simulation/m_time_steppers.fpp b/src/simulation/m_time_steppers.fpp index 94a74d946e..326df09807 100644 --- a/src/simulation/m_time_steppers.fpp +++ b/src/simulation/m_time_steppers.fpp @@ -598,7 +598,6 @@ contains impure subroutine s_adaptive_dt_bubble(stage) integer, intent(in) :: stage - type(vector_field) :: gm_alpha_qp call s_convert_conservative_to_primitive_variables(q_cons_ts(1)%vf, q_T_sf, q_prim_vf, idwint) @@ -642,7 +641,6 @@ contains real(wp) :: c !< Cell-avg. sound speed real(wp) :: H !< Cell-avg. enthalpy real(wp), dimension(2) :: Re !< Cell-avg. Reynolds numbers - type(vector_field) :: gm_alpha_qp real(wp) :: dt_local integer :: j, k, l !< Generic loop iterators From 42ac3ceb407970a0a6bac72f083462d00782cbe7 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Tue, 31 Mar 2026 22:58:27 -0400 Subject: [PATCH 4/7] fix: remove dead subroutines, dead stores, and more unused variables Dead subroutines (zero call sites, verified case-insensitive across entire repo including Fypp includes, hardcoded IC dispatch tables, and case.fpp): - 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 variables: - my_divu in m_bubbles_EE.fpp (declared and in GPU private clause but never used) - 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 --- src/common/m_finite_differences.fpp | 57 ------------------------ src/post_process/m_data_input.f90 | 1 - src/post_process/m_derived_variables.fpp | 44 ------------------ src/post_process/m_start_up.fpp | 6 +-- src/pre_process/m_assign_variables.fpp | 4 +- src/pre_process/m_icpp_patches.fpp | 11 ----- src/pre_process/m_perturbation.fpp | 3 -- src/pre_process/m_start_up.fpp | 5 +-- src/simulation/m_bubbles_EE.fpp | 3 +- src/simulation/m_data_output.fpp | 5 +-- src/simulation/m_ib_patches.fpp | 11 ----- src/simulation/m_start_up.fpp | 7 +-- 12 files changed, 7 insertions(+), 150 deletions(-) diff --git a/src/common/m_finite_differences.fpp b/src/common/m_finite_differences.fpp index f26c203dcd..32075eb034 100644 --- a/src/common/m_finite_differences.fpp +++ b/src/common/m_finite_differences.fpp @@ -13,63 +13,6 @@ module m_finite_differences contains - !> Accumulate the finite-difference divergence of a vector field onto a scalar field. - subroutine s_compute_fd_divergence(div, fields, ix_s, iy_s, iz_s) - - type(scalar_field), intent(inout) :: div - type(scalar_field), intent(in) :: fields(1:3) - type(int_bounds_info), intent(in) :: ix_s, iy_s, iz_s - integer :: x, y, z !< Generic loop iterators - real(wp) :: divergence - - $:GPU_PARALLEL_LOOP(collapse=3, private='[x, y, z, divergence]') - do x = ix_s%beg, ix_s%end - do y = iy_s%beg, iy_s%end - do z = iz_s%beg, iz_s%end - if (x == ix_s%beg) then - divergence = (-3._wp*fields(1)%sf(x, y, z) + 4._wp*fields(1)%sf(x + 1, y, z) - fields(1)%sf(x + 2, y, & - & z))/(x_cc(x + 2) - x_cc(x)) - else if (x == ix_s%end) then - divergence = (+3._wp*fields(1)%sf(x, y, z) - 4._wp*fields(1)%sf(x - 1, y, z) + fields(1)%sf(x - 2, y, & - & z))/(x_cc(x) - x_cc(x - 2)) - else - divergence = (fields(1)%sf(x + 1, y, z) - fields(1)%sf(x - 1, y, z))/(x_cc(x + 1) - x_cc(x - 1)) - end if - - if (n > 0) then - if (y == iy_s%beg) then - divergence = divergence + (-3._wp*fields(2)%sf(x, y, z) + 4._wp*fields(2)%sf(x, y + 1, & - & z) - fields(2)%sf(x, y + 2, z))/(y_cc(y + 2) - y_cc(y)) - else if (y == iy_s%end) then - divergence = divergence + (+3._wp*fields(2)%sf(x, y, z) - 4._wp*fields(2)%sf(x, y - 1, & - & z) + fields(2)%sf(x, y - 2, z))/(y_cc(y) - y_cc(y - 2)) - else - divergence = divergence + (fields(2)%sf(x, y + 1, z) - fields(2)%sf(x, y - 1, & - & z))/(y_cc(y + 1) - y_cc(y - 1)) - end if - end if - - if (p > 0) then - if (z == iz_s%beg) then - divergence = divergence + (-3._wp*fields(3)%sf(x, y, z) + 4._wp*fields(3)%sf(x, y, & - & z + 1) - fields(3)%sf(x, y, z + 2))/(z_cc(z + 2) - z_cc(z)) - else if (z == iz_s%end) then - divergence = divergence + (+3._wp*fields(3)%sf(x, y, z) - 4._wp*fields(3)%sf(x, y, & - & z - 1) + fields(3)%sf(x, y, z - 2))/(z_cc(z) - z_cc(z - 2)) - else - divergence = divergence + (fields(3)%sf(x, y, z + 1) - fields(3)%sf(x, y, & - & z - 1))/(z_cc(z + 1) - z_cc(z - 1)) - end if - end if - - div%sf(x, y, z) = div%sf(x, y, z) + divergence - end do - end do - end do - $:END_GPU_PARALLEL_LOOP() - - end subroutine s_compute_fd_divergence - !> Compute the centered finite-difference coefficients for first-order spatial derivatives in the s-coordinate direction (x, y, !! or z). Supports up to 4th order accuracy. !! @param fd_coeff_s Finite-diff. coefficients in the s-coordinate direction diff --git a/src/post_process/m_data_input.f90 b/src/post_process/m_data_input.f90 index fb19f03404..e7d6f2b716 100644 --- a/src/post_process/m_data_input.f90 +++ b/src/post_process/m_data_input.f90 @@ -190,7 +190,6 @@ impure subroutine s_read_serial_data_files(t_step) character(LEN=len_trim(case_dir) + 2*name_len) :: t_step_dir character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc character(LEN=int(floor(log10(real(sys_size, wp)))) + 1) :: file_num - character(LEN=len_trim(case_dir) + 2*name_len) :: t_step_ib_dir logical :: dir_check logical :: file_check integer :: i diff --git a/src/post_process/m_derived_variables.fpp b/src/post_process/m_derived_variables.fpp index daa9ca6dbf..ccd1af2ff8 100644 --- a/src/post_process/m_derived_variables.fpp +++ b/src/post_process/m_derived_variables.fpp @@ -28,8 +28,6 @@ module m_derived_variables real(wp), allocatable, dimension(:,:), public :: fd_coeff_z !> @} - integer, private :: flg !< Dimensionality flag: 1 = 3D dataset, 0 = otherwise - contains !> Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the module @@ -54,12 +52,6 @@ contains allocate (fd_coeff_z(-fd_number:fd_number,-offset_z%beg:p + offset_z%end)) end if - if (p > 0) then - flg = 1 - else - flg = 0 - end if - end subroutine s_initialize_derived_variables_module !> 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 end subroutine s_derive_flux_limiter - !> Solve Ax=b via Gaussian elimination with partial pivoting - subroutine s_solve_linear_system(A, b, sol, ndim) - - integer, intent(in) :: ndim - real(wp), dimension(ndim, ndim), intent(inout) :: A - real(wp), dimension(ndim), intent(inout) :: b - real(wp), dimension(ndim), intent(out) :: sol - integer :: i, j, k - - ! Forward elimination with partial pivoting - - do i = 1, ndim - j = i - 1 + maxloc(abs(A(i:ndim,i)), 1) - sol = A(i,:) - A(i,:) = A(j,:) - A(j,:) = sol - sol(1) = b(i) - b(i) = b(j) - b(j) = sol(1) - b(i) = b(i)/A(i, i) - A(i,:) = A(i,:)/A(i, i) - do k = i + 1, ndim - b(k) = b(k) - A(k, i)*b(i) - A(k,:) = A(k,:) - A(k, i)*A(i,:) - end do - end do - - do i = ndim, 1, -1 - sol(i) = b(i) - do k = i + 1, ndim - sol(i) = sol(i) - A(i, k)*sol(k) - end do - end do - - end subroutine s_solve_linear_system - !> Compute the specified component of the vorticity from the primitive variables. From those inputs, it proceeds to calculate !! values of the desired vorticity component, which are subsequently stored in derived flow quantity storage variable, q_sf. subroutine s_derive_vorticity_component(i, q_prim_vf, q_sf) diff --git a/src/post_process/m_start_up.fpp b/src/post_process/m_start_up.fpp index c65e4cf7cf..0da4425be7 100644 --- a/src/post_process/m_start_up.fpp +++ b/src/post_process/m_start_up.fpp @@ -171,16 +171,14 @@ contains integer, intent(inout) :: t_step character(LEN=name_len), intent(inout) :: varname real(wp), intent(inout) :: pres, c, H - real(wp) :: theta1, theta2 real(wp), dimension(-offset_x%beg:m + offset_x%end,-offset_y%beg:n + offset_y%end, & & -offset_z%beg:p + offset_z%end) :: liutex_mag real(wp), dimension(-offset_x%beg:m + offset_x%end,-offset_y%beg:n + offset_y%end,-offset_z%beg:p + offset_z%end, & & 3) :: liutex_axis integer :: i, j, k, l, kx, ky, kz, kf, j_glb, k_glb, l_glb - real(wp) :: En_tot - character(50) :: filename, dirname - logical :: file_exists, dir_exists + character(50) :: filename + logical :: file_exists integer :: x_beg, x_end, y_beg, y_end, z_beg, z_end if (output_partial_domain) then diff --git a/src/pre_process/m_assign_variables.fpp b/src/pre_process/m_assign_variables.fpp index e171097d4b..bd0c4ef884 100644 --- a/src/pre_process/m_assign_variables.fpp +++ b/src/pre_process/m_assign_variables.fpp @@ -139,12 +139,10 @@ contains integer, intent(in) :: j, k, l type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf integer :: i - real(wp) :: pres_mag, loc, n_tait, B_tait, p0 + real(wp) :: n_tait, B_tait, p0 real(wp) :: R3bar, n0, ratio, nH, vfH, velH, rhoH, deno p0 = 101325._wp - pres_mag = 1.e-1_wp - loc = x_cc(177) n_tait = gs_min(1) B_tait = ps_inf(1) diff --git a/src/pre_process/m_icpp_patches.fpp b/src/pre_process/m_icpp_patches.fpp index c2c310edfa..0fd388df6f 100644 --- a/src/pre_process/m_icpp_patches.fpp +++ b/src/pre_process/m_icpp_patches.fpp @@ -1403,17 +1403,6 @@ contains end function f_convert_cyl_to_cart - !> Compute the spherical azimuthal angle from cylindrical (x, r) coordinates. - subroutine s_convert_cylindrical_to_spherical_coord(cyl_x, cyl_y) - - $:GPU_ROUTINE(parallelism='[seq]') - - real(wp), intent(in) :: cyl_x, cyl_y - - sph_phi = atan(cyl_y/cyl_x) - - end subroutine s_convert_cylindrical_to_spherical_coord - !> Archimedes spiral function elemental function f_r(myth, offset, a) diff --git a/src/pre_process/m_perturbation.fpp b/src/pre_process/m_perturbation.fpp index f3096068c1..516fc3a6ce 100644 --- a/src/pre_process/m_perturbation.fpp +++ b/src/pre_process/m_perturbation.fpp @@ -63,7 +63,6 @@ contains type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf integer :: i, j, k - real(wp) :: perturb_alpha real(wp) :: rand_real call random_seed() @@ -71,7 +70,6 @@ contains do k = 0, p do j = 0, n do i = 0, m - perturb_alpha = q_prim_vf(E_idx + perturb_flow_fluid)%sf(i, j, k) call random_number(rand_real) rand_real = rand_real*perturb_flow_mag 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 integer, intent(inout) :: seed real(wp), intent(out) :: var - integer :: i seed = mod(modmul(seed), modulus) var = seed/real(modulus, wp) diff --git a/src/pre_process/m_start_up.fpp b/src/pre_process/m_start_up.fpp index a3a7c51270..0cf3a475f3 100644 --- a/src/pre_process/m_start_up.fpp +++ b/src/pre_process/m_start_up.fpp @@ -417,8 +417,7 @@ contains integer, dimension(MPI_STATUS_SIZE) :: status integer(KIND=MPI_OFFSET_KIND) :: disp integer(KIND=MPI_OFFSET_KIND) :: m_MOK, n_MOK, p_MOK - integer(KIND=MPI_OFFSET_KIND) :: WP_MOK, var_MOK, str_MOK - integer(KIND=MPI_OFFSET_KIND) :: NVARS_MOK + integer(KIND=MPI_OFFSET_KIND) :: WP_MOK, var_MOK integer(KIND=MPI_OFFSET_KIND) :: MOK character(LEN=path_len + 2*name_len) :: file_loc logical :: file_exist @@ -445,8 +444,6 @@ contains p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) WP_MOK = int(storage_size(0._stp)/8, MPI_OFFSET_KIND) MOK = int(1._wp, MPI_OFFSET_KIND) - str_MOK = int(name_len, MPI_OFFSET_KIND) - NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) do i = 1, sys_size var_MOK = int(i, MPI_OFFSET_KIND) diff --git a/src/simulation/m_bubbles_EE.fpp b/src/simulation/m_bubbles_EE.fpp index b2c5f1fd97..c80753fdb3 100644 --- a/src/simulation/m_bubbles_EE.fpp +++ b/src/simulation/m_bubbles_EE.fpp @@ -157,7 +157,6 @@ contains #:endif real(wp) :: myR, myV, alf, myP, myRho, R2Vav, R3 real(wp) :: nbub !< Bubble number density - real(wp) :: my_divu integer :: i, j, k, l, q, ii !< Loop variables integer :: adap_dt_stop_max, adap_dt_stop !< Fail-safe exit if max iteration count reached integer :: dmBub_id !< Dummy variables for unified subgrid bubble subroutines @@ -183,7 +182,7 @@ contains adap_dt_stop_max = 0 $:GPU_PARALLEL_LOOP(private='[j, k, l, Rtmp, Vtmp, myalpha_rho, myalpha, myR, myV, alf, myP, myRho, R2Vav, R3, nbub, & - & pb_local, mv_local, vflux, pbdot, rddot, n_tait, B_tait, my_divu]', collapse=3, & + & pb_local, mv_local, vflux, pbdot, rddot, n_tait, B_tait]', collapse=3, & & reduction = '[[adap_dt_stop_max]]', reductionOp = '[MAX]', copy = '[adap_dt_stop_max]') do l = 0, p do k = 0, n diff --git a/src/simulation/m_data_output.fpp b/src/simulation/m_data_output.fpp index 864e090471..2d547a6e1d 100644 --- a/src/simulation/m_data_output.fpp +++ b/src/simulation/m_data_output.fpp @@ -979,7 +979,7 @@ contains real(wp) :: pi_inf real(wp) :: qv real(wp) :: c - real(wp) :: M00, M10, M01, M20, M11, M02 + real(wp) :: M00, M10, M01, M20, M02 real(wp) :: varR, varV real(wp), dimension(Nb) :: nR, R, nRdot, Rdot real(wp) :: nR3 @@ -1029,7 +1029,6 @@ contains M10 = 0._wp M01 = 0._wp M20 = 0._wp - M11 = 0._wp M02 = 0._wp varR = 0._wp; varV = 0._wp alf = 0._wp @@ -1116,13 +1115,11 @@ contains M10 = q_cons_vf(bub_idx%moms(1, 2))%sf(j - 2, k, l)/nbub M01 = q_cons_vf(bub_idx%moms(1, 3))%sf(j - 2, k, l)/nbub M20 = q_cons_vf(bub_idx%moms(1, 4))%sf(j - 2, k, l)/nbub - M11 = q_cons_vf(bub_idx%moms(1, 5))%sf(j - 2, k, l)/nbub M02 = q_cons_vf(bub_idx%moms(1, 6))%sf(j - 2, k, l)/nbub M10 = M10/M00 M01 = M01/M00 M20 = M20/M00 - M11 = M11/M00 M02 = M02/M00 varR = M20 - M10**2._wp diff --git a/src/simulation/m_ib_patches.fpp b/src/simulation/m_ib_patches.fpp index 6f6e7140b6..e5618a256f 100644 --- a/src/simulation/m_ib_patches.fpp +++ b/src/simulation/m_ib_patches.fpp @@ -981,17 +981,6 @@ contains end function f_convert_cyl_to_cart - !> Convert cylindrical coordinates (x, r) to the spherical azimuthal angle phi - subroutine s_convert_cylindrical_to_spherical_coord(cyl_x, cyl_y) - - $:GPU_ROUTINE(parallelism='[seq]') - - real(wp), intent(in) :: cyl_x, cyl_y - - sph_phi = atan(cyl_y/cyl_x) - - end subroutine s_convert_cylindrical_to_spherical_coord - subroutine get_bounding_indices(left_bound, right_bound, cell_centers, left_index, right_index) real(wp), intent(in) :: left_bound, right_bound diff --git a/src/simulation/m_start_up.fpp b/src/simulation/m_start_up.fpp index db6b19d566..684e6b0eba 100644 --- a/src/simulation/m_start_up.fpp +++ b/src/simulation/m_start_up.fpp @@ -304,8 +304,7 @@ contains integer, dimension(MPI_STATUS_SIZE) :: status integer(KIND=MPI_OFFSET_KIND) :: disp integer(KIND=MPI_OFFSET_KIND) :: m_MOK, n_MOK, p_MOK - integer(KIND=MPI_OFFSET_KIND) :: WP_MOK, var_MOK, str_MOK - integer(KIND=MPI_OFFSET_KIND) :: NVARS_MOK + integer(KIND=MPI_OFFSET_KIND) :: WP_MOK, var_MOK integer(KIND=MPI_OFFSET_KIND) :: MOK character(LEN=path_len + 2*name_len) :: file_loc logical :: file_exist @@ -434,8 +433,6 @@ contains p_MOK = int(m_glb_read + 1, MPI_OFFSET_KIND) WP_MOK = int(storage_size(0._stp)/8, MPI_OFFSET_KIND) MOK = int(1._wp, MPI_OFFSET_KIND) - str_MOK = int(name_len, MPI_OFFSET_KIND) - NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) if (bubbles_euler .or. elasticity) then do i = 1, sys_size ! adv_idx%end @@ -498,8 +495,6 @@ contains p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) WP_MOK = int(storage_size(0._stp)/8, MPI_OFFSET_KIND) MOK = int(1._wp, MPI_OFFSET_KIND) - str_MOK = int(name_len, MPI_OFFSET_KIND) - NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) if (bubbles_euler .or. elasticity) then do i = 1, sys_size ! adv_idx%end From a8e1ea85fbb78451fb5edb79146e93c5beea66f6 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Wed, 1 Apr 2026 07:58:03 -0400 Subject: [PATCH 5/7] fix: replace fragile floating-point equality comparisons - m_ibm.fpp: Re(1) /= 0._wp -> Re(1) > 0._wp (matches convention in m_global_parameters.fpp where Re is checked with > 0) - m_ibm.fpp: sqrt(sum(axis**2)) == 0 -> < sgm_eps (floating-point magnitude should not be compared with exact equality) - ExtrusionHardcodedIC.fpp: dummy_x == x0 -> f_approx_equal (coordinates read from files should not be compared with exact equality) --- src/common/include/ExtrusionHardcodedIC.fpp | 2 +- src/simulation/m_ibm.fpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/include/ExtrusionHardcodedIC.fpp b/src/common/include/ExtrusionHardcodedIC.fpp index 07acc54a5e..3d82f60d11 100644 --- a/src/common/include/ExtrusionHardcodedIC.fpp +++ b/src/common/include/ExtrusionHardcodedIC.fpp @@ -109,7 +109,7 @@ do read (unit2, *, iostat=ios2) dummy_x, dummy_y, dummy_z if (ios2 /= 0) exit - if (dummy_x == x0 .and. dummy_y /= y0) then + if (f_approx_equal(dummy_x, x0) .and. (.not. f_approx_equal(dummy_y, y0))) then yRows = yRows + 1 else exit diff --git a/src/simulation/m_ibm.fpp b/src/simulation/m_ibm.fpp index b724a724fa..1323235887 100644 --- a/src/simulation/m_ibm.fpp +++ b/src/simulation/m_ibm.fpp @@ -904,7 +904,7 @@ contains if (viscous) then do fluid_idx = 1, num_fluids - if (fluid_pp(fluid_idx)%Re(1) /= 0._wp) then + if (fluid_pp(fluid_idx)%Re(1) > 0._wp) then dynamic_viscosities(fluid_idx) = 1._wp/fluid_pp(fluid_idx)%Re(1) else dynamic_viscosities(fluid_idx) = 0._wp @@ -1110,7 +1110,7 @@ contains if (p == 0) then normal_axis = [0, 0, 1] - else if (sqrt(sum(axis**2)) == 0) then + else if (sqrt(sum(axis**2)) < sgm_eps) then ! if the object is not actually rotating at this time, return a dummy value and exit patch_ib(ib_marker)%moment = 1._wp return From f3c9deb4cea33db044413871e4744b0743edf74b Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Wed, 1 Apr 2026 09:10:52 -0400 Subject: [PATCH 6/7] fix: use precision-aware default tolerance in f_approx_equal Single precision (wp=real(4)) has ~7 decimal digits of precision, so a default tolerance of 1e-10 is below machine epsilon (~1.2e-7) and f_approx_equal would almost never return true. Use 1e-6 for single precision builds and keep 1e-10 for double precision. The wp == single_precision comparison uses integer parameter constants that the compiler resolves at compile time, so there is no runtime cost. --- src/common/m_helper_basic.fpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/common/m_helper_basic.fpp b/src/common/m_helper_basic.fpp index 7208a451da..ccd46145e1 100644 --- a/src/common/m_helper_basic.fpp +++ b/src/common/m_helper_basic.fpp @@ -8,6 +8,7 @@ module m_helper_basic use m_derived_types + use m_precision_select implicit none @@ -29,7 +30,11 @@ contains if (present(tol_input)) then tol = tol_input else - tol = 1.e-10_wp + if (wp == single_precision) then + tol = 1.e-6_wp + else + tol = 1.e-10_wp + end if end if if (a == b) then @@ -58,7 +63,11 @@ contains if (present(tol_input)) then tol = tol_input else - tol = 1e-10_wp + if (wp == single_precision) then + tol = 1.e-6_wp + else + tol = 1.e-10_wp + end if end if do i = 1, size(b) From ce7328e366220864b46f904f1726f65518a00781 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Wed, 1 Apr 2026 09:32:32 -0400 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20remove=20dead=20sph=5Fphi=20variable?= =?UTF-8?q?,=20fix=20#ifdef=20DEBUG=20=E2=86=92=20MFC=5FDEBUG,=20remove=20?= =?UTF-8?q?dead=20store?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove sph_phi from m_ib_patches.fpp and m_icpp_patches.fpp (only user was s_convert_cylindrical_to_spherical_coord, removed in prior commit) - Fix #ifdef DEBUG to #ifdef MFC_DEBUG in m_data_output.fpp and m_variables_conversion.fpp (bare DEBUG is never defined, MFC_DEBUG is) - Remove dead igr assignment in toolchain/mfc/case.py (overwritten on line 360 without being read) --- src/common/m_variables_conversion.fpp | 2 +- src/pre_process/m_icpp_patches.fpp | 1 - src/simulation/m_data_output.fpp | 2 +- src/simulation/m_ib_patches.fpp | 3 +-- toolchain/mfc/case.py | 2 -- 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/common/m_variables_conversion.fpp b/src/common/m_variables_conversion.fpp index d74095c5ab..e9055e51f0 100644 --- a/src/common/m_variables_conversion.fpp +++ b/src/common/m_variables_conversion.fpp @@ -1323,7 +1323,7 @@ contains disc = term**2 - 4*c**2*B(norm)**2/(rho*h + B2) end if -#ifdef DEBUG +#ifdef MFC_DEBUG if (disc < 0._wp) then print *, 'rho, c, Bx, By, Bz, h, term, disc:', rho, c, B(1), B(2), B(3), h, term, disc call s_mpi_abort('Error: negative discriminant in s_compute_fast_magnetosonic_speed') diff --git a/src/pre_process/m_icpp_patches.fpp b/src/pre_process/m_icpp_patches.fpp index 0fd388df6f..8d92745595 100644 --- a/src/pre_process/m_icpp_patches.fpp +++ b/src/pre_process/m_icpp_patches.fpp @@ -33,7 +33,6 @@ module m_icpp_patches real(wp) :: smooth_coeff !< Smoothing coefficient (mirrors ic_patch_parameters%smooth_coeff) real(wp) :: eta !< Pseudo volume fraction for patch boundary smoothing real(wp) :: cart_y, cart_z - real(wp) :: sph_phi !< Spherical phi for Cartesian conversion in cylindrical coordinates type(bounds_info) :: x_boundary, y_boundary, z_boundary !< Patch boundary locations in x, y, z character(len=5) :: istr !< string to store int to string result for error checking diff --git a/src/simulation/m_data_output.fpp b/src/simulation/m_data_output.fpp index 2d547a6e1d..01f0d95100 100644 --- a/src/simulation/m_data_output.fpp +++ b/src/simulation/m_data_output.fpp @@ -1107,7 +1107,7 @@ contains nbub = sqrt((4._wp*pi/3._wp)*nR3/alf) end if -#ifdef DEBUG +#ifdef MFC_DEBUG print *, 'In probe, nbub: ', nbub #endif if (qbmm) then diff --git a/src/simulation/m_ib_patches.fpp b/src/simulation/m_ib_patches.fpp index e5618a256f..0758aa6f9f 100644 --- a/src/simulation/m_ib_patches.fpp +++ b/src/simulation/m_ib_patches.fpp @@ -25,8 +25,7 @@ module m_ib_patches & s_decode_patch_periodicity real(wp) :: cart_y, cart_z - real(wp) :: sph_phi - $:GPU_DECLARE(create='[cart_y, cart_z, sph_phi]') + $:GPU_DECLARE(create='[cart_y, cart_z]') ! Variables to be used to hold cell locations in Cartesian coordinates if 3D simulation is using cylindrical coordinates contains diff --git a/toolchain/mfc/case.py b/toolchain/mfc/case.py index 9627ef4503..48de3fa5cb 100644 --- a/toolchain/mfc/case.py +++ b/toolchain/mfc/case.py @@ -328,8 +328,6 @@ def __get_sim_fpp(self, print: bool) -> str: wenoz = 1 if self.params.get("wenoz", "F") == "T" else 0 teno = 1 if self.params.get("teno", "F") == "T" else 0 wenojs = 0 if (mapped_weno or wenoz or teno) else 1 - igr = 1 if self.params.get("igr", "F") == "T" else 0 - recon_type = self.params.get("recon_type", 1) # This fixes a bug on Frontier to do with allocating 0:0 arrays