ford icon indicating copy to clipboard operation
ford copied to clipboard

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

Open SharpRT opened this issue 2 years ago • 4 comments

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!

SharpRT avatar Nov 02 '23 16:11 SharpRT

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!

ZedThree avatar Nov 02 '23 16:11 ZedThree

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 &
    &)' &
) 

SharpRT avatar Nov 02 '23 16:11 SharpRT

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

ZedThree avatar Nov 02 '23 16:11 ZedThree

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

SharpRT avatar Nov 02 '23 17:11 SharpRT