0

我希望在 Fortran 中写一段文本,其中包含一些故障排除信息,这需要几行,如下所示:

/!\  Troubleshooting! /!\

Seems your input is not formatted properly!
Accepted keywords are:
value1
value2
value3
value4

一个简单的方法是:

write(*,*)'/!\  Troubleshooting! /!\'
write(*,*)''    
write(*,*)'Seems your input is not formatted properly!'
write(*,*)'Accepted keywords are:'
write(*,*)'value1'
write(*,*)'value2'
write(*,*)'value3'
write(*,*)'value4'

我可以在一个写语句中转储所有文本,没错,但这会导致阅读混乱!

write(*,'(A)')'/!\  Troubleshooting! /!\    &
Seems your input is not formatted properly! &  
Accepted keywords are:                      &
value1                                      &
value2                                      &
value3                                      &
value4                                      &

像这样!

strelok@Yggdrasil:~$ ./write.exe
/!\  Troubleshooting! /!\     Seems your input is not formatted properly! Accepted keywords are:                       value1                                      value2                                      value3                                      value4

但我希望有更多……有趣的东西!实际上,我希望文本中的单个 WRITE 语句有一些换行符(无需编写新的 WRITE 语句!),因此它可以通过多种方式以“格式化”方式产生!

有什么建议么?

4

1 回答 1

1

您可以插入new_line('A')字符,请参阅https://gcc.gnu.org/onlinedocs/gfortran/NEW_005fLINE.html

write(*,'(A)')'/!\  Troubleshooting! /!\//new_line('A')//&
Seems your input is not formatted properly!//new_line('A')//&  
...
于 2020-08-24T08:34:44.373 回答