-
Notifications
You must be signed in to change notification settings - Fork 111
Fix masked variables from parent scope #959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes instances of variable masking from parent scope throughout the MFC codebase. Variable masking occurs when local variables or parameters in subroutines have the same name as variables from the module or parent scope, which can lead to confusion and potential bugs. The changes rename these variables with more descriptive names (often adding suffixes like _in
, _out
, _local
) to avoid masking.
- Renames procedure parameters to avoid masking module-level variables
- Updates local variable names to prevent conflicts with parent scope
- Ensures consistent naming patterns while maintaining functionality
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/simulation/m_time_steppers.fpp | Renames parameters in bubble computation and body forces routines |
src/simulation/m_rhs.fpp | Updates parameter names in RHS computation and physics routines |
src/simulation/m_ibm.fpp | Renames variables in IBM state correction and ghost point routines |
src/simulation/m_hyperelastic.fpp | Updates tensor parameter names in stress computation |
src/simulation/m_data_output.fpp | Renames center of mass parameter and removes blank line |
src/simulation/m_bubbles_EL.fpp | Updates local variable name in bubble frequency computation |
src/simulation/m_bubbles_EE.fpp | Renames parameters in bubble source computation |
src/simulation/m_bubbles.fpp | Updates bubble property computation parameter names |
src/pre_process/m_start_up.fpp | Renames parameters in data file reading routines |
src/pre_process/m_patches.fpp | Updates variable names in patch geometry routines |
src/post_process/m_data_input.f90 | Renames array allocation parameter |
src/common/m_mpi_common.fpp | Updates MPI communication parameter names |
src/common/m_helper.fpp | Renames various utility function parameters |
src/common/m_finite_differences.fpp | Updates finite difference parameter name |
src/common/m_boundary_common.fpp | Renames boundary condition parameter names |
.cursor/rules/mfc-agent-rules.mdc | Minor formatting and documentation updates |
Comments suppressed due to low confidence (2)
src/simulation/m_bubbles_EL.fpp:296
- [nitpick] The variable name 'omegaN_local' follows an inconsistent naming pattern. Consider using 'omega_n_local' to align with Fortran naming conventions.
real(wp) :: omegaN_local, PeG, PeT, rhol, pcrit, qv, gamma, pi_inf, dynP
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #959 +/- ##
=======================================
Coverage 44.08% 44.08%
=======================================
Files 69 69
Lines 19573 19573
Branches 2428 2428
=======================================
Hits 8628 8628
Misses 9444 9444
Partials 1501 1501 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
User description
For a long time, we have had the issue of masked variables from the parent scope. I'm not sure if this has caused bugs or not, but it certainly isn't good practice. This PR fixes the issue.
PR Type
Bug fix, Documentation
Description
• Fixed variable masking issues across multiple modules by renaming parameters and local variables to avoid conflicts with parent scope
• Renamed parameters like
pb
topb_in
,mv
tomv_in
, and added_local
or_in
suffixes to prevent variable shadowing• Updated function signatures and parameter names in critical modules including RHS computation, boundary conditions, IBM, bubble dynamics, and MPI communication
• Fixed parameter masking in time stepping, data output, and finite difference computation routines
• Updated documentation formatting and fixed typos in agent rules file
Diagram Walkthrough
File Walkthrough
15 files
m_patches.fpp
Fix variable masking in patch geometry subroutines
src/pre_process/m_patches.fpp
• Renamed parameter
ib
toib_flag
in multiple subroutines to avoidvariable name conflicts
• Renamed variable
ca
toca_in
inairfoil-related subroutines to prevent masking
• Renamed local
variables like
x_centroid
,y_centroid
,eta
,smooth_coeff
to include_local
suffix• Renamed
non_axis_sym
tonon_axis_sym_in
to avoid scopeconflicts
m_boundary_common.fpp
Resolve parameter name conflicts in boundary condition routines
src/common/m_boundary_common.fpp
• Renamed parameters
pb
andmv
topb_in
andmv_in
in multiple boundarycondition subroutines
• Updated all references to use the new
parameter names throughout the file
• Renamed
old_grid
parameter toold_grid_in
in boundary condition file writing functionm_ibm.fpp
Fix variable masking in immersed boundary method functions
src/simulation/m_ibm.fpp
• Renamed
pb
andmv
parameters topb_in
andmv_in
in IBM correctionsubroutines
• Renamed function parameters like
ghost_points
,levelset
,levelset_norm
with_in
suffix• Updated variable names like
num_gps
tonum_gps_out
for output parametersm_rhs.fpp
Resolve variable name masking in RHS computation module
src/simulation/m_rhs.fpp
• Renamed
pb
andmv
parameters topb_in
andmv_in
in RHS computationfunctions
• Renamed
flux_src_n
parameter toflux_src_n_in
to avoidconflicts
• Fixed incorrect variable reference in additional physics
RHS computation
m_helper.fpp
Fix variable name conflicts in helper utility functions
src/common/m_helper.fpp
• Renamed local variables
m
,n
tolocal_m
,local_n
in matrix printingfunction
• Renamed function parameters like
weight
,R0
tolocal_weight
,local_R0
• Renamed variables in mathematical functions
to avoid conflicts with global scope
• Updated parameter names in
transformation and polynomial functions
m_mpi_common.fpp
Resolve variable masking in MPI communication routines
src/common/m_mpi_common.fpp
• Renamed
ierr
tolocal_ierr
in MPI communication functions• Renamed
pb
andmv
parameters topb_in
andmv_in
in MPI buffer operations•
Updated all references to use the new parameter names consistently
m_start_up.fpp
Fix parameter name masking in startup data reading functions
src/pre_process/m_start_up.fpp
• Renamed function parameters
q_cons_vf
andib_markers
to include_in
suffix
• Updated parameter names in both serial and parallel IC data
file reading functions
• Maintained consistency in parameter naming
across abstract interface definitions
m_bubbles_EE.fpp
Fix variable masking in bubble computation subroutines
src/simulation/m_bubbles_EE.fpp
• Renamed parameter
divu
todivu_in
in subroutines_compute_bubbles_EE_rhs
to avoid variable masking• Added
divu_in
parameter to
s_compute_bubble_EE_source
subroutine signature• Renamed
local variables
pb
andmv
topb_local
andmv_local
to prevent scopemasking
• Updated all references to use the new parameter and variable
names
m_hyperelastic.fpp
Rename btensor parameter to prevent variable masking
src/simulation/m_hyperelastic.fpp
• Renamed parameter
btensor
tobtensor_in
in boths_neoHookean_cauchy_solver
ands_Mooney_Rivlin_cauchy_solver
• Updated
all references to use the new parameter name
btensor_in
• Maintains
same functionality while avoiding variable name conflicts
m_bubbles_EL.fpp
Fix omegaN variable masking in bubble frequency calculation
src/simulation/m_bubbles_EL.fpp
• Renamed local variable
omegaN
toomegaN_local
to avoid masking fromparent scope
• Updated all references to use the new variable name
m_bubbles.fpp
Rename parameters in bubble wall property subroutine
src/simulation/m_bubbles.fpp
• Renamed parameter
pb
topb_in
ins_bwproperty
subroutine• Renamed
output parameters to include
_out
suffix:chi_vw_out
,k_mw_out
,rho_mw_out
• Updated all references to use the new parameter names
m_data_output.fpp
Fix parameter masking in center of mass output subroutine
src/simulation/m_data_output.fpp
• Removed empty line at beginning of file
• Renamed parameter
c_mass
to
c_mass_in
ins_write_com_files
subroutine• Updated all references
to use the new parameter name
m_time_steppers.fpp
Fix parameter masking in time stepping subroutines
src/simulation/m_time_steppers.fpp
• Added
divu
parameter tos_compute_bubble_EE_source
function call•
Renamed parameters in
s_apply_bodyforces
fromq_prim_vf
andrhs_vf
toq_prim_vf_in
andrhs_vf_in
• Updated all references to use the new
parameter names
m_data_input.f90
Rename start_idx parameter to prevent variable masking
src/post_process/m_data_input.f90
• Renamed parameter
start_idx
tolocal_start_idx
ins_allocate_field_arrays
subroutine• Updated all references to use the
new parameter name
m_finite_differences.fpp
Fix buffer size parameter masking in finite differences
src/common/m_finite_differences.fpp
• Renamed parameter
buff_size
tolocal_buff_size
ins_compute_finite_difference_coefficients
• Updated array dimension
declaration to use the new parameter name
1 files
mfc-agent-rules.mdc
Update documentation formatting and fix typos in agent rules
.cursor/rules/mfc-agent-rules.mdc
• Fixed YAML front matter formatting by changing dashes to proper YAML
format
• Fixed typo: "respository" to "repository"
• Reorganized
sections and improved GPU programming guidelines documentation
•
Enhanced error handling documentation with clearer examples