进度条在gfortran中时不会连续在ifort中写入 [英] Progress bar is not being written continuously in ifort while it is in gfortran

查看:72
本文介绍了进度条在gfortran中时不会连续在ifort中写入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Fortran中编写了一种遗传算法,能够长时间以双精度计算通用适应度函数.第一个版本(双精度)是为gfortran编写的,其中我实现了进度条.

I have wrote a genetic algorithm in Fortran to be able to compute with a long double precision a generic fitness function. The first version (double precision) was written for gfortran where I implemented a progress bar.

现在我必须使用ifort进行编译,因为gfortran无法执行real*16计算.一切正常,但在这种情况下(便利),进度栏无法正常工作.即,仅当整个周期完成时,进度条才会打印到std输出.

Now I have to compile with ifort because gfortran is not capable of performing real*16 calculations. All works fine but in this case (ifort) the progress bar does not work properly. Namely, only when the whole cycle is completed the progress bar is printed to std output.

这是进度条的代码:

if (rate(i).gt.ratemax) then

ratemax=rate(i)

write(*,"(1x,A57,D12.4,A27,f6.2,A1)",advance="no") &

'\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b ff: ', & 

ratemax,'             Progress:',100.*real(nmix)/real(nmixing),'%'

end if

我使用64位的Intel Xeon,并且ifort的选项是:

I use an Intel Xeon of 64bit and the options for ifort are:

ifort -O2 -assume bscc FFevalLD.f90  func.o -o FFevalLD

在使用gfortran时,我以这种方式进行编译:

while when use gfortran I compile in this way:

gfortran -ffree-form -O2 -fbackslash FFeval.f func.o -o FFeval

在gfortran(但双精度)中,一切正常.

in gfortran (but double precision) all works fine.

推荐答案

这是一个解决方案:

if (rate(i).gt.ratemax) then 
  ratemax=rate(i)
  1100 format(1x,A57,D12.4,A27,f6.2,A1,$) 
  write(*,1100) &
  '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\‌​b\b\b\b\b\b\b$ ratemax,' Progress:',100.*real(nmix)/real(nmixing),'%' 

这篇关于进度条在gfortran中时不会连续在ifort中写入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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