抑制 Fortran 95 写入语句中的换行符 [英] Suppressing line breaks in Fortran 95 write statements

查看:8
本文介绍了抑制 Fortran 95 写入语句中的换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 fortran 中写入标准输出而不添加换行符.也就是说,我想做这样的事情:

I would like to write to the standard output in fortran without adding a line break. That is, I want to do something like this:

a='some string and '
b='some other string'
write(*,101) a
...
write(*,102) b
...
101 format(a,...)
102 format(a)

是否可以使用某种格式语句来抑制 101 中的换行符,以便代码在同一输出行上输出some string and some other string"?

Is it possible to use some kind of format statement to supress the line break in 101, such that the code outputs "some string and some other string" on the same output line?

请注意,将两个 write 语句分开很重要,因为中间的代码实际上用于生成第二个字符串.

Note that it is important that the two write statements are separated, as the code in between is actually used to generate the second string.

推荐答案

您可以使用 advance='no' 选项:

a='some string and '
b='some other string'
write(*,101,advance='no') a
...
write(*,102) b
...
101 format(a)
102 format(a)

这将抑制换行.

这篇关于抑制 Fortran 95 写入语句中的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆