[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 , allocatable :: qo(:,:)
real , allocatable :: x1(:,:)
real , allocatable :: u1(:,:)
real , allocatable :: v1(:,:)
real , allocatable :: qw(:,:)
real , allocatable :: qmix(:,:)
integer , allocatable :: timemax(:)
real (kind=4) :: ansq
real (kind=4) :: ansqo
real (kind=4) :: ansqw
real (kind=4) :: ww
real (kind=4) :: ko
real (kind=4) :: kw
real (kind=4) :: ansx
real (kind=4) :: 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
if(status/=0) exit
pipe=pipe+1
end do
!此处读取管道个数的程序,即为pipe的大小
allocate(qo(pip,t))
allocate(qw(pip,t))
allocate(qmix(pip,t))
allocate(x1(pip,t))
allocate(u1(pip,t))
allocate(v1(pip,t))
allocate(timemax(pipe))
open (unit=10,file="r.txt")
rewind(10)
do pip = 1 , pipe
x=0
t=0
read(10,"(F9.3)",iostat=status)r
s=3.14*(r*0.0001/2)**2
write(*,*) r
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
qmix(pip,t)=q
x1(pip,t)=x
u1(pip,t)=u
v1(pip,t)=v
timemax(pip)=t
end do
end do
write(*,*) x1(1,1)
write(*,*)"请输入管道序号及时间"
read(*,*)pip,t
write(*,*) x1(pip,t)