Continuing lines

I have the following line of code…

write(6,201) i, TIME, DTIME, CorM, CorR, CorL, accL + CorL, fluxM, corM / solmass

Due to it’s length (and as an experiment in the use of continuation lines to confirm my understanding) I tried to spread this over two lines.

I have tried this…

write(6,201) i, TIME, DTIME, CorM, CorR, CorL, &
& accL + CorL, fluxM, corM / solmass

…with the ampersands…

  • one character away from the first/last character
  • at column 73 (first one) and column 6 (second one)

I have also tried this…

write(6,201) i, TIME, DTIME, CorM, CorR, CorL, &
accL + CorL, fluxM, corM / solmass

With the ampersand being

  • at 73
  • just after the final character
  • at a distance from the final character (to keep things consistent and pretty)

No matter what I do I now get this error message…

  283 |             write(6,201) i, TIME, DTIME, CorM, CorR, CorL, &
      |                                                            1
Error: Expected expression in WRITE statement at (1)

I have just undertaken a fresh install of GNU Fortran, with the --version being reported as 11.1.0

Anyone any ideas where I am going wrong?

What suffix does your source file have? By default, Fortran compilers assume .f and .for files are fixed source form.

Please excuse me for not directly answering your question, which pertains to continuation lines in fixed source form, but I suggest converting to free source form with fortran-legacy-tools or another tool listed here. The rules for continuation lines in free source form are simple.

2 Likes

Thank you! :slight_smile: :grin:

After re-reading your reply I realised you answered my question fully.

I was hoping to find out how to move to free-form Fortran and followed your links.

Though the tools are useful, I am happy to simply rename my file dummymain.f90 and go through and make the changes I need to.

Thank you once again; I am most grateful. :slight_smile:

To make source continuation lines that work with both fixed and free, start statements at column 7, put an ampersand at column 73-80 (where it should be ignored by fixed form but mark a continuation in free form). On the second line, put an ampersand at column 6 (where it will be interpreted as a fixed form continuation and as a second continuation marker in free form).

3 Likes

I thought I had tried this but clearly not!

What this conversation has given me are the tools to get the code running and tested, to make sure the changes I have made haven’t made the program fail (via your comment) and a target to convert to free-form (thanks to Beliavsky).

Thanks to the both of you! :slight_smile: