解释Fortran写入格式 [英] Explaining Fortran Write Format
问题描述
我是fortran90的初学者.现在,我正在尝试学习fortran代码,但不清楚写入格式的说明
I am a beginner of fortran90. Now I am trying to learn fortran code and I am not clear with the description of the write format
write(*,'((2x,i4,2x,g14.6,2x,14x,2x,g14.6)')0,unew_norm,错误
write ( *, '(2x,i4,2x,g14.6,2x,14x,2x,g14.6)' ) 0, unew_norm, error
有人可以向我解释'(2x,i4,2x,g14.6,2x,14x,2x,g14.6)'
的意思是什么.
Can anybody explain to me what does '(2x,i4,2x,g14.6,2x,14x,2x,g14.6)'
stuff mean.
很高兴教我一些虚拟的东西.
It would be very nice to teach me the dummy things.
最佳
推荐答案
nX
means that n
spaces are added to the line; iw
means that an integer (hence the i
) is printed in a field w
spaces wide; gw.p
is a specifier for a floating point number (i.e. not an integer) and is a little more complicated. g
means that we will output in either standard floating point format (i.e. 100.123) or in E format (1.00123E+03), whichever is more compact. w
means that our number has to fit in a field of width w
, just like with the integer. The p
indicates how much precision we want in the output, or the number of digits after the decimal point.
在您的情况下,格式说明符'(2x,i4,2x,g14.6,2x,14x,2x,g14.6)'
表示2个空格,宽度为4的整数,2个空格,宽度为14且精度为6的浮点,2个空格,14个空格,2个空格,宽度为14且精度为14的浮点6.
In your case, the format specifier '(2x,i4,2x,g14.6,2x,14x,2x,g14.6)'
means 2 spaces, integer with width 4, 2 spaces, floating point with width 14 and precision 6, 2 spaces, 14 spaces, 2 spaces, floating point with width 14 and precision 6.
希望有帮助!
这篇关于解释Fortran写入格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!