在每次使用gfortran Fortran 90程序写入后,如何将输出刷新到文件? [英] How do I flush output to file after each write with a gfortran Fortran 90 program?

查看:510
本文介绍了在每次使用gfortran Fortran 90程序写入后,如何将输出刷新到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Fortran 90程序中运行一个循环,为循环的每次迭代输出数值到输出文件。问题是输出没有保存到文件中,而是每隔很多步骤。



示例代码:

  open(unit = 1,file ='output')

do i = 1,1000
write(1,*)i
end do
$
close(unit = 1)

预先致谢。
另一种方式,如果gfortran实现它,就是调用非标准的子程序刷新。并非所有编译器都会实现这一点。


I am running a loop in a Fortran 90 program that outputs numerical values to an output file for each iteration of the loop. The problem is that the output is not saved to the file but every so many steps. How do I get it to flush each step?

Example code:

open(unit=1,file='output')

do i = 1, 1000
 write(1,*) i
end do

close(unit=1)

Thanks in advance.

解决方案

The other way, if gfortran implements it, is to call the non-standard subroutine flush. Not all compilers do implement this.

这篇关于在每次使用gfortran Fortran 90程序写入后,如何将输出刷新到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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