Closed Koushikphy closed 2 years ago
Since the string is so long, the command including its definition is too long. As far as I know, fprettify
is not able to split long strings into smaller bits. Thus, a manual intervention (i.e., an edit by you) is requested. For one, Fortran concatenates individual strings into a larger one by two forward slashes, //
. For two, if there is an overly long line of instruction, use a trailing &
to indicate that the command extends to the next line.
As an illustration for the concepts above with Fortran 90+:
program demo
implicit none
write (*, '(a)') "Just a very long line. Just a very long line." &
//"Just a very long line. Just a very long line. Just a very" &
//"long line. Just a very long line."
end program demo
Compared to FORTRAN 77 (character 73 [including] and beyond on a line is considered as comment irrelevant to the compiler), use the flexibility of up to 132 chars per line in the free form of contemporary Fortran with a grain of salt.*) Though we no longer use punch cards (this often) and now have computers with (on occasion multiple) wider screen(s) attached, you / your colleagues will welcome if the lines are not overly long: then, a difference view (displaying two codes side by side in separate tabs/terminals) and managing revisions e.g., in git tend to be easier. (And using GitHub to learn by the examples by others, I prefer to read the code blocks without need to use the horizontal scroll bar, too.)
(In FORTRAN 77/fixed format, the next line continuing an (ongoing) instruction already starts with char 6, instead of 7.)
*) Right of the tip of my hat, I don't recall the maximum number of times you are allowed to use the &
to extend a command over multiple lines.
Since the string is so long, the command including its definition is too long. As far as I know,
fprettify
is not able to split long strings into smaller bits. Thus, a manual intervention (i.e., an edit by you) is requested. For one, Fortran concatenates individual strings into a larger one by two forward slashes,//
. For two, if there is an overly long line of instruction, use a trailing&
to indicate that the command extends to the next line.As an illustration for the concepts above with Fortran 90+:
program demo implicit none write (*, '(a)') "Just a very long line. Just a very long line." & //"Just a very long line. Just a very long line. Just a very" & //"long line. Just a very long line." end program demo
Compared to FORTRAN 77 (character 73 [including] and beyond on a line is considered as comment irrelevant to the compiler), use the flexibility of up to 132 chars per line in the free form of contemporary Fortran with a grain of salt.*) Though we no longer use punch cards (this often) and now have computers with (on occasion multiple) wider screen(s) attached, you / your colleagues will welcome if the lines are not overly long: then, a difference view (displaying two codes side by side in separate tabs/terminals) and managing revisions e.g., in git tend to be easier. (And using GitHub to learn by the examples by others, I prefer to read the code blocks without need to use the horizontal scroll bar, too.)
(In FORTRAN 77/fixed format, the next line continuing an (ongoing) instruction already starts with char 6, instead of 7.)
*) Right of the tip of my hat, I don't recall the maximum number of times you are allowed to use the
&
to extend a command over multiple lines.
Your comment does nothing to address the problem I posted. I know the line is too long. I did it intentionally. The problem is fprettify
is doing something here that it should not be doing, i.e. dumping the errors/warning inside the source code itself. I don't know, maybe it's the problem with the VS Code extension itself.
I'm using
fprettify
in VS Code with the Modern Fortran VS Code extension. I have this VS Code setting forfprettify
And I have this sample code (for test purpose) with a very long line
Now, when I run the format document from the right click menu. This code is formatted as
i.e. the warnings are written inside the code itself. This is certainly wrong. What is going on here and how to fix it.