[Fortran] 纯文本查看 复制代码
program main1
implicit none
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