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

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

问题描述

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

$ p $ a ='一些字符串和'
b ='其他字符串'
写(*,101)a
...
写(*,102)b
...
101格式(a,... )
102格式(a)

是否可以使用某种格式语句在101中抑制换行,这样代码在同一输出行上输出一些字符串和其他字符串?

请注意,这两个写语句是分开的,因为中间的代码实际上是用来生成第二个字符串的。您可以使用 advance ='no'选项: / b>

  a ='一些字符串和'
b ='一些其他的字符串'
write(*,101, (a)
102格式(a)
格式(a)
格式(a)

这将抑制换行。


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)

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?

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.

解决方案

You can used the advance='no' option:

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

This will suppress the linebreak.

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

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