Fortran Coder

查看: 739|回复: 3

[求助] 关于函数中数组的问题

[复制链接]

24

帖子

7

主题

0

精华

熟手

F 币
143 元
贡献
88 点
发表于 2021-11-2 19:38:02 | 显示全部楼层 |阅读模式
[Fortran] 纯文本查看 复制代码
 Module LegendreSeries
    USE set_parameter
    IMPLICIT NONE
    
    INTEGER*4::Degree,DegreeCount !count是勒让德多项式的维度

    REAL*8,private::t1
    REAL*8,private::t2
    REAL*8,private::y1
    REAL*8,private::y2
    REAL*8 by1,by2,tmp
    INTEGER*4 m,n,i 
    
    contains
    FUNCTION xdw_LegendreFunction(theta1,theta2,Degree) RESULT(LendrendIntegration)
    USE set_parameter
    IMPLICIT NONE
    REAL*8            ::theta1,theta2
    INTEGER*4         ::Degree,DegreeCount
    !REAL*8,ALLOCATABLE::LendrendIntegration(:,:)
    !REAL*8,ALLOCATABLE::Lendrend1(:,:)
    !REAL*8,ALLOCATABLE::Lendrend2(:,:)
    REAL*8::LendrendIntegration(DegreeCount,1)
    REAL*8::Lendrend1(DegreeCount,1)
    REAL*8::Lendrend2(DegreeCount,1)
    DegreeCount = (Degree*Degree+Degree)/2+Degree+1
    !ALLOCATE(LendrendIntegration(DegreeCount,1))
    !ALLOCATE(Lendrend1(DegreeCount,1))
    !ALLOCATE(Lendrend2(DegreeCount,1))
     
    t1 = cos(theta1)
    t1 = cos(theta1)
    y1=sqrt(1d0-t1**2)
    y2=sqrt(1d0-t2**2)
    Legendre1(1)=1d0 
    Legendre1(2)=sqrt(3d0)*t1 
    Legendre1(3)=sqrt(3d0)*y1 
    Legendre1(4)=sqrt(5d0)*(3d0*t1**2-1d0)/2d0 
    Legendre1(5)=sqrt(15d0)*t1*y1 
    Legendre1(6)=sqrt(15d0)*y1**2/2d0
 Legendre2(1)=1d0 
    Legendre2(2)=sqrt(3d0)*t2 
    Legendre2(3)=sqrt(3d0)*y2 
    Legendre2(4)=sqrt(5d0)*(3d0*t2**2-1d0)/2d0 
    Legendre2(5)=sqrt(15d0)*t2*y2 
    Legendre2(6)=sqrt(15d0)*y2**2/2d0 
    LegendreIntegration(1)=t2-t1 
    LegendreIntegration(2)=sqrt(3d0)*(t2**2-t1**2)/2d0 
    LegendreIntegration(3)=sqrt(3d0)*(t2*y2-theta2-t1*y1+theta1)/2d0 
    LegendreIntegration(4)=sqrt(5d0)*(t1*y1**2-t2*y2**2)/2d0 
    LegendreIntegration(5)=sqrt(5d0/3d0)*(y1**3-y2**3) 
    LegendreIntegration(6)=sqrt(5d0/12d0)*(3d0*t2-t2**3-3d0*t1+t1**3)


这是写的一个勒让德函数的前边的一部分代码,
报错说
[Fortran] 纯文本查看 复制代码
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(35): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(36): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(37): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(38): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(39): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(40): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(42): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(43): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(44): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(45): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(46): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(47): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(48): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(49): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(50): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(51): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(52): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(53): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(56): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]




可是不是已经声明了数组的大小了么,之前写的是ALLOCATE的写法,不行之后改成了直接赋值数组大小的,还是有错误,这个怎么办呢?

24

帖子

7

主题

0

精华

熟手

F 币
143 元
贡献
88 点
 楼主| 发表于 2021-11-2 20:00:17 | 显示全部楼层
太蠢了,名字输错了、

见笑了属于是

1767

帖子

13

主题

5

精华

论坛跑堂

臭石头雪球

F 币
505 元
贡献
194 点

美女勋章热心勋章星光勋章新人勋章贡献勋章管理勋章帅哥勋章爱心勋章规矩勋章元老勋章水王勋章

发表于 2021-11-2 21:09:35 | 显示全部楼层
好的,你写了 implicit none ,这个问题就比较容易找了。如果没写,那可能更隐蔽。

24

帖子

7

主题

0

精华

熟手

F 币
143 元
贡献
88 点
 楼主| 发表于 2021-11-3 22:29:27 | 显示全部楼层
fcode 发表于 2021-11-2 21:09
好的,你写了 implicit none ,这个问题就比较容易找了。如果没写,那可能更隐蔽。 ...


难受住了
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

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

GMT+8, 2022-8-11 07:58

Powered by Tencent X3.4

© 2013-2022 Tencent

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