本文介绍了解释Fortran写入格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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

有人可以向我解释'(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表示将n空格添加到该行; iw表示在宽度为w的字段中打印整数(因此为i); gw.p是浮点数(即非整数)的说明符,有点复杂. g表示我们将以标准浮点格式(即100.123)或E格式(1.00123E + 03)输出,以较紧凑的格式为准. w意味着我们的数字必须适合宽度w的字段,就像整数一样. p表示我们希望输出的精度,或小数点后的位数.

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写入格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 08:50