我的代码如下,我一直收到以下错误屏幕。我真的很感激我能得到的任何帮助。谢谢!
ERROR:
Quasi1DEuler.f90:79.13:
Q =(0,P(i)*(Sr-S1),0) 1 错误:在(1)
处的复数常量中预期的PARAMETER符号Quasi1DEuler.f90:184.25:
DOUBLE PRECISION FUNCTION Flux(W1,W2) Result(FluxArray(3,1))
1
Error: Syntax error in data declaration at (1)
Quasi1DEuler.f90:9.20:
PROGRAM Quasi1DEuler
1
Quasi1DEuler.f90:185.15:
USE parameters
2
Error: Two main PROGRAMs at (1) and (2)
CODE:
MODULE parameters
DOUBLE PRECISION, PARAMETER::h=.15, t1=.8, t2=3
DOUBLE PRECISION, PARAMETER::gamma_constant=1.4, eps=.15
DOUBLE PRECISION, PARAMETER:: tol=10**(-16), pi=3.14159265358979323
DOUBLE PRECISION, PARAMETER:: P_t=2117, T_t=531.2, R=1716
END MODULE parameters
PROGRAM Quasi1DEuler
USE parameters
IMPLICIT NONE
INTEGER, PARAMETER::gridpoints=50, maxiter=20000
DOUBLE PRECISION, PARAMETER:: ExitPressureRatio=.7,dx=1/gridpoints
DOUBLE PRECISION, PARAMETER:: cv=R/(gamma_constant-1), CFL=.4
DOUBLE PRECISION, PARAMETER:: Pexit=P_t*ExitPressureRatio
DOUBLE PRECISION:: Minf=1.2
DOUBLE PRECISION:: residue=1, S, Flux, Ms
DOUBLE PRECISION:: IsentropicTemperature, IsentropicPressure
DOUBLE PRECISION, DIMENSION(gridpoints):: X, M, P, u, c, rho
DOUBLE PRECISION, DIMENSION(3, gridpoints)::W, Res, W_temp
DOUBLE PRECISION, DIMENSION(maxiter):: iterations, residual
DOUBLE PRECISION:: T_initial,P_initial,rho_initial,c_initial
DOUBLE PRECISION:: u_initial, Energy, a, V, Sl, Sr, Fr, Fl, dt
DOUBLE PRECISION:: dt_inlet, dp_du, Lambda, Lambda_1,Lambda_2
DOUBLE PRECISION:: Lambda_3, dt_exit, Q(3),du_inlet, R1, R2, R3
DOUBLE PRECISION:: d_p, d_rho, d_u, T_exit, Energy_exit, T_inlet
INTEGER::k=1, i
!Initialization
IF (Pexit==0) THEN
Ms=Minf
ELSE
Ms=sqrt(2/(gamma_constant-1)*((Pexit/P_t)**(-(gamma_con&
&stant-1)/gamma_constant)-1))
END IF
DATA iterations /maxiter*0/
DATA residual /maxiter*0/
DO i=1,gridpoints,1
M(i)=Ms
END DO
Minf = Ms;
T_initial = isentropicTemperature(Minf)
P_initial = isentropicPressure(Minf)
rho_initial=P_initial/(R*T_initial)
c_initial=sqrt(gamma_constant*P_initial/rho_initial)
u_initial=Minf*c_initial
DO i=1,gridpoints,1
P(i)=P_initial
rho(i)=rho_initial
c(i)=c_initial
u(i)=u_initial
END DO
Energy = P(1)/(gamma_constant-1)+.5*rho(1)*u(1)**2
a = sqrt(2*gamma_constant*(gamma_constant-1)/(gamma_con&
&stant+1)*cv*T_t)
DO i=1,gridpoints,1
W(1,i)= rho(1)
W(2,i)= rho(1)*u(1)
W(3,i)= Energy
END DO
DO i=1,gridpoints,1
X(i)=(i-.5)*dx
END DO
!let us begin the loop------------------------------------------------------------
DO WHILE ((k<maxiter) .AND. (residue>tol)) !entire loop
DO i=2,gridpoints-1,1 !scheme
Sl = .5*(S(X(i))+S(X(i-1)))
Sr = .5*(S(X(i))+S(X(i+1)))
Q = (0, P(i)*(Sr-Sl), 0)
V = .5*(Sr+Sl)*dx
u(i) = W(i,2)/W(i,1)
dt = CFL*dx/u(i)
Fr = Flux(W(i,:),W(i+1,:))
Fl = Flux(W(i-1,:),W(i,:))
Res(:,i) = (Fr*Sr-Fl*Sl)-Q
W(:,i) = W_temp(:,i)-(dt/V)*Res(:,i)
END DO !end scheme
DO i=2,gridpoints-1,1 !update vectors
P(i) = (gamma_constant-1)*(W(3,i)-.5*W(2,i)**&
2/W(1,i))
rho(i) = W(1,i)
u(i) = W(2,i)/rho(i)
c(i) = sqrt((gamma_constant*P(i)/rho(i)))
M(i) = u(i)/c(i)
END DO !end vector update
If (Minf<1) THEN !inlet condition
dt_inlet = CFL*dx/(u(1)+c(1))
dp_du = P_t*gamma_constant/(gamma_constant-1)&
*(1-(gamma_constant-1)/(gamma_constant+1)*u(1)**2/a**2)&
**(1/(gamma_constant-1))*(-2*(gamma_constant-1)/&
(gamma_constant+1)*u(1)/a**2)
Lambda = .5*((u(1)+u(2))-(c(2)+c(1)))*(dt_inlet/dx)
du_inlet = -Lambda*(P(2)-P(1)-rho(1)*c(1)*(u(2)-u(1)))/&
(dp_du-rho(1)*c(1))
u(1) = u(1)+du_inlet
T_inlet = T_t*(1-(gamma_constant-1)/(gamma_constant+1&
)*u(1)**2/a**2)
P(1) = P_t*(T_inlet/T_t)**(gamma_constant/(gamma_c&
&onstant-1))
rho(1) = P(1)/(R*T_inlet)
Energy = rho(1)*(cv*T_inlet+.5*u(1)**2)
c(1) = sqrt(gamma_constant*P(1)/rho(1))
M(1) = u(1)/c(1)
W(1,:) = [rho(1), rho(1)*u(1), Energy]
END IF !end inlet condition
!exit condition
dt_exit= CFL*dx/(u(gridpoints)+c(gridpoints))
!Eigenvalues
Lambda_1 = (u(gridpoints)+u(gridpoints-1))/2 * dt_exit/dx
Lambda_2 = ((u(gridpoints)+u(gridpoints-1))/2 + (c(gridpoin&
&ts)+c(gridpoints-1))/2) * dt_exit/dx
Lambda_3 = ((u(gridpoints)+u(gridpoints-1))/2 - (c(gridpoin&
&ts)+c(gridpoints-1))/2) * dt_exit/dx
! Compute Characteristic Relations
R1 = -Lambda_1*(rho(gridpoints)-rho(gridpoints-1) - 1/c(gri&
&dpoints)**2*(P(gridpoints)-P(gridpoints-1)))
R2 = -Lambda_2*(P(gridpoints)-P(gridpoints-1) + rho(gridpoi&
&nts)*c(gridpoints)*(u(gridpoints)-u(gridpoints-1)))
R3 = -Lambda_3*(P(gridpoints)-P(gridpoints-1) - rho(gridpoi&
&nts)*c(gridpoints)*(u(gridpoints)-u(gridpoints-1)))
! Compute Exit Mach Number
M(gridpoints) = ((u(gridpoints)+u(gridpoints-1))/2) / ((c(g&
&ridpoints)+c(gridpoints-1))/2)
IF (M(gridpoints)>1) THEN
d_p=(R2+R3)/2
ELSE
d_p=0
END IF
d_rho = (R1+d_p/c(gridpoints)**2)
d_u = (R2-d_p)/(rho(gridpoints)*c(gridpoints))
!end exit conditions
!update flow
rho(gridpoints)=rho(gridpoints)+d_rho
u(gridpoints) = u(gridpoints) + d_u
P(gridpoints) = P(gridpoints) + d_p
T_exit = P(gridpoints)/(rho(gridpoints)*R)
Energy_exit = rho(gridpoints)*(cv*T_exit+1/2*u(gridpoints)*&
&*2)
c(gridpoints) = sqrt(gamma_constant*P(gridpoints)/rho(gridp&
&oints))
M(gridpoints) = u(gridpoints)/c(gridpoints)
W(:,gridpoints) = [ rho(gridpoints) , rho(gridpoints)*u(&
gridpoints) , Energy_exit]
!end flow update
iterations(k)=k
residue=(W_temp(1,:)-W(1,:))
PRINT*, residue
residue=maxval(residue)
residual(k)=residue
k=k+1
END DO !end loop
END PROGRAM Quasi1DEuler
DOUBLE PRECISION FUNCTION S(b)
USE parameters
DOUBLE PRECISION:: b
S=1-h*(sin(pi*b**t1))**t2
RETURN
END FUNCTION S
DOUBLE PRECISION FUNCTION Flux(W1,W2) Result(FluxArray(3,1))
USE parameters
DOUBLE PRECISION, DIMENSION(3,1)::W1, W2, F1, F2
DOUBLE PRECISION::U1,U2,Rh1,Rh2,P1,P2,E1,E2,Rh,P,u,c,Lambda
U1=W1(2,1)/W1(1,1)
U2=W2(2,1)/W2(1,1)
Rh1=W1(1,1)
Rh2=W2(1,1)
P1=(gamma_constant-1)*(W1(3,1)-.5*Rh1*U1**2)
P2=(gamma_constant-1)*(W2(3,1)-.5*Rh2*U2**2)
E1=W1(3,1)
E2=W2(3,1)
F1=(Rh1*U1,Rh1*U1**2+P1,(E1+P1)*U1)
F2=(Rh2*U2,Rh2*U2**2+P2,(E2+P2)*U2)
Rh=.5*(Rh1+Rh2)
P=.5*(P1+P2)
u=.5*(U1+U2)
c=sqrt(gamma_constant*P/Rh)
Lambda=max(u, u+c, u-c)
FluxArray=.5*(F1+F2)-.5*eps*Lambda*(W2-W1)
RETURN
END FUNCTION Flux
DOUBLE PRECISION FUNCTION IsentropicPressure(M)
USE parameters
DOUBLE PRECISION:: M
IsentropicPressure=P_t*(1+.5*(gamma_constant-1)*M**2)**(-gamma_&
&constant/(gamma_constant-1))
RETURN
END FUNCTION IsentropicPressure
DOUBLE PRECISION FUNCTION IsentropicTemperature(M)
USE parameters
DOUBLE PRECISION:: M
IsentropicTemperature=T_t*(1+.5*(gamma_constant-1)*M**2)**(-1)
RETURN
END FUNCTION IsentropicTemperature
答案 0 :(得分:1)
本声明
Q = (0, P(i)*(Sr-Sl), 0)
语法不正确。错误消息Expected PARAMETER symbol in complex constant
表明您的编译器正在尝试将 rhs 解析为文字复数值并失败:它有3个组件,而不是2个格式良好的复数将具有的组件。你的程序中的声明表明你应该在 rhs 上提供一个3元素的向量。为此你需要
Q = (/ 0, P(i)*(Sr-Sl), 0 /)
或者,如果您的编译器是最新的(-ish)
Q = [ 0, P(i)*(Sr-Sl), 0 ]
(
和)
不是文字向量的正确括号。
我认为下一个错误是由编译器阻塞
引起的DOUBLE PRECISION FUNCTION Flux(W1,W2) Result(FluxArray(3,1))
你尝试将函数的返回类型声明两次,一次为DOUBLE PRECISION
,一次为FluxArray(3,1)
(没有我可以看到的显式类型。对于返回a的函数你应该使用后一种形式,即声明一个result
变量。哦,并在函数定义中插入implicit none
并声明结果的类型。