Progress bar is not being written continuously in ifort while it is in gfortran

若如初见. 提交于 2020-02-01 09:09:37

问题


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.

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.

Here is the piece of code for the progress bar:

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

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

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

while when use gfortran I compile in this way:

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

in gfortran (but double precision) all works fine.


回答1:


Here's a solution:

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),'%' 


来源:https://stackoverflow.com/questions/5962009/progress-bar-is-not-being-written-continuously-in-ifort-while-it-is-in-gfortran

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!