我正在尝试编写一个 fortran 代码,但是当我尝试将数据从子程序中的一个变量传递到另一个变量时,错误是:common /c/kf,eff,q
1 Warning: Padding of 4 bytes required before 'q ' 在 (1) 处的常见 'c' 中;重新排序元素或使用 -fno-align-commons。
从子程序输入到计算的 q 值没有被传递。如果子程序输入时q的值为5e-3,则子程序计算时q的值为3.57e-315
请帮助
查看代码
implicit none
call input
call calculation
stop
end
subroutine input
real*8 n
real*8 l1,l2,l3,d,kf,eff,z1,z2,rho,mu,pin,pout,l4
common /a/l1,l2,l3,l4,d
common /c/kf,eff,q
common /e/z1,z2
common /d/rho,mu,pin,pout
common /b/n
print*,"enter the lengths of the pipe at various sections (4)"
read(*,*) l1,l2,l3,l4
print*,"enter the diameter of the pipe"
read(*,*) d
print*,"enter the volumetric flow rate (m3/s)"
read(*,*) q
print*,"enter the number of elbows to be added"
read(*,*) n
print*,"enter firction coefficient for elbow"
read(*,*) kf
print*,"enter the pump efficiency"
read(*,*) eff
print*,"enter the datum height (m)"
read(*,*)z1
print*,"enter the final height (m)"
read(*,*)z2
print*,"enter the density of the fluid (kg/m3)"
read(*,*)rho
print*,"enter the viscosity of the fluid (kg/ms)"
read(*,*)mu
print*,"enter the inlet and exit pressure (KPa)"
read(*,*) pin,pout
print*,q
end
subroutine calculation
real*8 n
real*8 g,pi,v2,v1,vdif,z2,z1,head,v,q,d
real*8 p,pout,pin,rho,re,mu,f,kc,hc,kf,hf
real*8 kex,hex,l,l1,l2,l3,l4,fp,ft,Ws,Wp,m,power
common /a/l1,l2,l3,l4,d
common /c/kf,eff,q
common /e/z1,z2
common /d/rho,mu,pin,pout
common /b/n
parameter (g=9.8,pi=3.14)
print*,q,d
v= (4*q)!/(pi*(d**2))
v1=v
v2=v
vdif=0.5*((v2**2)-(v1**2))
head=g*(z2-z1)
p=(pout-pin)/(rho)
re=(d*v*rho)/(mu)
print*,v,vdif,p,head,re
if (re>2000) then
f=16/re
else
f=0.079*(re**(-0.25))
endif
kc=0.55
hc=kc*(v**2)/2
hf=n*kf*(v**2)/2
kex=1
hex=kex*(v**2)/2
l=l1+l2+l3+l4
fp=(4*f*l*(v**2))/(2*d)
ft=hc+hf+hex+fp
Ws=-head-vdif-ft
Wp=-(Ws/eff)
m=q*rho
power=m*Wp
print*, "the power required by the pump is", power
end