问题描述
在Fortran中,列表导向的输出
write(*,*)
的结果依赖于编译器。实际上,用代码: 程式一
real(8),dimension(5):: (*,*)(r1(i),i = 1)b1 b1 b1(i)= sqrt(i * 10.0)
end do $ b $ 1,5)
结束程序一个
intel编译器ifort提供标准输出:
3.16227769851685 4.47213602066040 5.47722530364990
6.32455539703369 7.07106781005859
而gfortran给出了相当于一行的结果:
3.1622776601683795 4.4721359549995796 5.4772255750516612 6.3245553203367590 7.0710678118654755
我认为ifort每行最多写3个项目(浮动实数时)。
有什么办法可以让ifort输出像gfrotran一样,即避免换行符?
理想情况下,我想保持列表导向输出(*,*)
指令,所以我正在寻找类似于编译器选项的东西, 。
自从14版本开始,intel fortran编译器就有了-no-wrap-margin选项。 b
默认情况下,记录包装在80个字符之后;使用-no-wrap-margin消除了这种行为。
I have noticed the results of list-directed output write(*,*)
in Fortran is compiler dependent.
Indeed, with the code:
program one
real(8), dimension(5):: r1
do i=1,5
r1(i)=sqrt(i*10.0)
end do
write(*,*) (r1(i), i =1,5)
end program one
intel compiler ifort gives standard output broken by a newline:
3.16227769851685 4.47213602066040 5.47722530364990
6.32455539703369 7.07106781005859
while gfortran gives the equivalent one line result:
3.1622776601683795 4.4721359549995796 5.4772255750516612 6.3245553203367590 7.0710678118654755
I think that ifort is writing maximum 3 items per line (when floating real numbers).Is there any way to make the ifort output be like gfrotran, i.e. avoid the newline?Ideally, I would like to keep list-directed output (*,*)
instructions, so I am looking for something like a compiler option or so, if any.
Since verson 14, intel fortran compiler has the option -no-wrap-margin.
By default, the record is wrapped after 80 characters ; using -no-wrap-margin removes this behaviour.
这篇关于使用英特尔Fortran编译器避免在列表导向输出中使用换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!