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

Add modern Fortran comment style #836

Merged
merged 1 commit into from
Oct 24, 2023
Merged

Add modern Fortran comment style #836

merged 1 commit into from
Oct 24, 2023

Conversation

dbroemmel
Copy link
Contributor

@dbroemmel dbroemmel commented Oct 6, 2023

The current comment style for Fortran seems to target fixed form source code, where any character in col.1 would start a comment. The character usually is "c" or ''C".
Free form source code, on the other hand, requires an "!" to start comments. Adding comments with a leading "c" is not supported if I'm not mistaken, sources would no longer compile, reuse would thus break the code.

This PR adds an additional comment style for modern free form Fortran and adjusts the selection to commonly used file extensions. While the easiest fix would have been to replace

    SINGLE_LINE = "c"

with

    SINGLE_LINE = "!"

I think it is more customary to have 'c' with fixed form source code, hence the additional style block.

Since the changes are minimal at best, I did not add a line to "AUTHORS.rst" or the copyright headers at the top of the file. If you prefer to add anything, it should be my employer "Juelich Supercomputing Centre, Forschungszentrum Juelich GmbH", possibly including my name. But I don't think any of this is necessary.

@mxmehl mxmehl added the comment-styles Request for a new comment style, or fixing a bug with these label Oct 16, 2023
Copy link
Member

@carmenbianca carmenbianca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dbroemmel ! This PR looks excellent, and thank you for the explanation.

The current comment style for Fortran seems to target fixed form source code, where any character in col.1 would start a comment. The character usually is "c" or ''C".
Free form source code, on the other hand, requires an "!" to start comments. Adding comments with a leading "c" is not supported if I'm not mistaken, sources would no longer compile, `reuse` would thus break the code.

This PR adds an additional comment style for modern free form Fortran and adjusts the selection to commonly used file extensions. While the easiest fix would have been to replace
```python
    SINGLE_LINE = "c"
```
with
```python
    SINGLE_LINE = "!"
```
I think it is more customary to have 'c' with fixed form source code, hence the additional style block.

Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
@carmenbianca carmenbianca merged commit ecd09f3 into fsfe:main Oct 24, 2023
21 checks passed
@dbroemmel
Copy link
Contributor Author

Thanks for the merge and amending the authors file!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comment-styles Request for a new comment style, or fixing a bug with these
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants