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

Can not start a new line in Fortran with "&" #582

Open
SharpRT opened this issue Nov 2, 2023 · 4 comments
Open

Can not start a new line in Fortran with "&" #582

SharpRT opened this issue Nov 2, 2023 · 4 comments

Comments

@SharpRT
Copy link

SharpRT commented Nov 2, 2023

Hi,

I am getting the following error:
Warning: Error parsing src/main.f90.
Can not start a new line in Fortran with "&": & world &

As far as I know, this is standard Fortran syntax for line continuation of strings.
https://stackoverflow.com/questions/16776270/line-continuation-of-strings-in-fortran

Is this something that can be fixed?

Thanks!

@ZedThree
Copy link
Member

ZedThree commented Nov 2, 2023

Oh dear, this definitely should work!

This looks like it should only happen if we think the previous line didn't end with an &. Do you have a full example I can check?

It does look like we don't actually have any tests for this, which is a mistake!

@SharpRT
Copy link
Author

SharpRT commented Nov 2, 2023

It seems to be my comment that is throwing things.
Would be nice if this worked.

write(11, ' &
    &( &
        ! row    col    day    year   sysTime   sysRate   cpuTime
        & I0, A, I0, A, I0, A, I0, A, I0, A, I0, A, f13.6, A &
    &)' &
) 

@ZedThree
Copy link
Member

ZedThree commented Nov 2, 2023

Thanks! Ah, that is quite painful: there's a comment in the middle of the string literal. Valid Fortran, but quite difficult to parse.

This might take me a little bit of time to get to, so one workaround would be to move the comment out of the string. You could put a & at the end of the comment instead

@SharpRT
Copy link
Author

SharpRT commented Nov 2, 2023

Yes, that works as a fairly pain-free workaround.
Thanks!

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

No branches or pull requests

2 participants