Fortran Coder

查看: 2902|回复: 2
打印 上一主题 下一主题

[求助] error #6404: This name does not have a type, and must have an explicit type. ...

[复制链接]

4

帖子

2

主题

0

精华

新人

F 币
27 元
贡献
10 点
跳转到指定楼层
楼主
发表于 2023-9-10 07:31:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
[Fortran] 纯文本查看 复制代码
01program main
02    implicit none
03 
04    integer, parameter :: nvar = 2, nstep=500
05    real(kind=8), dimension(nvar) :: ystart=[0.0d0,0.0d0]
06    real(kind=8), dimension(nstep) :: xx
07    real(kind=8), dimension(nvar,nstep) :: y, ytrue
08 
09    real(kind=8) :: x1=0.0d0, x2=10.0d0
10    integer :: i
11 
12    call rkdub(Qa,xx, y, ystart, nvar, x1, x2, nstep, diff)                                               !这一行出现:error #6404: This name does not have a type, and must have an explicit type.   [QA]
13 
14    print*,y(1,i), y(2,i)
15end program
16    ! Define the Ordinary Differential Equations(ODEs) in this fileubroutine diff(Qa, t, y, dydx)
17   implicit none
18 
19   integer, parameter :: n = 2
20   real(kind=8) :: Qa, t
21   real(kind=8) :: y(n), dydx(n)
22   real(kind=8) :: Kr=1.4
23   real(kind=8) :: Pg=5000000
24   real(kind=8) :: Vg=0.04
25   !real(kind=8), parameter :: Qa=0.0005
26   real(kind=8) :: Dm=0.00025
27   real(kind=8) :: Jm=2
28   real(kind=8) :: Ro=850
29   real(kind=8) :: Cd=0.61
30   real(kind=8) :: Af=0.0005
31   real(kind=8) :: Bg=2
32   ! Define the ODE or ODEs here  
33   !dx(1) = Kr*Pg*(Qa-Dm*x(2))/Vg
34   !dx(2) = (x(2)*x(2)*Ro*Dm*Dm*Dm/(2*(Cd*Af)*(Cd*Af))-Bg*x(2)+x(1)*Dm)/J
35   dydx(1) = Qa-Dm*y(2)
36   !dx(2) = (Dm*Pg/((1-x(1)/Vg)**1.4)-x(2)*x(2)*Ro*Dm*Dm*Dm/(2*(Cd*Af)*(Cd*Af))-Bg*x(2))/Jm
37   dydx(2) = (Dm*(Vg**Kr*Pg/((Vg-y(1))**1.4))-(y(2)*y(2)*Ro*Dm*Dm*Dm)/(2*(Cd*Af)*(Cd*Af))-Bg*y(2))/Jm
38end subroutine diff
39 
40! RK4 numerical solution of differential equations
41subroutine ODE_RK4(Qa,t, y, n, h, yout, diff)
42    implicit none
43    external :: diff
44    integer n
45    real(kind=8) :: Qa, t, h
46    real(kind=8) :: y(n)
47    real(kind=8) :: yout(n)
48    real(kind=8) :: k1(n),k2(n),k3(n),k4(n)
49    ! Calculate k1
50    call diff(Qa, t, y, dydx)                                                                   !这一行出现:error #6404: This name does not have a type, and must have an explicit type.   [QA]
51    k1 = h*dydx
52    call diff(Qa, t+0.5d0*h, y+0.5*k1, dydx)
53    k2 = h*dydx
54    call diff(Qa, t+0.5d0*h, y+0.5*k2, dydx)
55    k3 = h*dydx
56    call diff(Qa, t+h, y+k3, dydx)
57    k4 = h*dydx
58 
59    yout = y + k1/6.0d0 + k2/3.0d0 + k3/3.0d0 + k4/6.0d0
60end subroutine ODE_RK4
61 
62subroutine rkdub(Qa,xx, y, ystart, nvar, x1, x2, nstep, diff)
63    implicit none
64    integer, intent(in) :: nvar, nstep, Qa
65    real(kind=8), intent(in) :: x1, x2
66    real(kind=8), dimension(nvar), intent(in) :: ystart
67    real(kind=8), dimension(nstep), intent(out) :: xx
68    real(kind=8),dimension(nvar,nstep), intent(out) :: y
69    external :: diff
70 
71    real(kind=8) :: h, x
72    integer :: i,j
73 
74    x = x1
75    h = (x2-x1) / nstep
76    xx(1) = x1
77    y(:,1) = ystart
78    do i=2, nstep
79        call ODE_RK4(Qa,x, y(:,i-1), nvar, h, y(:,i), diff)
80        if (x+h == x) then
81        write(*,*) 'stepsize not significant in rkdub'
82    end if
83    x = x + h
84    xx(i) = x
85    end do
86end subroutine rkdub

在第12  和51行出现 error #6404: This name does not have a type, and must have an explicit type.   [QA],请大神指点一下如何修改

分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

213

帖子

2

主题

0

精华

宗师

F 币
2142 元
贡献
875 点

规矩勋章

沙发
发表于 2023-9-10 08:36:23 | 只看该作者
本帖最后由 风平老涡 于 2023-9-10 08:41 编辑

call rkdub(Qa,xx, y, ystart, nvar, x1, x2, nstep, diff)                                               !这一行出现:error #6404: This name does not have a type, and must have an explicit type.   [QA]

其中的Qa, diff没有定义。

在main中加入
external::diff
integer:: Qa

4

帖子

2

主题

0

精华

新人

F 币
27 元
贡献
10 点
板凳
 楼主| 发表于 2023-9-11 13:13:33 | 只看该作者
风平老涡 发表于 2023-9-10 08:36
call rkdub(Qa,xx, y, ystart, nvar, x1, x2, nstep, diff)                                              ...

非常感谢您的回答
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2025-3-15 05:30

Powered by Discuz! X3.4

© 2013-2025 Comsenz Inc.

快速回复 返回顶部 返回列表