如何在Fortran 90中刷新stdout? [英] How to flush stdout in Fortran 90?

查看:256
本文介绍了如何在Fortran 90中刷新stdout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上看到很多在Fortran中使用 flush 函数来刷新输出。我想知道,特别是对于Fortran 90,特别是对于stdout来说,这应该作为一个单独的代码放入我的代码中吗?



我的猜测是 flush(*)

解决方案 不是一个函数,而是一个非标准的内部子例程,因此在调用语句中调用

 调用flush(unit_number)

或Fortran 2003中的标准语句,因此被调用为语句

  flush(unit_number)

通常,标准输出预先连接到单元6,但要确保可以使用模块中的标准常量 output_unit iso_fortran_env (请参阅标准输入和输出单元Fortran 90?



再次要求Fortran 2003。



请注意,现在几乎所有的编译器都支持这些功能。但是,如果您确实需要26岁的Fortran 90,那么您必须查阅编译器的手册,了解它用于预连接文件的单元编号。标准输出很可能是6。


I see a lot online on using the flush function in Fortran to flush output. I am wondering, specifically for Fortran 90, and specifically for stdout, what form this should take as a one-liner to put into my code?

My guess is flush(*).

解决方案

flush() is not a function, but either a non-standard intrinsic subroutine, and hence invoked in a call statement

 call flush(unit_number)

or a standard statement in Fortran 2003, hence invoked as a statement

flush(unit_number)

Commonly, standard output is pre-connected to unit 6, but to be sure you can use the standard constant output_unit from module iso_fortran_env (see Standard input and output units in Fortran 90?)

That again requires Fortran 2003.

Note that almost any compiler nowadays supports these features. But if you really specifically need the 26 years old Fortran 90, then you must consult your compiler's manual, which unit numbers it uses for the pre-connected files. Very likely it will be 6 for standard output.

这篇关于如何在Fortran 90中刷新stdout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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