richard7 发表于 2022-3-14 15:59:19

代码无法运行

代码调试之后发现错误,改完错误之后就无法运行,执行时显示图1
调试时显示图2
别的代码可以正常运行,不知道这段代码为什么不行

program main1
implicitnone
real (kind=4) :: r,s,x,u,v,q,k,p
integer , parameter :: L=5
integer :: t
integer :: status=0
integer :: pipe
integer :: pip !用来赋值管道序号
integer :: time
real :: qo(10000,10000)
real :: x1(10000,10000)
real :: u1(10000,10000)
real :: v1(10000,10000)
real :: qw(10000,10000)
integer :: timemax(100000)

real :: ansq
real :: ansqo
real :: ansqw
real :: ww
real :: ko
real :: kw
real :: ansx
real :: sw
logical alive
write(*,*) "压差p(MPa)"
read(*,*) p
inquire(file="r.txt",exist=alive)
if(.not.alive)then
   write(*,*) "文件不存在"
   stop
end if
open(unit=10,file="r.txt")

pipe=0
do while (.true.)
   read(10,"(F9.3)",iostat=status)r
   pipe=pipe+1
if(status/=0) exit
end do
!此处读取管道个数的程序,即为pipe的大小

do pip = 1 , pipe
   x=0
   t=0
   read(10,"(F9.3)",iostat=status)r
   s=3.14*(r*0.0001/2)**2
   do while (x<=L)
   u=(5*(L-x)**2+0.75*x**2)/((l-x)**2+x**2)
   v=((r*0.000001/2))**2*p*1000000/(8*u*0.001*0.05*100)
   q=v*s
   x=x+v
   t=t+1


   qo(pip,t)=q
   x1(pip,t)=x
   u1(pip,t)=u
   v1(pip,t)=v
   timemax(pip)=t
   end do
end do
!计算某一时刻含水率
   write(*,*)"请输入时间t"

   ansq=0
   ansqo=0
   ansqw=0
   do pip = 1 , pipe
    if (time>timemax(pip)) then
       u=0.75
       v=((r*0.000001/2))**2*p*1000000/(8*u*0.001*0.05*100)
       q=v*s
       qw(pip,time)=q
    end if
   ansq=ansq+qo(pip,time)+qw(pip,time)
   ansqo=ansqo+qo(pip,time)
   ansqw=ansqw+qw(pip,time)
   end do
   ww=ansqw/ansq
   !计算相渗透率
   ko=(ansqo*5*L)/(s*p)
   kw=(ansqw*5*L)/(s*p)
   open(unit=11,file="1.txt",position="append")
   write(11,*) "ww=",ww
   close(unit=11)   
   !计算含水饱和度

   ansx=0
   do pip = 1 , pipe
    if (time>timemax(pip)) then
      x1(pip,time)= L
    end if
    ansx=ansx+x1(pip,time)
   end do
   sw=ansx/(pipe*L)
   open(unit=11,file="1.txt",position="append")
   write(11,*) "sw=",sw
   close(unit=11)




STOP
end




fcode 发表于 2022-3-15 08:29:03

静态数组太大了,
改成64位,或改成可分配数组,或设法降低数组大小的需求(比如用单变量重复使用代替数组)。

richard7 发表于 2022-3-17 11:45:54

fcode 发表于 2022-3-15 08:29
静态数组太大了,
改成64位,或改成可分配数组,或设法降低数组大小的需求(比如用单变量重复使用代替数组 ...

多谢多谢
页: [1]
查看完整版本: 代码无法运行