Skip to content

Add more break points for long lines#727

Merged
mkavulich merged 6 commits into
NCAR:developfrom
gold2718:fix_breaks
Apr 6, 2026
Merged

Add more break points for long lines#727
mkavulich merged 6 commits into
NCAR:developfrom
gold2718:fix_breaks

Conversation

@gold2718

Copy link
Copy Markdown
Collaborator

Some long lines are still broken incorrectly

Some long lines are still broken into invalid Fortran. This PR addresses this by adding more non-ID characters to the allowed break points (currently only spaces and commas).

User interface changes?: No

Fixes: TBA

Testing:
test removed:
unit tests:
system tests:
manual testing:

@gold2718

Copy link
Copy Markdown
Collaborator Author

@climbfuji, The latest Codee failure seems to be a mismatch between the default settings of the FortranWriter class and what Codee expects. Am I seeing that correctly? If so, I suggest we either modify Codee's expectations or the FortranWriter class defaults (e.g., __INDENT, __CONTINUE_INDENT, etc.). Thoughts?

Note, linebreak_test.F90 now compiles with no warnings so this is just a formatting issue.

@gold2718

Copy link
Copy Markdown
Collaborator Author

Another Codee comment. While I can match most of Codee's formatting expectations by setting __INDENT = 2, __CONTINUE_INDENT = 4, lowercasing CONTAINS, and minimizing the spacing before the continue character, Codee expects spaces around operators. Unfortunately, this defeats the purpose of the test which is how to break lines when spaces are not present.

Ironically, if capgen had been generating Codee-approved Fortran, @jimmielin would never have seen the bug he reported in #724 🤷.

@climbfuji

Copy link
Copy Markdown
Collaborator

Another Codee comment. While I can match most of Codee's formatting expectations by setting __INDENT = 2, __CONTINUE_INDENT = 4, lowercasing CONTAINS, and minimizing the spacing before the continue character, Codee expects spaces around operators. Unfortunately, this defeats the purpose of the test which is how to break lines when spaces are not present.

Ironically, if capgen had been generating Codee-approved Fortran, @jimmielin would never have seen the bug he reported in #724 🤷.

We had a similar issue with another test (#722; comment #722 (comment)). If you want to preserve formatting for certain parts of the code, you can wrap those lines in

! codee format off
...
! codee format on

See c221aaf

@climbfuji climbfuji left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

try this please

name079, name080, name081, name082, name083, name084, name085, name086, name087, &
name088, name089, name090, name091, name092, name093, name094, name095, name096, &
name097, name098, name099 /)
character(len=7) :: data(100) = (/ 'name000', 'name001', 'name002', 'name003', 'name004', &

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
character(len=7) :: data(100) = (/ 'name000', 'name001', 'name002', 'name003', 'name004', &
! codee format off
character(len=7) :: data(100) = (/ 'name000', 'name001', 'name002', 'name003', 'name004', &

'Cannot read columns_on_task from file'// &
', columns_on_task has no horizontal dimension; columns_on_task is a protected variable'

end subroutine foo

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
end subroutine foo
end subroutine foo
! codee format on

Add missing spaces in host cap (for Codee).
@climbfuji

Copy link
Copy Markdown
Collaborator

Update 2026/04/03. This PR is included in #732. When #732 gets merged, this PR will be automatically closed as merged.

@gold2718

gold2718 commented Apr 5, 2026

Copy link
Copy Markdown
Collaborator Author

I managed to fix the Fortran writer to pass these tests. The two sections that are Codee commented out are purposefully bad Fortran lines to make sure the writer can still break them legally. While #732 avoids the previous problems with this PR, I think the new version helps move the Fortran writer closer to being Codee compliant.

@gold2718 gold2718 requested a review from climbfuji April 5, 2026 20:42
@climbfuji

Copy link
Copy Markdown
Collaborator

I managed to fix the Fortran writer to pass these tests. The two sections that are Codee commented out are purposefully bad Fortran lines to make sure the writer can still break them legally. While #732 avoids the previous problems with this PR, I think the new version helps move the Fortran writer closer to being Codee compliant.

I agree. I propose to merge #727 and then update #732 to make the list of excluded files in the GitHub workflow an empty list for now. It's nice to have the capability to exclude individual files entirely.

@mkavulich mkavulich left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. @climbfuji I assume we can go ahead and merge this PR then?

@gold2718

gold2718 commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator Author

I agree. I propose to merge #727 and then update #732 to make the list of excluded files in the GitHub workflow an empty list for now. It's nice to have the capability to exclude individual files entirely.

This sounds like a good idea although aside from testing line breaking, I can't think of any reasons we would want to generate non-compliant code.

@climbfuji

Copy link
Copy Markdown
Collaborator

I agree. I propose to merge #727 and then update #732 to make the list of excluded files in the GitHub workflow an empty list for now. It's nice to have the capability to exclude individual files entirely.

This sounds like a good idea although aside from testing line breaking, I can't think of any reasons we would want to generate non-compliant code.

One reason that we are hitting with the NEPTUNE code base is not related to non-compliant code, but to bugs that we identified in the Codee formatter itself. We report those back and the team needs a bit of time to fix them and release a new version. In the meantime, we exclude those files from formatting.

@climbfuji

Copy link
Copy Markdown
Collaborator

LGTM. @climbfuji I assume we can go ahead and merge this PR then?

Yes please

@mkavulich mkavulich merged commit 7db88e5 into NCAR:develop Apr 6, 2026
15 checks passed
@gold2718 gold2718 deleted the fix_breaks branch April 6, 2026 21:51
mkavulich pushed a commit that referenced this pull request Apr 8, 2026
…ing in GitHub actions (#732)

## Description

This PR adds the capability to exclude individual Fortran files from
Codee formatting in GitHub actions. This was originally motivated by
issues with making the Fortran writer Codee compliant (PR #727). These
issues were resolved, but there are scenarios were excluding individual
files from Codee formatting checks may be needed (see comments in #727).

User interface changes?: No

## Issues

N/A

## Testing

Testing: **all pass** (only updates to existing tests, no new tests, no
tests removed)

## Additional information

See comments in #727

---------

Co-authored-by: Steve Goldhaber <gold2718@gmail.com>
Co-authored-by: Haipeng Lin <hplin@ucar.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants