声明实数时,Fortran不会使用“ OPEN”语句创建文件

时间:2019-02-07 20:27:30

标签: fortran

因此,我正在尝试编写此代码,以评估Fortran 77中的S = 1 + x ^ 2 + x ^ 3 + ... x ^ 10系列。

     Program prob_2
C    Sum of series
     implicit none
     integer i
     real S, x
     S = 0.0
     x = 0.99
     open(8, file='output2.dat')
     do i=1,10,1
       S = S+(x**i)
     end do
     write(8, 100) S
100  format('Sum =', F15.4)
     close(8)
     Stop
     end

代码运行没有错误,但是没有创建output2.dat文件。当我将S和x更改为整数(使x = 1)时,它将创建文件。我在做什么错了?

0 个答案:

没有答案