Error: Unterminated character constant beginning at (1)

Error: Unterminated character constant beginning at (1)

我想在 Fortran 代码中使用多行字符串。我试过这样做:

print *, "Line 1&
  &line 2"

但是编译文件时出现语法错误 gfortran myfile.f:

Error: Unterminated character constant beginning at (1)

如何以干净的方式拥有多行字符串?

可以使用字符串连接轻松完成。示例(在自由格式的 .f90 文件中):

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