Ionică Bizău
Ionică Bizău

Reputation: 113355

Error: Unterminated character constant beginning at (1)

I want to have a multiline string in Fortran code. I tried to do it this way:

print *, "Line 1&
  &line 2"

But it gives me syntax errors when compiling the file gfortran myfile.f:

Error: Unterminated character constant beginning at (1)

How can I have multiline strings in a clean way?

Upvotes: 4

Views: 11320

Answers (1)

Time Laird
Time Laird

Reputation: 179

Can be easily done using string concatenation. Example (in a free-form .f90 file):

write(*,'(A)') 'Line 1'//&
               'line 2'//&
               'and so forth'

Upvotes: 4

Related Questions