Skip to content
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

Check if variables set by DATA statements could be made named constants (parameters) #237

Open
Beliavsky opened this issue Dec 14, 2024 · 1 comment
Labels
rule A new rule for the linter

Comments

@Beliavsky
Copy link

Many old codes set variables that never changed and could be named constants using the DATA statement. I suggest that Fortitude warn about such code and eventually have the ability to fix it by declaring the variables as parameter. An example of code that could be rewritten this way is at https://github.com/UoA-Stars-And-Supernovae/STARS/blob/master/src/diffusion2.f -- variables BARYN AND MIZZ could have the parameter attribute.

@ZedThree ZedThree added the rule A new rule for the linter label Dec 16, 2024
@ZedThree
Copy link
Member

I guess we can do this in the case where the variable isn't used in a common block, doesn't appear on the left hand side of an assignment, and also isn't passed to any subroutine or function calls -- in the future, if we have more semantic information, we might be able to check the intents, and follow uses through common blocks.

At that point, we might also be able to do similar analysis for all variables (although potentially this is an expensive check!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule A new rule for the linter
Projects
None yet
Development

No branches or pull requests

2 participants